Skip to content

Instantly share code, notes, and snippets.

@overnew
Created April 17, 2024 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save overnew/6a643ff236c78613bf16e8ccee76178b to your computer and use it in GitHub Desktop.
Save overnew/6a643ff236c78613bf16e8ccee76178b to your computer and use it in GitHub Desktop.
latest ec2 terraform example
# 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