A project to demonstrate how to automate terraform workflow with Github Actions.
These instructions will get you a copy of the project up and running on your local machine for development purpose.
To get started with this project you need a basic knowledge of the following.
Version Control (Git)
Terraform
AWS
-
Login to your AWS account and generate
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
. -
After that, login to your Terraform Cloud account. Create a new workspace and select API-driven workflow.
-
Then navigate to the Variables tab and click on Add variable. Add
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
with their respective values. -
From your Terraform Cloud User Settings, click on Tokens and generate an API token named
GitHub Actions
. -
Add the token to your Github repository as a secret. Name the secret
TF_API_TOKEN
. -
Clone and open your Github repo on your code editor.
-
Checkout to a new branch with
git checkout -b <branch-name>
. -
Add your changes with
git add .
and commit the changes with a message usinggit commit -m "<commit-message>"
. -
Then push your changes with
git push
. -
Go back to the Github repository and generate a pull request from the new branch. You can view the status of the job through the pull request created, Actions tab or the Terraform Cloud workspace.
-
Then merge the pull request.
- Github
- Forem