Skip to content

Commit

Permalink
Add dependency management
Browse files Browse the repository at this point in the history
- Pinned down a specific version of terraform plugins and terraform
for compatibility reasons. Check the following link for more info:
	hashicorp/terraform#15756
  • Loading branch information
dikhan committed Dec 28, 2017
1 parent 05bc5f3 commit 77d2243
Show file tree
Hide file tree
Showing 7,562 changed files with 3,133,721 additions and 21 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
14 changes: 0 additions & 14 deletions Makefile

This file was deleted.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ input environment variable OTF_VAR_{PROVIDER_NAME}_SWAGGER_URL will be pointing
$ terraform init && OTF_VAR_{PROVIDER_NAME}_SWAGGER_URL="https://some-domain/swagger.yaml" terraform plan
```

Additionally, a convenient [Makefile](terraform_provivider_api/Makefile) is provided allowing the user to execute
the above in just one command as follows:
```
cd terraform_provider_api
make run_terraform PROVIDER_NAME="sp" OTF_VAR_SWAGGER_URL="https://some-domain/swagger.yaml" TF_CMD=plan
```

For more information refer to [How to set up the local environment?](./docs/local_environment.md) which explains in
detail

Expand Down
45 changes: 38 additions & 7 deletions docs/local_environment.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
# Setting up a local environment

A [docker-compose](docker-compose.yml) file has been created to ease the execution of an example. In order to bring up
the service provider example and also render a UI from the swagger file that can be accessed from the browser, please
run the following command from the root folder:
## Running docker compose

A [docker-compose](https://github.com/dikhan/terraform-provider-openapi/blob/master/docker-compose.yml) file has been created to ease the execution of an example. This will start up
a server that exposes its APIs in a swagger file.

```
docker-compose up --build --force-recreate
```

Once docker-compose is done bringing up both services, the following command will read the sample [main.tf](terraform_provider_api/main.tf)
file and execute terraform plan:
In addition, it will also render a UI from the swagger file exposed by the API server that can be accessed from the
browser at:

```
https://localhost:8443
```

The UI rendered feeds from the swagger file located at [docker-compose](https://github.com/dikhan/terraform-provider-openapi/blob/master/service_provider_example/resources/swagger.yaml)

## Trying out the service provider example

### Building the terraform provider plugin binary

Once docker-compose is done bringing up the API server, the following command will read the sample [main.tf](terraform_provider_api/main.tf)
file and build the terraform provider plugin:
```
$ cd terraform_provider_api
$ go build -o terraform-provider-sp
```

Looking carefully at the above command, the binary is named as 'terraform-provider-sp'. The reason for this is so
terraform knows what provider binary it should call when creating resources for 'sp' provider as defined in [main.tf](terraform_provider_api/main.tf)
file.
terraform knows what provider binary it should call when creating resources for 'sp' provider as defined in [main.tf](terraform_provider_api/main.tf)
file.

### Running the terraform plan

With the new provider binary in place, we can now execute terraform commands.

Expand Down Expand Up @@ -89,3 +105,18 @@ Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
```

And a 'terraform.tfstate' should have been created by terraform containing the state of the new resource created.


## Using the Makefile

A convenient [Makefile](https://github.com/dikhan/terraform-provider-openapi/blob/master/terraform_provider_api/Makefile)
is provided allowing the user to execute the above in just one command as follows:
```
make run_terraform TF_CMD=plan
```

The above command will build the binary with a default value - terraform-provider-sp and then it will export the
OTF_VAR_{PROVIDER_NAME}_SWAGGER_URL with a default value pointing to the local example API server that should be
running already after having run docker compose as specified. The value passed in to the TF_CMD parameter will be
the command terraform will execute (e,g: apply/plan/refresh etc)

Loading

0 comments on commit 77d2243

Please sign in to comment.