-
Notifications
You must be signed in to change notification settings - Fork 1
/
kops-external-user.tf
42 lines (35 loc) · 1.12 KB
/
kops-external-user.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
# Workaround for https://github.com/terraform-providers/terraform-provider-aws/issues/8242
locals {
kops_policies = [
"arn:aws:iam::aws:policy/AmazonRoute53FullAccess",
"arn:aws:iam::aws:policy/AmazonEC2FullAccess",
"arn:aws:iam::aws:policy/AmazonVPCFullAccess",
"arn:aws:iam::aws:policy/AmazonS3FullAccess",
"arn:aws:iam::aws:policy/IAMFullAccess",
]
}
resource "aws_iam_user" "kops" {
count = var.external_account ? 1 : 0
name = module.kops_label.id
tags = module.kops_label.tags
path = "/system/"
}
resource "aws_iam_user_policy_attachment" "permissions" {
count = var.external_account ? length(local.kops_policies) : 0
user = join("", aws_iam_user.kops.*.name)
policy_arn = local.kops_policies[count.index]
}
resource "aws_iam_access_key" "kops" {
count = var.external_account ? 1 : 0
user = join("", aws_iam_user.kops.*.name)
}
# Wait for IAM to propagate new user
resource "null_resource" "wait_for_iam" {
count = var.external_account ? 1 : 0
provisioner "local-exec" {
command = "sleep 30"
}
triggers = {
user = join("", aws_iam_access_key.kops.*.id)
}
}