-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathiam-k8s.tf
More file actions
56 lines (44 loc) · 2 KB
/
iam-k8s.tf
File metadata and controls
56 lines (44 loc) · 2 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
resource "aws_iam_role" "waggle_dance_k8s_role_iam" {
count = var.wd_instance_type == "k8s" && var.oidc_provider != "" ? 1 : 0
name = "${local.instance_alias}-k8s-${var.aws_region}"
tags = var.tags
description = "Role to allow AWS Glue access from WaggleDance"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${var.oidc_provider}"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"${var.oidc_provider}:sub": "system:serviceaccount:${var.k8s_namespace}:${local.instance_alias}",
"${var.oidc_provider}:aud": "sts.amazonaws.com"
}
}
}
]
}
EOF
}
resource "aws_iam_role_policy" "waggle_dance_remote_glue_federations_policy" {
count = var.wd_instance_type == "k8s" && var.oidc_provider != "" && local.glue_enabled ? 1 : 0
role = aws_iam_role.waggle_dance_k8s_role_iam[0].name
name = "waggle-dance-remote-metastores-glue-readonly"
policy = data.aws_iam_policy_document.waggle_dance_remote_glue_federations_policy_read[0].json
}
resource "aws_iam_role_policy" "waggle_dance_remote_glue_federations_policy_write" {
count = var.wd_instance_type == "k8s" && var.oidc_provider != "" && local.glue_enabled ? 1 : 0
role = aws_iam_role.waggle_dance_k8s_role_iam[0].name
name = "waggle-dance-remote-metastores-glue-write"
policy = data.aws_iam_policy_document.waggle_dance_remote_glue_federations_policy_write[0].json
}
resource "aws_iam_role_policy" "waggle_dance_remote_glue_federations_policy_s3_write" {
count = var.wd_instance_type == "k8s" && var.oidc_provider != "" && var.s3_glue_tables_bucket != "" && local.glue_enabled ? 1 : 0
role = aws_iam_role.waggle_dance_k8s_role_iam[0].name
name = "waggle-dance-remote-metastores-glue-s3-write"
policy = data.aws_iam_policy_document.waggle_dance_remote_glue_federations_policy_s3_write[0].json
}