forked from joshuamkite/terraform-aws-ssh-bastion-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocals.tf
68 lines (57 loc) · 1.92 KB
/
locals.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
##########################
#Create local for bastion hostname
##########################
locals {
bastion_vpc_name = var.bastion_vpc_name == "vpc_id" ? var.vpc : var.bastion_vpc_name
bastion_host_name = var.bastion_host_name == "" ? join(
"-",
compact(
[
var.environment_name,
data.aws_region.current.name,
local.bastion_vpc_name,
],
),
) : var.bastion_host_name
}
##########################
# Logic for security group and listeners
##########################
locals {
hostport_whitelisted = join(",", var.cidr_blocks_whitelist_host) != ""
hostport_healthcheck = var.lb_healthcheck_port == "2222"
}
##########################
# Logic tests for assume role vs same account
##########################
locals {
assume_role_yes = var.assume_role_arn != "" ? 1 : 0
assume_role_no = var.assume_role_arn == "" ? 1 : 0
}
##########################
# Logic for using module default userdata sections or not
##########################
locals {
custom_ssh_populate_no = var.custom_ssh_populate == "" ? 1 : 0
custom_authorized_keys_command_no = var.custom_authorized_keys_command == "" ? 1 : 0
custom_docker_setup_no = var.custom_docker_setup == "" ? 1 : 0
custom_systemd_no = var.custom_systemd == "" ? 1 : 0
}
##########################
# Logic for using module default or custom ami
##########################
locals {
bastion_ami_id = var.custom_ami_id == "" ? data.aws_ami.debian.id : var.custom_ami_id
}
##########################
# Logic for using cidr_blocks_whitelist_service ONLY if provided
##########################
locals {
cidr_blocks_whitelist_service_yes = join(",", var.cidr_blocks_whitelist_service) != "" ? 1 : 0
}
##########################
# Construct route53 name for historical behaviour where used
##########################
locals {
route53_name_components = "${local.bastion_host_name}-${var.service_name}.${var.dns_domain}"
}