Created
January 31, 2023 12:57
-
-
Save NYARAS/c3fffe3420ad17862c439345b36f0e81 to your computer and use it in GitHub Desktop.
Gitlab OIDC IAM Role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_iam_role" "gitlab_ci" { | |
name = var.role_name | |
assume_role_policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Federated": "${aws_iam_openid_connect_provider.gitlab.arn}" | |
}, | |
"Action": "sts:AssumeRoleWithWebIdentity", | |
"Condition": { | |
"StringEquals": { | |
"gitlab.com:sub": "project_path:${var.gitlab_group}/${var.gitlab_subgroup}/${var.gitlab_project}:ref_type:branch:ref:${var.gitlab_branch}" | |
} | |
} | |
} | |
] | |
} | |
EOF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment