0
votes

I'm asking you guys, how to set up Terraform in AWS the "right way." What I meant by that is, 2 years ago I graduated with no Terraform knowledge and once I got hired I started writing Terraform scripts but only for 6 months, there was a senior dev who was no longer with us, but he did the initial set up in AWS so that every time we committed a TF script into AWS CodeCommit and then we build the scripts in the said repo using AWS CodeBuild, the infrastructure (i remember it was AWS Lambda, Glue, DynamoDB, Cognito, a bunch of Python code) was deployed without AWS CodeDeploy.

Now, how do i set up the way he did? Do i just simply need to create codecommit and codebuild and start committing TF scripts into codecommit, build, and thats it? Or do i need to spin an EC2 instance?

2
I recommend having a look at atlantis: runatlantis.iojordanm

2 Answers

2
votes

I think your question is about how can you leverage AWS development tools like Codepipeline, CodeCommit, Codebuild, and CodeDeploy to deploy terraform scripts in your AWS. the following example show how create pipeline to deploy terraform: here

0
votes

Based on your use-case, you want to create an IaC pipeline (CICD) to Apply Terraform on AWS.

There are multiple ways to do this, but using only AWS Ecosystem, the following can be implemented:

  • CodeCommit ( Terraform codebase for templates and modules)
  • CodeBuild ( bash scripting for run terraform init/plan/apply etc)
  • CodePipeline ( orchestrate CodeCommit - CodeBuild , add notifications)

You going to need the following:

  • S3 bucket for hosting the TF state files (versioning enabled)
  • Dynamodb Table for state locking
  • KMS custom Key for State encryption on S3

enter image description here

An overall IaC CICD looks like:

iac