Created
April 17, 2024 01:33
-
-
Save overnew/6a643ff236c78613bf16e8ccee76178b to your computer and use it in GitHub Desktop.
latest ec2 terraform example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configure the AWS Provider | |
provider "aws" { | |
region = "ap-northeast-2" | |
} | |
# resource - instanace | |
resource "aws_instance" "mymymi_ubuntu" { | |
ami = data.aws_ami.ubuntu.id | |
instance_type = "t2.micro" | |
tags = { | |
Name = "latest-ec2" | |
} | |
} | |
# data - aws_ami | |
data "aws_ami" "ubuntu" { | |
most_recent = true #최신 것을 가져오도록 세팅 | |
filter { | |
name = "name" | |
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-22.04-amd64-server-*"] | |
} | |
filter { | |
name = "virtualization-type" | |
values = ["hvm"] | |
} | |
owners = ["099720109477"] # Canonical | |
# Owners는 AWS의 공식 계정의 AMI를 가져오도록 하는 것을 의미한다. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment