Skip to content
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

Enable logging with private s3 bucket #210

Merged
merged 22 commits into from
Jul 8, 2020

Conversation

alldoami
Copy link
Contributor

@alldoami alldoami commented Jul 3, 2020

Summary

This doc describes that if you remove permissions for the awslogsdelivery account, CloudFront won't be able to save logs to the S3 bucket. Terraform is wiping this out every time we update s3 buckets. We have to explicitly create grants to awslogsdelivery. Inspired by: https://github.com/FB-PLP/terraform-infra-management/pull/386, creating a module for this so that it will be easier to configure.

Test Plan

Updating a module that is referencing this module and seeing if logs show up (since they have disappeared when buckets were updated last). Tests in go.

@alldoami alldoami requested a review from jgadling July 3, 2020 00:30
@alldoami alldoami requested a review from a team as a code owner July 3, 2020 00:30
@@ -1,6 +1,8 @@
locals {
# If grants are defined, we use `grant` to grant permissions, otherwise it will use the `acl` to grant permissions
acl = length(var.grants) == 0 ? "private" : null
acl = length(var.grants) == 0 ? "private" : (
var.log_delivery_write_acl_enable ? "log-delivery-write" : null
Copy link
Contributor

Choose a reason for hiding this comment

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

Think this needs a fix -- the log delivery flag will only work here if we have grants AND log_delivery_write_acl_enable set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

redid, but had to put in a try because hashicorp/terraform#25014

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did find this: hashicorp/terraform#22131 (comment), which is what I had previously.

aws-s3-private-bucket/variables.tf Outdated Show resolved Hide resolved
@jgadling
Copy link
Contributor

jgadling commented Jul 7, 2020

Ok, this looks like a good start to me -- let's test it in the cellxgene dev environment before merging.

variable log_delivery_write_acl_enable {
type = bool
default = false
description = "Enables logging"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a more descriptive description?

# Define the grant ACL for the Cloudfront logging S3 bucket,
# In order for the awslogsdelivery account to write log files to the bucket,
# we need to grant the AWS log delivery group the FULL_CONTROL access to the logging bucket
# LP's AWS account also has the FULL_CONTROL access to the bucket, this is specified by the canonical user id
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is confusing -- please remove the reference to LP

@alldoami alldoami merged commit d87b007 into master Jul 8, 2020
@alldoami alldoami deleted the adoami/acl-condition-log-delivery-write branch July 8, 2020 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants