- Install Terraform on your local machine.
- Create a new directory for your Terraform project.
- Create a new file in the directory named "main.tf".
- Add the following code to "main.tf":
main.tf
provider "aws" {
region = "us-east-1"
}
resource "aws_vpc" "example_vpc" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "example_subnet_1" {
vpc_id = aws_vpc.example_vpc.id
cidr_block = "10.0.1.0/24"
}
resource "aws_subnet" "example_subnet_2" {
vpc_id = aws_vpc.example_vpc.id
cidr_block = "10.0.2.0/24"
}
resource "aws_security_group" "example_sg_1" {
name_prefix = "example_sg_1"
vpc_id = aws_vpc.example_vpc.id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_security_group" "example_sg_2" {
name_prefix = "example_sg_2"
vpc_id = aws_vpc.example_vpc.id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "example_instance_1" {
ami = "ami-0a5ae2501482eae54"
instance_type = "t2.micro"
subnet_id = aws_subnet.example_subnet_1.id
vpc_security_group_ids = [aws_security_group.example_sg_1.id]
}
resource "aws_instance" "example_instance_2" {
ami = "ami-0a5ae2501482eae54"
instance_type = "t2.micro"
subnet_id = aws_subnet.example_subnet_2.id
vpc_security_group_ids = [aws_security_group.example_sg_2.id]
}
Note: In this example, we are using the US East 1 region, so please change it to the region of your choice.
- Save the file.
- Initialize your Terraform project by running
terraform init
in your project directory. - Create a plan for your infrastructure by running
terraform plan
. - Apply the changes to create your VPC and instances by running
terraform apply
. - Once the instances have been created, you can access them via SSH using their public IP addresses.
And that's it! You should now have a VPC with two instances of CentOS 9 running in AWS, created using Terraform.
From chat GPT.
Amazon QuickSight is a cloud-based business intelligence (BI) and analytics service offered by Amazon Web Services (AWS). It allows users to create and share interactive dashboards, visualizations, and reports from a variety of data sources. QuickSight is designed to be fast, scalable, and cost-effective, making it an attractive option for organizations of all sizes.One of the key benefits of Amazon QuickSight is its ease of use. For more information about the Amazon QuickSight consulting services, call us @ 1-289-952-8845.
ReplyDelete