-
Notifications
You must be signed in to change notification settings - Fork 43
/
ssm.tf
95 lines (76 loc) · 2.31 KB
/
ssm.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
resource "aws_kms_key" "kong" {
description = format("%s-%s", var.service, var.environment)
tags = merge(
{
"Name" = format("%s-%s", var.service, var.environment),
"Environment" = var.environment,
"Description" = var.description,
"Service" = var.service,
},
var.tags
)
}
resource "aws_kms_alias" "kong" {
name = format("alias/%s-%s", var.service, var.environment)
target_key_id = aws_kms_key.kong.key_id
}
resource "aws_ssm_parameter" "ee-license" {
name = format("/%s/%s/ee/license", var.service, var.environment)
type = "SecureString"
value = var.ee_license
key_id = aws_kms_alias.kong.target_key_arn
lifecycle {
ignore_changes = [value]
}
}
resource "aws_ssm_parameter" "ee-admin-token" {
name = format("/%s/%s/ee/admin/token", var.service, var.environment)
type = "SecureString"
value = random_string.admin_token.result
key_id = aws_kms_alias.kong.target_key_arn
lifecycle {
ignore_changes = [value]
}
}
resource "aws_ssm_parameter" "db-host" {
name = format("/%s/%s/db/host", var.service, var.environment)
type = "String"
value = coalesce(
join("", aws_db_instance.kong.*.address),
join("", aws_rds_cluster.kong.*.endpoint),
"none"
)
}
resource "aws_ssm_parameter" "db-name" {
name = format("/%s/%s/db/name", var.service, var.environment)
type = "String"
value = replace(format("%s_%s", var.service, var.environment), "-", "_")
}
resource "aws_ssm_parameter" "db-password" {
name = format("/%s/%s/db/password", var.service, var.environment)
type = "SecureString"
value = random_string.db_password.result
key_id = aws_kms_alias.kong.target_key_arn
lifecycle {
ignore_changes = [value]
}
overwrite = true
}
resource "aws_ssm_parameter" "db-master-password" {
name = format("/%s/%s/db/password/master", var.service, var.environment)
type = "SecureString"
value = random_string.master_password.result
key_id = aws_kms_alias.kong.target_key_arn
lifecycle {
ignore_changes = [value]
}
overwrite = true
}
resource "aws_ssm_parameter" "redis-primary-endpoint" {
name = format("/%s/%s/redis/primary-endpoint", var.service, var.environment)
type = "String"
value = coalesce(
join("", aws_elasticache_replication_group.kong.*.primary_endpoint_address),
"none"
)
}