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

Resolve CF logging bucket errors #23

Merged
merged 2 commits into from
Oct 15, 2024
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
9 changes: 0 additions & 9 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ jobs:
with:
branch: v${{ steps.version.outputs.value }}

# Fail on version collision. Every change to code requires an update to the version number.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removing this check because we should not enforce a 1:1 relationship between PRs and releases.

version-collision:
needs: detect-versions
runs-on: ubuntu-latest
if: needs.detect-versions.outputs.branch-exists == 'true'
steps:
- name: "Error: version collision"
run: exit 1

# Run Ruff against tb_pulumi. Fail on format errors or failed sanity checks.
lint:
needs: detect-changes
Expand Down
5 changes: 2 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'insegel' # Clean black-on-white theme
html_theme = 'insegel' # Clean black-on-white theme
if os.environ.get('TBPULUMI_DARK_MODE', False):
html_theme = 'furo' # Dark theme, easy on the eyes
html_theme = 'furo' # Dark theme, easy on the eyes

# -- Override path to read our docstrings
sys.path.insert(0, os.path.abspath('..'))
24 changes: 16 additions & 8 deletions tb_pulumi/cloudfront.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ def __init__(
self.resources['logging_bucket'] = aws.s3.Bucket(
f'{name}-loggingbucket',
bucket=f'{service_bucket_name}-logs',
grants=[
{
'permissions': ['FULL_CONTROL'],
'type': 'CanonicalUser',
'id': aws.s3.get_canonical_user_id().id,
'uri': '',
}
],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AWS has disabled ACLs on S3 buckets by default. CloudFront needs this grant to work. Grants need ACLs enabled to work. Therefore, describing this grant here creates a circular dependency which cannot be resolved. For this reason, the BucketAclV2 resource is created below.

server_side_encryption_configuration={
'rule': {'applyServerSideEncryptionByDefault': {'sseAlgorithm': 'AES256'}, 'bucket_key_enabled': True}
},
Expand All @@ -100,6 +92,22 @@ def __init__(
opts=pulumi.ResourceOptions(parent=self, depends_on=[self.resources['logging_bucket']]),
)

canonical_user = aws.s3.get_canonical_user_id().id
self.resources['logging_bucket_acl'] = aws.s3.BucketAclV2(
f'{name}-bucketacl',
bucket=self.resources['logging_bucket'].id,
access_control_policy={
'grants': [
{
'grantee': {'type': 'CanonicalUser', 'id': canonical_user},
'permission': 'FULL_CONTROL',
}
],
'owner': {'id': canonical_user},
},
opts=pulumi.ResourceOptions(parent=self, depends_on=[self.resources['logging_bucket_ownership']]),
)

# Create an Origin Access Control to use when CloudFront talks to S3
self.resources['oac'] = aws.cloudfront.OriginAccessControl(
f'{name}-oac',
Expand Down
Loading