Below are the steps that one should follow in order to setup a CI/CD pipeline with Terraform Cloud, AWS and GitHub.
First step is to configure AWS by creating a new user, we are going to complete this task in the AWS console.
Under IAM — Click on users and click on “Add User” enter a username and add a permission to the user.
After adding the permission, download the .csv file that contains the Access Key ID and the Secret Key ID and store it in a safe place.
Now login to your GitHub account and create a repository.
Upload the Terraform code that you’ve written to provision your AWS resources. If you do not have one check out my previous post here.
Now its time to login to your Terraform Cloud account or click here and create one if you do not have an account. I will suggest that you sign in using your GitHub account.
Terraform cloud makes it easy for users to collaborate on Terraform configurations through versioned and shared Terraform state files.
Now that we got an idea what Terraform Cloud is, it’s time to link our GitHub account to Terraform Cloud to establish a CI/CD Pipeline.
In GitHub create a new repository and push your Terraform code to it.
Now that all your files are uploaded, it’s now time to create a new Organization inside Terraform Cloud.
Click on New workspace.
Click on GitHub
Select the repository that has your Terraform code.
Now click on Create workspace.
You should now see the message below, stating that the configuration has been uploaded.
Now it’s time to configure the variables.
Under Environment Variables add your Access Keys, Secret Keys and your default region. Remember that you must never include that information in your code.
Now its now the time to run the Terraform code by clicking Queue plan
Now everything looks like its running just fine
After everything ran perfectly, this is what I see on my dashboard.
Congratulations!!!!!!!!!! You’ve implemented your first GitHub CI/CD pipeline for AWS using Terraform Cloud.