DevOps Classroom Series – 20/Jan/2020

Data-Sources

  • For creating ec2 machine, we need to provide

    • subnet-id
    • security group
    • key value pair
  • One approach create every thing and use the attributes.

  • If we want to use existing subnet-id, security group and key-value pair, we need to know ids, for this terraform has data sources which can query the information from providers.

  • Every provider gives various data sources much like resources.

  • Lets create a simple data source to pull the information of default subnet and create a new subnet


data "aws_vpc" "default" {
    default = true
}

resource "aws_subnet" "extra" {
    cidr_block = "172.31.48.0/20"
    vpc_id = "${data.aws_vpc.default.id}"
}

Terraform provisioning

  • Execution of scripts/ansible/chef after creation of Virtual Machines is supported by terraform provisioners. Refer

Backends

  • Two tf developers have same terraform script and they have applied terraform, it creates two different resources, as the state file is stored on individual developers laptop Preview
  • Now, if we want to restrict these two developers in such a way, whenever they execute terraform it should not create two different but one resource.
  • Terraform supports backends, to store state remotely and terraform also supports locking feature to avoid simultaneous access to terraform state. Preview
  • Refer

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube