-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiam_vcs_gateway.tf
More file actions
53 lines (50 loc) · 1.79 KB
/
Copy pathiam_vcs_gateway.tf
File metadata and controls
53 lines (50 loc) · 1.79 KB
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
locals {
vcs_gateway_assume_role_policy = jsonencode({
Version = "2012-10-17"
# We're using concat here even though only one of either ECS or Kubernetes can be enabled because
# Terraform can't handle different branches of a ternary operator returning different types.
Statement = concat(
local.ecs_role_assumption_enabled ? [local.ecs_role_assumption_statement] : [],
local.kubernetes_role_assumption_enabled ? [{
Effect = "Allow"
Principal = {
Federated = "arn:${var.aws_partition}:iam::${var.kubernetes_role_assumption_config.aws_account_id}:oidc-provider/${var.kubernetes_role_assumption_config.oidc_provider}"
}
Action = "sts:AssumeRoleWithWebIdentity"
Condition = {
StringEquals = {
"${var.kubernetes_role_assumption_config.oidc_provider}:aud" = "sts.amazonaws.com"
"${var.kubernetes_role_assumption_config.oidc_provider}:sub" = "system:serviceaccount:${var.kubernetes_role_assumption_config.namespace}:${var.kubernetes_role_assumption_config.vcs_gateway_service_account_name}"
}
}
}] : []
)
})
vcs_gateway_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"xray:PutTraceSegments",
"xray:PutTelemetryRecords",
"xray:GetSamplingRules",
"xray:GetSamplingTargets",
"xray:GetSamplingStatisticSummaries",
"cloudwatch:PutMetricData",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
]
Resource = "*"
},
]
})
vcs_gateway = {
assume_role = local.vcs_gateway_assume_role_policy
policies = {
"VCS_GATEWAY" = local.vcs_gateway_policy
}
attachments = {}
}
}