Introduction

Docker image to run API server to interact with OCI.

The server is providing rest API leveraging the following pyhton modules

  • Flask --> microframework
  • Flask-RESTPlus --> Flask extension to build REST API
  • python-terraform --> providea a wrapper of terraform command line tool

Installation

    git clone ...
    ./build.sh

Usage

Run API Server

To run the server as daemon

    ./run-server.sh
    #API Server running on http://localhost:5000/
    

To stop the server

    ./stop-server.sh
    

To run the server in interactive mode

    ./run-server-interactive.sh
    #API Server running on http://localhost:5000/
    

The server will run terraform init on the provided directory at startup

Available API

  • plan

      shows an execution plan summary
    
  • apply

      builds or changes infrastructure according to Terraform configuration in the working directory
    
    NOTE: this will apply the configuration without asking for confirmation
  • destroy

      destroy Terraform-managed infrastructure.
    
    NOTE: this will destroy all without asking for confirmation

Examples

$ curl http://localhost:5000/plan
{
    "plan": [
        "add oci_core_internet_gateway.internetgateway1", 
        "add oci_core_virtual_network.vcn1"
    ]
}
$ curl http://localhost:5000/apply
{
    "apply": "Apply complete! Resources: 2 added, 0 changed, 0 destroyed."
}
$ curl http://localhost:5000/destroy
{
    "destroy": "Destroy complete! Resources: 2 destroyed."
}