Terraform (Day-2)
Topic Includes:
* HCLBlocks, Parameters & Arguments
* Variables, Datatypes and Expression
* Configurations
Task 1
HashiCorp Configuration Language (HCL) is the language used in Terraform configuration files to define infrastructure resources and their configurations. Within HCL, you have blocks, parameters, and arguments.
Blocks: Blocks are used to define resources, data sources, providers, and more. Blocks are identified by their block type, and they enclose a set of parameters and arguments.
Parameters are essentially the properties or attributes of a resource type that can be configured. Each resource type has its own set of parameters that define how the resource should behave.
Arguments, also known as argument values, are the values you assign to parameters. They specify the actual values you want to use when creating the resource.
Different types of resources and data sources available in Terraform
Resources are the fundamental building blocks in Terraform. They represent the infrastructure components you want to create, modify, or delete.
Compute Resources
aws_instance: Represents an EC2 instance in AWS.google_compute_instance: Represents a Compute Engine instance in Google Cloud.Storage Resources:
aws_s3_bucket: Represents an S3 bucket in AWS.google_storage_bucket: Represents a Google Cloud Storage bucket in Google Cloud.
Container Resources:
docker_container: Represents a Docker container.kubernetes_deployment: Represents a Kubernetes deployment.
In Terraform, data sources are used to query existing resources or retrieve information from external sources, such as APIs or databases, and make that data available for use within your Terraform configuration.
AWS Data Sources:
aws_ami: Retrieves information about an Amazon Machine Image (AMI).aws_vpc: Retrieves details about a Virtual Private Cloud (VPC).aws_subnet: Retrieves information about a subnet.aws_security_group: Retrieves details about a security group.aws_s3_bucket: Retrieves information about an S3 bucket.
Task 2
Create a variables.tf file and define a variable
Use the variable in a main.tf file to create a "local_file" resource
In Terraform, variables are used to parameterize your infrastructure code and make it more flexible and reusable. Variables allow you to pass values into your Terraform configurations. Here's how you can define and use variables in Terraform:
Variable Declaration: Define variables in your Terraform configuration using the variable block. You specify the variable name and an optional description, and you can set a default value if desired.



Task 3:Writing Terraform configurations using HCL syntax
Provider is the block type used to configure Terraform to use the third-party tools and this has to be configured in terraform.tf file.

As you wrap up this Terraform primer, remember that the world of infrastructure as code is dynamic and ever-evolving. Stay curious, stay creative, and stay Terraform-powered. The possibilities are endless!"



