-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathec2.tf
46 lines (37 loc) · 1.48 KB
/
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
40
41
42
43
44
45
46
###################################################
# Public Access Block for EC2 AMI
###################################################
resource "aws_ec2_image_block_public_access" "this" {
state = (var.ec2.ami_public_access_enabled
? "unblocked"
: "block-new-sharing"
)
}
###################################################
# Instance Metadata Defaults for EC2
###################################################
resource "aws_ec2_instance_metadata_defaults" "this" {
count = anytrue([
for k, v in var.ec2.instance_metadata_defaults :
v != null
]) ? 1 : 0
http_endpoint = (var.ec2.instance_metadata_defaults.http_enabled != null
? (var.ec2.instance_metadata_defaults.http_enabled ? "enabled" : "disabled")
: "no-preference"
)
http_tokens = (var.ec2.instance_metadata_defaults.http_token_required != null
? (var.ec2.instance_metadata_defaults.http_token_required ? "required" : "optional")
: "no-preference"
)
http_put_response_hop_limit = coalesce(var.ec2.instance_metadata_defaults.http_put_response_hop_limit, -1)
instance_metadata_tags = (var.ec2.instance_metadata_defaults.instance_tags_enabled != null
? (var.ec2.instance_metadata_defaults.instance_tags_enabled ? "enabled" : "disabled")
: "no-preference"
)
}
###################################################
# Serial Consol Access for EC2
###################################################
resource "aws_ec2_serial_console_access" "this" {
enabled = var.ec2.serial_console_enabled
}