Terraform Assignment

·

2 min read

1] Learn about tfvars file?

In Terraform, a .tfvars file is used to pass variable values into your Terraform configuration. This allows you to separate configuration from variable definitions, making it easier to manage and share configurations.

Terraform automatically loads all files in the current directory with the exact name terraform.tfvars or matching *.auto.tfvars


2] Work on terraform import

I. Import an EC2 instance created through console to your state file.

II. Import a security group created through console to your state file.


3] Setup terraform backend and store the state file in the S3 bucket.


4] Create terraform module and raise a pull request to https://github.com/artisantek/terraform-modules

a. Create a module to set up an s3 bucket.

b. Create a module for setting up a DynamoDB table.


5] Learn about terraform templates

Terraform templates refer to reusable and shareable configurations that can be used to manage infrastructure as code. These templates enable you to define your cloud and on-premises resources in a consistent, version-controlled manner


6. Use for_each to create multiple EC2 instances.

Here I have created IAM users using for_each Meta-argument


7] Use data sources to pull latest Ubuntu AMI


8] Use terraform work spaces and use them to manage separate environment for DEV, UAT and PROD using same configuration files.


9] Learn about terraform graph

The terraform graph command in Terraform generates a visual representation of the dependencies in your Terraform configuration. This can be extremely helpful for understanding the relationships between resources and how they are orchestrated. The graph is output in the DOT format, which can be visualized using tools like Graphviz.

To generate a graph, simply run:

terraform graph