DevOps Classroomnotes 23/Dec/2021

Activity 2 AWS infra continued

  • Adding Database:
  • Creating Db subnet group from two db subnets Refer Here
  • Now lets create a database from the resource Refer Here.
  • Refer Here for the changes done
  • Generally it is a good idea to show some outputs to the users whenever they execute terraform apply
  • For writing outputs Refer Here for official documentation
  • Lets add two simple outputs and see the terraform output while apply
output "web1_publicip" {
    value = aws_instance.web_instance_1.public_ip
}

output "db_endpoint" {
    value = aws_db_instance.db.endpoint
}

Preview
* Lets create more outputs
* vpc id
* subnet id
* security group ids
* ec2 ip address
* db endpoint
* ec2 url => http://<publicip&gt;

  • Terraform has inbuilt functions which will help us Refer Here
  • Now applying format function and using the outputs section Refer Here for the changes.
    Preview

Dependencies in Terraform

  • We can generate a graph from terraform command which will generate dot format, which can be used to create a graph
    Preview
  • Terraform has two kinds of dependencies
  • implicit
    • Created by referring attributes of one resource in another
  • explicit
    • Using depends_on

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner