DevOps Classroom Series – 25/Feb/2021

Scenario: Lets create the following architecture in AWS

  • The first version of the architecture to be created using terraform looks as shown below
  • So before we start working on terraform, we should know how to manually create it.
  • Now lets try to acheive the same from terraform
  • Create a new folder and in that folder create a terraform file main.tf
  • In todays example lets not hard code the access_key and secret_key
  • So lets create Environmental Variables
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
  • To set environmental variables in Linux
export AWS_ACCESS_KEY_ID="anaccesskey"
export AWS_SECRET_ACCESS_KEY="asecretkey"
  • To set environmental variables in windows powershell
$env:AWS_ACCESS_KEY_ID="youraccesskey"
$env:AWS_SECRET_ACCESS_KEY="your secret key"
  • Now perform init
terraform init
  • Validate the template
terraform validate .
  • Now lets create the resources by executing terraform apply .
  • Now lets verify the vpc manually in the aws console
  • Now lets just apply terraform apply . again
  • Terraform will apply only when there is need to create resources, if the resources are already created and have the same values as you mentioned, terraform will not do anything.
  • Refer Here for the changes
  • Now lets make small change in aws vpc to enable dns support Refer Here for the changes
  • Now lets view the contents of the folder, some new files got generated during apply
  • Lets understand the importance the files generated in our next session.

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%