java-tutorials/terraform-modules/best-practices/ec2-simple/main.tf

34 lines
526 B
Terraform
Raw Normal View History

2020-03-29 10:49:46 -04:00
#
# Resource definitions
#
data "aws_ami" "apache" {
filter {
name = "name"
values = [var.ami_name]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = [var.ami_owner]
most_recent = true
}
resource "aws_instance" "web" {
ami = data.aws_ami.apache.id
instance_type = "t2.micro"
subnet_id = aws_subnet.frontend.id
}
resource "aws_subnet" "frontend" {
vpc_id = aws_vpc.apps.id
cidr_block = "10.0.1.0/24"
}
resource "aws_vpc" "apps" {
cidr_block = "10.0.0.0/16"
}