Course outlines for learning terraform.
| expected time | requirements |
|---|---|
| 75 minutes | A computer with Terraform installed, terraform knowledge. |
Goal: Setup CI/CD for Terraform modules.
Testing helps you to keep your modules in a good state and makes it easier to contribute.
Let’s take an example BitBucket CI/CD file. (It’s not complete, you’ll make it complete later.)
Add a file to the repository containing a Terraform module called bitbucket-pipelines.yml:
---
image: hashicorp/terraform:full
pipelines:
default:
- step:
script:
- terraform init
And a GitHub actions example. Be aware the the different scenarios (directories in examples need to be listed in the action.
There are many actions that you can use. Pick one that suits your situation.
A realistic example can be found here.
This may take some time, but it’s well worth the effort as these pipelines will run quite frequently. We’ll compare each others code later to learn from each other.
With CI/CD, always start with the smallest unit/component. This ensures you can deliver value incrementally instead of a “waterfall” approach.
string where number is only allowed, and the pipeline should successfully test the failure.) To reverse the exit-status of a command, use !, for example ! false returns an exit-code of 0.terraform apply and terraform destroy.terraform apply the code in CI when testing a module?terraform apply, how would you make sure terraform destroy runs whatever the output of terraform apply. (hint).You may need to place these “secret variables” to the CI system:
AZURE_AD_CLIENT_IDAZURE_AD_CLIENT_SECRETAZURE_AD_TENANT_IDAZURE_SUBSCRIPTION_IDFor GitLab users, a template can be used.