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-s3): urlForObject() returns invalid URL if bucket is not in same region as stack #14149

Closed
peterwoodworth opened this issue Apr 13, 2021 · 2 comments · Fixed by #14315
Closed
Assignees
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@peterwoodworth
Copy link
Contributor

The code for urlForObject() here builds the URL by using the region of the stack rather than the bucket. This causes the function to return an incorrect URL if an existing bucket is imported from another region using fromBucketXXX() function

Workarounds

You can currently get around this by copying the bucket objects to a bucket in the same region as the stack that is being deployed
OR use "low level overriding" to change the low level AWS::CloudFormation::Init section

Potential solution

Construct the URL using data from bucketRegionalDomainName prop


This is 🐛 Bug Report

@peterwoodworth peterwoodworth added the bug This issue is a bug. label Apr 13, 2021
@peterwoodworth peterwoodworth self-assigned this Apr 13, 2021
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Apr 13, 2021
@iliapolo
Copy link
Contributor

Just adding this for future implementors - since imported buckets can have explicit regions set, we might be able to properly construct the URL even if bucketRegionalDomainName is not set.

@iliapolo iliapolo added effort/small Small work item – less than a day of effort p2 labels Apr 15, 2021
cjihrig added a commit to cjihrig/aws-cdk that referenced this issue Apr 22, 2021
This commit updates urlForObject() to use the bucket's region
instead of the stack's region when constructing the returned
URL.

Refs: aws#14149
@mergify mergify bot closed this as completed in #14315 May 3, 2021
mergify bot pushed a commit that referenced this issue May 3, 2021
This commit updates `urlForObject()` to use the bucket's region instead of the stack's region when constructing the returned URL.

Fixes #14149

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented May 3, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

john-tipper pushed a commit to john-tipper/aws-cdk that referenced this issue May 10, 2021
…4315)

This commit updates `urlForObject()` to use the bucket's region instead of the stack's region when constructing the returned URL.

Fixes aws#14149

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
…4315)

This commit updates `urlForObject()` to use the bucket's region instead of the stack's region when constructing the returned URL.

Fixes aws#14149

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants