You can use the following Terraform script to Deploy an Instance in your AWS Account. Terraform will create a t2.medium instance from the official RHEL7.2 AMI using the AMI ID within the specified subnet. And will create a 30GB root block device and a 10GB Ebs volume. The instance will use a predefined key and will add the specified tags to the Instance Being Launched.
provider "aws" {
access_key = "AKXXXXXXXXXXXXXXXXX"
secret_key = "2YXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx"
region = "ap-south-1"
}
resource "aws_instance" "instance_name" {
ami = "ami-cdbdd7a2"
count = 1
instance_type = "t2.medium"
security_groups = ["sg-f70674re"]
subnet_id = "subnet-526bcb6d"
root_block_device = {
volume_type = "standard"
volume_size = "30"
}
ebs_block_device = {
device_name = "/dev/sdm"
volume_type = "gp2"
volume_size = "10"
}
source_dest_check = true
key_name = "Keyname"
tags {
Name = "tagname"
}
}
0 comments:
Post a Comment