AWS Infrastructure as Code(IaC) using Codepipeline with Terraform to provision resources for an enterprize application.
- Terraform Initialize
terraform init
- Observation: Initialized Local Backend,Downloaded the provider plugins (initialized plugins) and Review the folder structure
.terraform folder
- Terraform Validate
terraform validate
Observation:
If any changes to files, those will come as printed in stdout (those file names will be printed in CLI)- Terraform Plan
terraform plan
-> Observation:No changes - Just prints the execution plan
- Terraform Apply
terraform apply
then approve ORterraform apply -auto-approve
NOTE:
To use the secret file for the DB - runterraform plan -var-file=secrets.tfvars
ORterraform apply -var-file=secrets.tfvars
- Terraform Destroy
terraform plan destroy
then approve ORterraform destroy -auto-approve
- Clean-Up Files:
rm -rf .terraform*
andrm -rf terraform.tfstate*
Deployment to different environments requires merging all the .auto.tfvars
files to leverage the same terraform configuration across environments
- Pass the
.tfvars
file-var-file
argument toterraform apply
for each environment ->terraform apply -input=false -var-file=dev.tfvars -auto-approve
- Navigate to
AWS Systems Manager
-> Application tools then selectParameter Store
to create secret variables - Create a
GetParameter
access inAWS IAM
for CodeBuild service role build project
- Create AWS hosted zones for your domain name on AWS
-> Records servers = NS
- Copy the
NS
fromAWS
to theCheapname Domain platform
asHost Records
->Custom DNS