forked from terraform-ibm-modules/terraform-ibm-landing-zone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bastion_host.tf
76 lines (66 loc) · 3.88 KB
/
bastion_host.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
68
69
70
71
72
73
74
75
76
##############################################################################
# Bastion Host Locals
##############################################################################
locals {
bastion_vsi_map = module.dynamic_values.bastion_vsi_map
}
##############################################################################
##############################################################################
# Configure Teleport
##############################################################################
module "teleport_config" {
count = local.create_bastion_host ? 1 : 0
source = "./teleport_config"
teleport_licence = var.teleport_config_data.teleport_license
https_certs = var.teleport_config_data.https_cert
https_key = var.teleport_config_data.https_key
hostname = var.teleport_config_data.hostname
domain = var.teleport_config_data.domain
cos_bucket = ibm_cos_bucket.buckets[var.teleport_config_data.cos_bucket_name].bucket_name
cos_bucket_endpoint = ibm_cos_bucket.buckets[var.teleport_config_data.cos_bucket_name].s3_endpoint_public
hmac_access_key_id = ibm_resource_key.key[var.teleport_config_data.cos_key_name].credentials["cos_hmac_keys.access_key_id"]
hmac_secret_access_key_id = ibm_resource_key.key[var.teleport_config_data.cos_key_name].credentials["cos_hmac_keys.secret_access_key"]
appid_client_id = ibm_resource_key.appid_key[var.teleport_config_data.app_id_key_name].credentials["clientId"]
appid_client_secret = ibm_resource_key.appid_key[var.teleport_config_data.app_id_key_name].credentials["secret"]
appid_issuer_url = ibm_resource_key.appid_key[var.teleport_config_data.app_id_key_name].credentials["oauthServerUrl"]
teleport_version = var.teleport_config_data.teleport_version
claim_to_roles = var.teleport_config_data.claims_to_roles
message_of_the_day = var.teleport_config_data.message_of_the_day
}
##############################################################################
##############################################################################
# Create Bastion Host
##############################################################################
module "bastion_host" {
source = "terraform-ibm-modules/landing-zone-vsi/ibm"
version = "4.2.0"
for_each = local.bastion_vsi_map
resource_group_id = each.value.resource_group == null ? null : local.resource_groups[each.value.resource_group]
create_security_group = each.value.security_group == null ? false : true
prefix = "${var.prefix}-${each.value.name}"
vpc_id = module.vpc[each.value.vpc_name].vpc_id
subnets = each.value.subnets
access_tags = each.value.access_tags
kms_encryption_enabled = true
skip_iam_authorization_policy = true
vsi_per_subnet = 1
boot_volume_encryption_key = each.value.boot_volume_encryption_key_name == null ? "" : [
for keys in module.key_management.keys :
keys.crn if keys.name == each.value.boot_volume_encryption_key_name
][0]
image_id = data.ibm_is_image.image["${var.prefix}-${each.value.name}"].id
user_data = module.teleport_config[0].cloud_init
security_group_ids = each.value.security_groups == null ? [] : [
for group in each.value.security_groups :
ibm_is_security_group.security_group[group].id
]
ssh_key_ids = [
for ssh_key in each.value.ssh_keys :
module.ssh_keys.ssh_key_map[ssh_key].id
]
machine_type = each.value.machine_type
security_group = each.value.security_group
enable_floating_ip = false
depends_on = [module.ssh_keys]
}
##############################################################################