Description: Here I have explained, How to integrated GitHub with Terraform cloud to driven the workflow using VCS. When you integrate the GitHub with terraform cloud your terraform project tf files saved in GitHub repository. Whenever you make any changes in GitHub files workflow run automatically.
GitHub Repository:
The first step, we setup blank public repository in GitHub. To create the blank repository navigate GitHub and create blank repository with Readme file
Clone the newly created repository in local folder using git clone command
git clone https://github.com/harpal1990/testrepo-tfcloud.git
After clone the repository I am adding terraform project files in same directory and upload it to repository. So I have uploaded main.tf and install_nginx.sh file as part of my terraform project
Now to push it to repository we need git username and password. So generate git token from the GitHub. To generate GitHub token navigate to user setting in GitHub --> Developer Settings --> Personal access tokens --> Tokens (classic) --> Generate new token
Once you add the additional files and push to origin branch it asked for password/token as follow
Select GiHub as subversion control system and click on next
Once you click on GitHub it will popup for account authorization
First variable add for region as follow
Now add access key and secret key for authorization to AWS as follow
After applying all the variable set run the task from the workspace and confirm apply
In EC2 you can find the instance in the listDestruction and Deletion: To remove the instance and workspace follow the below steps
- Goto -> Workspace -> Settings -> Destruction and Deletion
- click on Queue Destroy Plan to delete the resources on cloud
- Goto -> Workspac -> Runs -> Click on Confirm & Apply
- Add Comment: Approved for Deletion
No comments:
Post a Comment