forked from tekglobals/terraform24
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.tf
47 lines (39 loc) · 797 Bytes
/
data.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
provider "aws" {
region = "us-east-2"
}
data "aws_vpc" "class2vpc" {
filter {
name = "tag:Name"
values = ["prod"]
}
}
output "myvpc" {
value = data.aws_vpc.class2vpc.id
}
resource "aws_subnet" "class2sub" {
cidr_block = "10.0.1.0/24"
vpc_id = data.aws_vpc.class2vpc.id
}
data "aws_ami" "myami" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm-*-gp2"]
}
}
output "myamis" {
value = data.aws_ami.myami.id
}
resource "aws_instance" "class2ec2" {
for_each = {
prod = "t2.medium"
dev = "t2.micro"
}
ami = data.aws_ami.myami.id
instance_type = each.value
subnet_id = aws_subnet.class2sub.id
tags = {
Name = "class2 ${each.key}"
}
}