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

aws-cloudfront-origins: optional s3:PutObject permission missing in S3BucketOrigin.withOriginAccessControl #31362

Closed
1 task
garysassano opened this issue Sep 8, 2024 · 3 comments
Labels
@aws-cdk/aws-cloudfront-origins Related to CloudFront Origins for the CDK CloudFront Library bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@garysassano
Copy link

Describe the bug

According to the AWS docs, it's possible to grant both read and write access when using CloudFront OAC with an S3 bucket origin. However, the S3BucketOrigin.withOriginAccessControl L2 construct currently defaults to read-only access, and there is no built-in option to add write permissions.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

See above.

Current Behavior

See above.

Reproduction Steps

See above.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.156.0

Framework Version

No response

Node.js Version

20.17.0

OS

Ubuntu 22.04.3 LTS

Language

TypeScript

Language Version

No response

Other information

No response

@garysassano garysassano added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 8, 2024
@github-actions github-actions bot added the @aws-cdk/aws-cloudfront-origins Related to CloudFront Origins for the CDK CloudFront Library label Sep 8, 2024
@garysassano garysassano changed the title aws-cloudfront-origins: cannot upload files to S3 with S3BucketOrigin.withOriginAccessControl aws-cloudfront-origins: optional s3:PutObject permission missing in S3BucketOrigin.withOriginAccessControl Sep 8, 2024
@vpylypenko2
Copy link

Try to set originAccessLevels to [cloudfront.AccessLevel.READ, cloudfront.AccessLevel.WRITE]

import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
import * as origins from 'aws-cdk-lib/aws-cloudfront-origins';

const accessControl = new cloudfront.S3OriginAccessControl(this, 'AccessControl', {
  originAccessControlName: <name>,
  description: <description>
});

origins.S3BucketOrigin.withOriginAccessControl(
  <bucket>, {
    originAccessControl: accessControl,
    originAccessLevels: [cloudfront.AccessLevel.READ, cloudfront.AccessLevel.WRITE]}
)

@garysassano
Copy link
Author

Thanks, that seems to work in adding the s3:PutObject permission to the S3 bucket policy:

image

Copy link

github-actions bot commented Sep 9, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-cloudfront-origins Related to CloudFront Origins for the CDK CloudFront Library bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants