Terraform is an open-source tool for provisioning and managing cloud infrastructure. Terraform can provision resources on any cloud platform.
Terraform allows you to create infrastructure in configuration files(tf files) that describe the topology of cloud resources. These resources include virtual machines, storage accounts, networking interfaces, etc.- Install Terraform on your EC2 instance.
- Create an IAM role or access keys/secret keys
- AWS Access keys + secret keys (un-secure way)
- IAM Role with AmazonEC2FullAccess Policy. (more secure way)

Create Terraform Files
Execute the below command
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
List of Resources created by Terraform

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
All Terraform files should be checked into version control systems such as GitHub, BitBucket or GitLab. Let us see how to push code changes into GitHub. Make sure you are in the directory where Terraform files are created.
Create a new repo with below name, make sure it is a private repo. Also do not click on initialize this repository with a README option.
Note down the remote url under SSH as highlighted below:

Note:
If you have any issues in uploading tf files, you may not have created ssh-keys and uploaded into GitHub. Create ssh keys using ssh-keygen command:
git init
The above command will create local git repository.
Now add terraform files. add only tf files, not other files.
git add *.tf
git commit -m "Added terraform files"
Copy the below red highlighted url from above screenshots circled in red.
git remote add origin your remote repo SSH url per above screenshot, not https url
Now push the code into GitHub
git push -u origin master
Now Login to GitHub to view the Terraform files









I face this issue when i reach the Terraform Plan stage.
ReplyDeleteWhat seems to be the issue?
NoCredentialProviders: no valid providers in chain. Deprecated.
you need to add IAM role or AWS root keys
Delete