-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.tf
51 lines (46 loc) · 1.04 KB
/
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
48
49
50
51
data "aws_region" "this" {}
data "aws_availability_zones" "this" {}
data "aws_ami" "default_ami" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["al2023-ami-2023**"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
filter {
name = "architecture"
values = ["x86_64"]
}
}
data "aws_ami" "preferred_ami" {
count = var.preferred_ami_id != "" ? 1 : 0
filter {
name = "image-id"
values = [var.preferred_ami_id]
}
}
data "aws_instances" "bastion" {
instance_tags = {
purpose = "bastion"
prefix = var.resource_prefix
Name = "${var.resource_prefix}-bastion"
}
filter {
name = "instance-state-name"
values = ["pending", "running"]
}
depends_on = [aws_autoscaling_group.bastion_host_asg]
}
data "cloudinit_config" "bastion_cloudinit" {
base64_encode = true
part {
content_type = "text/x-shellscript"
content = templatefile("${path.module}/template/userdata.tpl", {
aws_region = data.aws_region.this.name
})
}
}