Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This tutorial will walk you through how to create and configure the pipeline step for Terraform Script.

The below mentioned steps will guide the step by step workflow for Terraform Script:

  1. On a Pipeline, add a step for ‘Terraform’ Tool type

Image RemovedImage Added

2. Once the step tool and name is entered, click ‘Save’ button

Image RemovedImage Added

3. Identify the Terraform script available in Git Repository.

Scenario-1: Having AWS Credentials - Static on the Terraform script as shown below

In the below example, we have the Terraform script available at ‘python-example > Terraform > Terraform > subnet.tf’

Image RemovedImage Added

4. On pipeline, Terraform script step → Click on the ‘Configuration’ icon to enter step level configuration to invoke Terraform script run in G

Image RemovedImage Added

5. On the configuration window, select/enter the details on all the fields

Image RemovedImage Added

6. Once all the configurations are set, click on ‘Save’ button to save the pipeline step

Image RemovedImage Added

7. Click on ‘Start Pipeline’ to start the execution of the pipeline

Image RemovedImage Added

8. Pipeline will start and will show a blue bar with predefined message as an indication

Image RemovedImage Added

9. Once the script is executed and successful, a green tick will appear on the step

Image RemovedImage Added

10. The script success can be tracked in the Summary tab > Activity logs as well

Image RemovedImage Added

11. Output of the script is given below - where the Terraform script is meant to fetch the Subnet IDs of the VPC given as ‘Terraform script argument’.

Output: Terraform script initialized and 3 Subnet IDs are fetched.

Image RemovedImage Added

Scenario-2: Having AWS Credentials - Dynamic on the Terraform script as shown below

In the below example, we have the Terraform script available at ‘python-example > Terraform > Terraform > subnet.tf’

Image RemovedImage Added

12. On pipeline, Terraform script step → Click on the ‘Configuration’ icon to enter step level configuration to invoke Terraform script run from GITHUB REPOSITORY

Image RemovedImage Added

13. On the configuration window, select/enter the details on all the fields

Image RemovedImage Added

14. Once all the configurations are set, click on ‘Save’ button to save the pipeline step

Image RemovedImage Added

15. Click on ‘Start Pipeline’ to start the execution of the pipeline

Image RemovedImage Added

16. Pipeline will start and will show a blue bar with predefined message as an indication

Image RemovedImage Added

17. Once the script is executed and successful, a green tick will appear on the step

Image RemovedImage Added

18. The script success can be tracked in the Summary tab > Activity logs as well

Image RemovedImage Added

19. Output of the script is given below - where the Terraform script is meant to fetch the Subnet IDs of the VPC given as ‘Terraform script argument’.

Output: Terraform script initialized and 3 Subnet IDs are fetched.

Image RemovedImage Added

A Sample Terraform script from GITLAB and GITHUB and its workflow has been demonstrated above, which in the same way can be used to invoke any possible Terraform script.