DevOps(Day-85): Create a security group using terraform
TABLE OF CONTENTS
Understanding Terraform Resources
Task 1: Create a security group
Yesterday, we saw how to create a Terraform script with Blocks and Resources. Today, we will dive deeper into Terraform resources.
Understanding Terraform Resources
A resource in Terraform represents a component of your infrastructure, such as a physical server, a virtual machine, a DNS record, or an S3 bucket. Resources have attributes that define their properties and behaviours, such as the size and location of a virtual machine or the domain name of a DNS record.
When you define a resource in Terraform, you specify the type of resource, a unique name for the resource, and the attributes that define the resource. Terraform uses the resource block to define resources in your Terraform configuration.
Task 1: Create a security group
To allow traffic to the EC2 instance, you need to create a security group. Follow these steps:
In your main.tf file, add the following code to create a security group:
Create the terraform.tf file to define the providers
Create the provider.tf file to define the region.
Run terraform init to initialize the Terraform project.
Run terraform apply to create the security group.
Verify the console for the created security group by terraform.
Thanks for reading my article. Have a nice day.
Comments
Post a Comment