-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathec2.tf
39 lines (33 loc) · 840 Bytes
/
ec2.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
provider "aws" {
region = "us-east-1"
}
data "aws_ami" "suse12" {
owners = ["amazon"]
most_recent = true
filter {
name = "name"
values = ["*suse*"]
}
}
locals {
instances = toset(["one", "two"])
}
resource "aws_instance" "suse12" {
for_each = local.instances
ami = data.aws_ami.suse12.id
instance_type = "m5d.large"
availability_zone = "us-east-1a"
tags = { Name = each.value }
}
resource "aws_ebs_volume" "data-ndj" {
for_each = local.instances
type = "gp2"
size = 110
availability_zone = "us-east-1a"
}
resource "aws_volume_attachment" "data-ndj" {
for_each = local.instances
device_name = "/dev/sdj"
instance_id = aws_instance.suse12[each.key].id
volume_id = aws_ebs_volume.data-ndj[each.key].id
}