Skip to content

fix: use a valid policy for ssm access #1124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,38 @@ resource "aws_eip" "gitlab_runner" {
################################################################################
### AWS Systems Manager access to store runner token once registered
################################################################################
data "aws_iam_policy_document" "ssm" {
statement {
actions = [
"ssm:GetParameter",
"ssm:GetParameters",
]
resources = [
for name in compact(
[
aws_ssm_parameter.runner_sentry_dsn.name,
var.runner_gitlab_registration_token_secure_parameter_store_name,
var.runner_gitlab.access_token_secure_parameter_store_name,
var.runner_gitlab.preregistered_runner_token_ssm_parameter_name,
aws_ssm_parameter.runner_registration_token.name
]
) : "arn:${data.aws_partition.current.partition}:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/${name}"
]
}

statement {
actions = ["ssm:PutParameter"]
resources = [
"arn:${data.aws_partition.current.partition}:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/${aws_ssm_parameter.runner_registration_token.name}"
]
}
}

resource "aws_iam_policy" "ssm" {
name = "${local.name_iam_objects}-ssm"
path = "/"
description = "Policy for runner token param access via SSM"
policy = templatefile("${path.module}/policies/instance-secure-parameter-role-policy.json", { partition = data.aws_partition.current.partition })
policy = data.aws_iam_policy_document.ssm.json

tags = local.tags
}
Expand Down
20 changes: 0 additions & 20 deletions policies/instance-secure-parameter-role-policy.json

This file was deleted.