forked from ExpediaGroup/apiary-lifecycle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s-path-cleanup-iam.tf
46 lines (42 loc) · 1.19 KB
/
k8s-path-cleanup-iam.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
/**
* Copyright (C) 2019-2020 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
resource "aws_iam_role" "beekeeper_k8s_role_path_cleanup_iam" {
count = var.instance_type == "k8s" ? 1 : 0
name = "${local.instance_alias}-path-cleanup-${var.aws_region}"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
},
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "${var.k8s_kiam_role_arn}"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "beekeeper_k8s_path_cleanup_s3" {
count = var.instance_type == "k8s" ? 1 : 0
role = aws_iam_role.beekeeper_k8s_role_path_cleanup_iam[count.index].id
policy_arn = aws_iam_policy.beekeeper_s3.arn
}
resource "aws_iam_role_policy_attachment" "beekeeper_k8s_path_cleanup_secrets" {
count = var.instance_type == "k8s" ? 1 : 0
role = aws_iam_role.beekeeper_k8s_role_path_cleanup_iam[count.index].id
policy_arn = aws_iam_policy.beekeeper_secrets.arn
}