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

(cloudfront): (passing a ARN does not respect region) #29915

Closed
darylteo opened this issue Apr 21, 2024 · 3 comments
Closed

(cloudfront): (passing a ARN does not respect region) #29915

darylteo opened this issue Apr 21, 2024 · 3 comments
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront bug This issue is a bug. p2

Comments

@darylteo
Copy link

darylteo commented Apr 21, 2024

Describe the bug

Related to #9556

Using CloudfrontToS3 Construct. "@aws-solutions-constructs/aws-cloudfront-s3": "^2.54.0",

When creating a CloudFront Distribution, I create them in us-east-1 as they're a global resource. But when accessing the Distribution I get an error.

Expected Behavior

It should point to the correct bucket endpoint.

Current Behavior

<Error>
<script/>
<Code>PermanentRedirect</Code>
<Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message>
<Endpoint>buckets-ap-southeast-2-s3webbucketb6c2279f-ce00aret2azk.s3-ap-southeast-2.amazonaws.com</Endpoint>
<Bucket>buckets-ap-southeast-2-s3webbucketb6c2279f-ce00aret2azk</Bucket>
<RequestId>ZG1DFTQ513BQ3EZE</RequestId>
<HostId>mf0fAffIZD+FKYFoM1W0w1Vy39Rxt/ALQ0MKPaGcg19p9IVJ4tP0AKtRLa0VS7cP8kfIAlEbh8g=</HostId>
</Error>

I have cross-region references turned on, which is why I believe it's created this unknown ARN buckets-ap-southeast-2-s3webbucketb6c2279f-ce00aret2azk, which i wonder might be related.

This issue does not seem to occur if the Distribution is launched in the same region as the bucket.

Reproduction Steps

bin/infra.ts

const buckets = new BucketsStack(app, 'Buckets-ap-southeast-2', {
  env: { region: 'ap-southeast-2', account: 'xxxxxxxx' },
  crossRegionReferences: true,
})

const cdn = new CdnStack(app, 'Cdn-us-east-1', {
  env: { region: 'ap-southeast-2', account: 'xxxxxxxx' },
  crossRegionReferences: true,
}

CdnStack

const webCloudfront = new CloudFrontToS3(this, 'cf-WebDistribution', {
  existingBucketObj: Bucket.fromBucketArn(this, 'cf-WebDistributionBucket', 'arn:aws:s3:::buckets-ap-southeast-2-s3webbucketb6c2279f-tszl6objngxw'),
  insertHttpSecurityHeaders: false,
  cloudFrontDistributionProps: {
    certificate: certificate,
    domainNames: [options.webHostname],
    defaultBehavior: {
      functionAssociations: [{
        function: webRewriteIndexFunction,
        eventType: FunctionEventType.VIEWER_REQUEST,
      }],
    },
  },
});

Possible Solution

Hope this gives you enough information. I'm turning off Cross-Reg

Additional Information/Context

No response

CDK CLI Version

2.138.0

Framework Version

No response

Node.js Version

20.11.1

OS

OS X

Language

TypeScript

Language Version

No response

Other information

No response

@darylteo darylteo added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 21, 2024
@github-actions github-actions bot added the @aws-cdk/aws-cloudfront Related to Amazon CloudFront label Apr 21, 2024
@pahud
Copy link
Contributor

pahud commented Apr 22, 2024

@aws-solutions-constructs is not maintained in this repo. Please create a ticket to https://github.com/awslabs/aws-solutions-constructs/issues instead.

@pahud pahud closed this as completed Apr 22, 2024
@pahud pahud added p2 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 22, 2024
Copy link

⚠️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.

@aws-cdk-automation
Copy link
Collaborator

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.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront bug This issue is a bug. p2
Projects
None yet
Development

No branches or pull requests

3 participants