Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Fix S3 permissions to allow CloudFront logging #1208

Merged
merged 2 commits into from
Jan 12, 2021

Conversation

colekettler
Copy link
Contributor

@colekettler colekettler commented Jan 12, 2021

Overview

Creates grants to prevent Terraform removing implicit grants that are usually created by AWS when creating a CloudFront distribution through the console. These grants have recently become necessary for CloudFront to persist access logs to S3.

The AWS canonical user grant replicates the permissions granted by the private canned ACL, and the CloudFront canonical user ID replicates the permissions granted when creating a distribution through the console.

Testing Instructions

  • Disable CloudFront logging for the staging distribution via the AWS console
  • Execute a Terraform plan/apply cycle using the changes on this branch and ensure that logging is reconfigured for the distribution
bash-5.0# GIT_COMMIT="4090799" ./scripts/infra plan
bash-5.0# GIT_COMMIT="4090799" ./scripts/infra apply

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

@colekettler colekettler self-assigned this Jan 12, 2021
bucket = "${aws_s3_bucket.logs.id}.s3.amazonaws.com"
bucket = "${aws_s3_bucket.logs.bucket_domain_name}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two create no diff in the plan, but using bucket_domain_name requires less manual stringiness.

Comment on lines +276 to +278
variable "aws_cloudfront_canonical_user_id" {
default = "c4c1ede66af53448b93c283ce9448c4ba468c9432aa01d700d3878632f77d2d0"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to hardcode this magic ID until hashicorp/terraform-provider-aws#12512 is merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
We should consider opening an issue in the backlog so we have something to remind us to clean this up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked in #1209!

Copy link
Contributor

@hectcastro hectcastro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes working as expected. 👍🏼 Shame, because I thought we had an issue that mirrored the one in other CA projects to confirm that this relationship wasn't severed, but after looking, I wasn't able to find one in the OAR repo.

@colekettler colekettler force-pushed the feature/cek/cloudfront-logging branch from fb61951 to 633d33e Compare January 12, 2021 19:39
@colekettler colekettler merged commit f59a441 into develop Jan 12, 2021
@colekettler colekettler deleted the feature/cek/cloudfront-logging branch January 12, 2021 19:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants