-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathaws-roles.tf
57 lines (49 loc) · 1.08 KB
/
aws-roles.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
resource "mongodbatlas_cloud_provider_access" "test" {
project_id = var.project_id
provider_name = "AWS"
iam_assumed_role_arn = var.aws_iam_role_arn
}
resource "aws_iam_role_policy" "test_policy" {
name = "test_policy"
role = aws_iam_role.test_role.id
policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}
EOF
}
resource "aws_iam_role" "test_role" {
name = "test_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "${mongodbatlas_cloud_provider_access.test.atlas_aws_account_arn}"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "${mongodbatlas_cloud_provider_access.test.atlas_assumed_role_external_id}"
}
}
}
]
}
EOF
}
output "aws_iam_role_arn" {
value = aws_iam_role.test_role.arn
}
output "cpa_role_id" {
value = mongodbatlas_cloud_provider_access.test.role_id
}