DevOps Classroomnotes 28/May/2022

AWS Infra with Terraform

  • We would like to realize the following architecture
    Preview
  • Refer Here for the Terraform local variables.
  • Refer Here for the changeset containing local variables defined and their usage
  • when we execute terraform apply a plan gets created depending on what has to be created. Generally when we apply terraform apply the plan gets created internally, we can create the plan externally as well.
  • Now execute `terraform plan -out “myfirstplan”
    Preview
    Preview
  • Now execute terrform apply “myfirstplan”
    Preview
  • Now we have a small fix for security egress rules Refer Here for the changes. Execute the application by following command
    terraform apply -auto-approve
    Preview
  • Now lets add public and private route tables Refer Here for the resource documentation.
  • Refer Here for public and private routetables added into terraform
  • Now we need to associate route tables with subnets. Refer Here for the resource documentation
  • One approach is to use this
resource "aws_route_table_association" "associations" {
    count               = length(aws_subnet.subnets)
    subnet_id           = aws_subnet.subnets[count.index].id
    route_table_id      = count.index<2 ? aws_route_table.publicrt.id :  aws_route_table.privatert.id

}
  • Refer Here for the usage of condition with variable with configurable public subnets, by default subnets not defined in public_subnets variable are private Refer Here for the changes done.
  • Lets add db security group as well Refer Here for the changes
  • To Create explicit dependecies, we use depends on Refer Here. Refer Here for the changes done

AWS RDS Creation

  • Manual Steps: refer class room video
  • As tried we need to have the following before we create rds
    • Security group
    • Subnet Group
  • We already have the Security Group, lets create the db subnet group
  • If we need to pull information from aws regarding any resource we can use data source which is like query to a provider Refer Here
  • Refer Here for the usage of datasources and creating db subnet group
  • Note: from now on i will not be creating variables/locals until and unless it is important. I would expect you to change that while practicing
  • Refer Here for the changeset to rds instance in our vpc

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner