Skip to content

Commit

Permalink
Add current user to canonical perms
Browse files Browse the repository at this point in the history
  • Loading branch information
Vermyndax committed Mar 23, 2021
1 parent 01a5f5f commit 5802e99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ No Modules.

| Name |
|------|
| [aws_canonical_user_id](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) |
| [aws_cloudfront_distribution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution) |
| [aws_route53_record](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) |
| [aws_route53_zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route53_zone) |
Expand Down
9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ resource "aws_s3_bucket" "site_www_redirect" {
}

# S3 bucket for CloudFront logging

data "aws_canonical_user_id" "current" {}

resource "aws_s3_bucket" "site_cloudfront_logs" {
bucket = "${var.site_tld}-cloudfront-logs"
# region = var.site_region
Expand All @@ -88,6 +91,12 @@ resource "aws_s3_bucket" "site_cloudfront_logs" {
type = "CanonicalUser"
permissions = ["FULL_CONTROL"]
}

grant {
id = data.aws_canonical_user_id.current.id
type = "CanonicalUser"
permissions = ["FULL_CONTROL"]
}
}

resource "aws_s3_bucket_public_access_block" "cloudfront_logs_block" {
Expand Down

0 comments on commit 5802e99

Please sign in to comment.