Skip to content

Instantly share code, notes, and snippets.

@NYARAS
Created January 31, 2023 12:57
Show Gist options
  • Save NYARAS/c3fffe3420ad17862c439345b36f0e81 to your computer and use it in GitHub Desktop.
Save NYARAS/c3fffe3420ad17862c439345b36f0e81 to your computer and use it in GitHub Desktop.
Gitlab OIDC IAM Role
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