Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit a676d03

Browse files
authored
fix(aws-cloudfront, nextjs-component): specify s3 client's region in aws-cloudfront the same as the bucket region (#2042)
1 parent b2d265c commit a676d03

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

packages/serverless-components/aws-cloudfront/src/component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class CloudFront extends Component {
2323
async default(inputs: any = {}) {
2424
this.context.status("Deploying");
2525

26-
inputs.region = inputs.region || "us-east-1";
26+
inputs.region = inputs.region ?? "us-east-1";
27+
inputs.bucketRegion = inputs.bucketRegion ?? "us-east-1"; // S3 client needs to be specific to the bucket region
2728
inputs.enabled = inputs.enabled !== false;
2829
inputs.comment =
2930
inputs.comment === null || inputs.comment === undefined
@@ -57,7 +58,7 @@ class CloudFront extends Component {
5758

5859
const s3 = new AWS.S3({
5960
credentials: this.context.credentials.aws,
60-
region: inputs.region
61+
region: inputs.bucketRegion
6162
});
6263

6364
this.state.id = inputs.distributionId || this.state.id;

packages/serverless-components/nextjs-component/__tests__/deploy.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ describe.each`
310310

311311
it("creates distribution", () => {
312312
expect(mockCloudFront).toBeCalledWith({
313+
bucketRegion: "us-east-1",
313314
defaults: {
314315
allowedHttpMethods: [
315316
"HEAD",

packages/serverless-components/nextjs-component/src/component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ class NextjsComponent extends Component {
911911
delete defaultLambdaAtEdgeConfig["origin-response"];
912912

913913
const cloudFrontOutputs = await cloudFront({
914+
bucketRegion: bucketRegion,
914915
distributionId: cloudFrontDistributionId,
915916
defaults: {
916917
minTTL: 0,

0 commit comments

Comments
 (0)