Difference between revisions of "Aws ec2 instance state"
Jump to navigation
Jump to search
(Created page with " {{aws_instance}}") |
|||
Line 1: | Line 1: | ||
+ | <pre> | ||
+ | data "aws_ami" "ubuntu" { | ||
+ | most_recent = true | ||
+ | |||
+ | filter { | ||
+ | name = "name" | ||
+ | values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] | ||
+ | } | ||
+ | |||
+ | filter { | ||
+ | name = "virtualization-type" | ||
+ | values = ["hvm"] | ||
+ | } | ||
+ | |||
+ | owners = ["099720109477"] # Canonical | ||
+ | } | ||
+ | |||
+ | resource "aws_instance" "test" { | ||
+ | ami = data.aws_ami.ubuntu.id | ||
+ | instance_type = "t3.micro" | ||
+ | |||
+ | tags = { | ||
+ | Name = "HelloWorld" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | resource "aws_ec2_instance_state" "test" { | ||
+ | instance_id = aws_instance.test.id | ||
+ | state = "stopped" | ||
+ | } | ||
+ | </pre> | ||
{{aws_instance}} | {{aws_instance}} |
Revision as of 17:17, 23 March 2023
data "aws_ami" "ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical } resource "aws_instance" "test" { ami = data.aws_ami.ubuntu.id instance_type = "t3.micro" tags = { Name = "HelloWorld" } } resource "aws_ec2_instance_state" "test" { instance_id = aws_instance.test.id state = "stopped" }
Terraform AWS: aws_instance
: ami
, availability_zone
, instance_type
, key_name
, aws_key_pair
, monitoring
, associate_public_ip_address
, tenancy
, subnet_id, user_data, iam_instance_profile, vpc_security_group_ids, root_block_device, ebs_block_device
Advertising: