-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
32 lines (26 loc) · 832 Bytes
/
main.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
data "aws_iam_policy_document" "bitbucket_assume_role_policy" {
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
principals {
identifiers = [var.bitbucket_openid_connect_provider_arn]
type = "Federated"
}
condition {
test = "StringLike"
variable = "api.bitbucket.org/2.0/workspaces/${var.bitbucket_workspace_name}/pipelines-config/identity/oidc:sub"
values = var.allowed_subjects
}
}
}
resource "aws_iam_role" "this" {
name = var.role_name
assume_role_policy = data.aws_iam_policy_document.bitbucket_assume_role_policy.json
tags = {
Name = var.role_name
}
}
resource "aws_iam_role_policy_attachment" "this" {
count = length(var.policy_arns)
role = aws_iam_role.this.name
policy_arn = var.policy_arns[count.index]
}