In my previous note, I mentioned the steps to authenticate Azure. In this note, I’ll list the steps to authenticate to AWS. The approach will be pretty similar -we create an IAM user with appropriate policies, create/update terraform configuration files, and run the configuration files. Step 1: Create an IAM user To work with resources in AWS, we need appropriate access -read/modify. In this case, we need an IAM user with programmatic access permission (full access) to Amazon S3. Please attach the appropriate policy (AmazonS3FullAccess) and store the Access key ID and Secret Access key securely. We need those in the next step.
Step 2: Update terraform configuration files I followed the instructions here to create the AWS provider usage, authentication, and the instructions to create an Amazon S3 bucket were provided here. As stated in my previous note, the secured credentials (access_key and secret_key) are stored in a .tfvars file. This .tfvars file should not be added to the repository (update .gitignore accordingly). https://gist.github.com/kunduso/91c4a8eb850e9ba9d4e63263f5e51511 https://gist.github.com/kunduso/7416b5da596e93d567fc637c60e5b6a5 Step 3: Execute terraform trial commands (init -> plan -> apply)
After terraform apply
I was able to verify that an Amazon S3 bucket was created under my AWS profile using Terraform configuration files.
Conclusion: The purpose of this note was to authenticate Terraform, and we saw that with the creation of the bucket in Amazon S3.
Other ideas to explore: Is this the best method to authenticate Terraform? How to provision an EC2 instance in AWS using Terraform?