-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Elide an unnecessarily separate IAM policy for pubapi.
There's no benefit in having a separate, almost-identical IAM policy for Publishing API to write event logs to S3 when both policies are attached to the node role anyway. If we were to someday split up the roles, assign them to serviceaccounts and use pod identity (almost certainly overkill in this case) then it would make sense to have separate policies. Until then, it's just additional toil and potential for confusion (which itself is not good for security).
- Loading branch information
Showing
2 changed files
with
6 additions
and
30 deletions.
There are no files selected for viewing
30 changes: 0 additions & 30 deletions
30
terraform/deployments/govuk-publishing-infrastructure/publishing_api_s3.tf
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +0,0 @@ | ||
# TODO: merge into policy in reports_s3.tf. | ||
data "aws_iam_policy_document" "publishing_api_s3" { | ||
statement { | ||
actions = ["s3:GetBucketLocation", "s3:ListBucket", ] | ||
# These buckets don't seem to be defined in alphagov/govuk-aws. | ||
resources = ["arn:aws:s3:::govuk-publishing-api-event-log-${var.govuk_environment}"] | ||
} | ||
|
||
statement { | ||
actions = [ | ||
"s3:*MultipartUpload*", | ||
"s3:*Object", | ||
"s3:*ObjectAcl", | ||
"s3:*ObjectVersion", | ||
"s3:GetObject*Attributes" | ||
] | ||
resources = ["arn:aws:s3:::govuk-publishing-api-event-log-${var.govuk_environment}/*"] | ||
} | ||
} | ||
|
||
resource "aws_iam_policy" "publishing_api_s3" { | ||
name = "publishing_api_s3" | ||
description = "Read and write govuk-publishing-api-event-log-${var.govuk_environment} bucket." | ||
policy = data.aws_iam_policy_document.publishing_api_s3.json | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "publishing_api_s3" { | ||
role = data.tfe_outputs.cluster_infrastructure.nonsensitive_values.worker_iam_role_name | ||
policy_arn = aws_iam_policy.publishing_api_s3.arn | ||
} | ||
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