Skip to content

Commit

Permalink
TEST SETUP
Browse files Browse the repository at this point in the history
  • Loading branch information
Adityarana1986 committed Apr 25, 2024
1 parent 869b6a8 commit 450021b
Show file tree
Hide file tree
Showing 51 changed files with 156 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ jobs:
name: Install and run e2e tests
working_directory: ~/project/packages/e2e-tests/<< parameters.app >>
environment:
AWS_DEFAULT_REGION: us-east-1
AWS_DEFAULT_REGION: us-west-2
WAIT_TIMEOUT: 900
SERVERLESS_CI: true
command: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_AT }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ST }}
AWS_DEFAULT_REGION: us-east-1
AWS_DEFAULT_REGION: us-west-2
GITHUB_SHA: ${{ github.sha }}
run: yarn handlers:upload-handler-sizes
#
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cleanup-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_AT }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ST }}
AWS_DEFAULT_REGION: us-east-1
AWS_DEFAULT_REGION: us-west-2
run: |
cd packages/e2e-tests/test-utils
yarn --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_AT }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ST }}
AWS_DEFAULT_REGION: us-east-1
AWS_DEFAULT_REGION: us-west-2
WAIT_TIMEOUT: 900
CYPRESS_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed for testing external rewrites to GitHub API without getting throttled
NODE_OPTIONS: "--max-old-space-size=4096"
Expand Down
2 changes: 1 addition & 1 deletion packages/ci-api/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider:
name: aws
runtime: nodejs14.x
stage: prod
region: us-east-1
region: us-west-2

package:
individually: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe("addCustomStackResources", () => {

expect(apiGatewayOrigin.OriginPath).toEqual("/test");
expect(apiGatewayOrigin.DomainName["Fn::Join"][1][1]).toEqual(
".execute-api.us-east-1.amazonaws.com"
".execute-api.us-west-2.amazonaws.com"
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const addCustomStackResources = async function () {

// see https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html
const bucketBaseUrl =
region === "us-east-1"
region === "us-west-2"
? "https://s3.amazonaws.com"
: `https://s3-${region}.amazonaws.com`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ServerlessPluginBuilder {
getProvider: () => {
return {
request: () => {},
getRegion: () => "us-east-1",
getRegion: () => "us-west-2",
getStage: () => "test"
};
},
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/test-utils/scripts/cleanup-lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async function cleanupVersions(
}

console.info("Cleaning up old Lambda versions");
cleanupVersions("us-east-1", true) // All Lambda@Edge is created in us-east-1 only
cleanupVersions("us-west-2", true) // All Lambda@Edge is created in us-west-2 only
.then((success) => {
console.info(
`Cleaning up old Lambda versions successful. Count: ${success}`
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/lambda-at-edge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Features

- **lambda-at-edge:** use S3 regional endpoint when not in us-east-1 ([#474](https://github.com/serverless-nextjs/serverless-next.js/issues/474)) ([5ecff1a](https://github.com/serverless-nextjs/serverless-next.js/commit/5ecff1a50e26c22f7de9ec9da3cf2cba4390d77d))
- **lambda-at-edge:** use S3 regional endpoint when not in us-west-2 ([#474](https://github.com/serverless-nextjs/serverless-next.js/issues/474)) ([5ecff1a](https://github.com/serverless-nextjs/serverless-next.js/commit/5ecff1a50e26c22f7de9ec9da3cf2cba4390d77d))

## [1.4.1-alpha.5](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2020-06-30)

Expand Down
2 changes: 1 addition & 1 deletion packages/libs/lambda-at-edge/src/default-handler-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const handler = async (
const request = event.Records[0].cf.request;
const bucketName = s3BucketNameFromEventRequest(request) ?? "";
const { region: bucketRegion } = request.origin?.s3 || {
region: "us-east-1" // default to us-east-1 though it should always be present
region: "us-west-2" // default to us-west-2 though it should always be present
};
const regenerationQueueRegion = bucketRegion;
const regenerationQueueName =
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/lambda-at-edge/src/default-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const addS3HostHeader = (
};

const normaliseS3OriginDomain = (s3Origin: CloudFrontS3Origin): string => {
if (s3Origin.region === "us-east-1") {
if (s3Origin.region === "us-west-2") {
return s3Origin.domainName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("Lambda@Edge", () => {
authMethod: "origin-access-identity",
domainName: "my-bucket.s3.amazonaws.com",
path: "/basepath/static-pages/build-id",
region: "us-east-1"
region: "us-west-2"
}
});
expect(request.uri).toEqual(expectedPage);
Expand Down Expand Up @@ -126,7 +126,7 @@ describe("Lambda@Edge", () => {
authMethod: "origin-access-identity",
domainName: "my-bucket.s3.amazonaws.com",
path: "/basepath/public",
region: "us-east-1"
region: "us-west-2"
}
});
expect(request.uri).toEqual("/manifest.json");
Expand Down Expand Up @@ -234,19 +234,19 @@ describe("Lambda@Edge", () => {
authMethod: "origin-access-identity",
domainName: "my-bucket.s3.amazonaws.com",
path: "/basepath",
region: "us-east-1"
region: "us-west-2"
}
});
expect(request.uri).toEqual(expectedUri);
}
);
});

it("uses default s3 endpoint when bucket region is us-east-1", async () => {
it("uses default s3 endpoint when bucket region is us-west-2", async () => {
const event = createCloudFrontEvent({
uri: "/basepath/terms",
host: "mydistribution.cloudfront.net",
s3Region: "us-east-1"
s3Region: "us-west-2"
});

const result = await handler(event);
Expand All @@ -263,7 +263,7 @@ describe("Lambda@Edge", () => {
expect(request.headers.host[0].value).toEqual("my-bucket.s3.amazonaws.com");
});

it("uses regional endpoint for static page when bucket region is not us-east-1", async () => {
it("uses regional endpoint for static page when bucket region is not us-west-2", async () => {
const event = createCloudFrontEvent({
uri: "/basepath/terms",
host: "mydistribution.cloudfront.net",
Expand Down Expand Up @@ -291,7 +291,7 @@ describe("Lambda@Edge", () => {
);
});

it("uses regional endpoint for public asset when bucket region is not us-east-1", async () => {
it("uses regional endpoint for public asset when bucket region is not us-west-2", async () => {
const event = createCloudFrontEvent({
uri: "/basepath/favicon.ico",
host: "mydistribution.cloudfront.net",
Expand Down Expand Up @@ -356,7 +356,7 @@ describe("Lambda@Edge", () => {
authMethod: "origin-access-identity",
domainName: "my-bucket.s3.amazonaws.com",
path: "/basepath/static-pages/build-id",
region: "us-east-1"
region: "us-west-2"
}
});
expect(request.uri).toEqual("/404.html");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe("Lambda@Edge", () => {
authMethod: "origin-access-identity",
domainName: "my-bucket.s3.amazonaws.com",
path: "/static-pages/build-id",
region: "us-east-1"
region: "us-west-2"
}
});
expect(request.uri).toEqual(expectedPage);
Expand Down Expand Up @@ -155,7 +155,7 @@ describe("Lambda@Edge", () => {
authMethod: "origin-access-identity",
domainName: "my-bucket.s3.amazonaws.com",
path: "/public",
region: "us-east-1"
region: "us-west-2"
}
});
expect(request.uri).toEqual(path);
Expand Down Expand Up @@ -271,7 +271,7 @@ describe("Lambda@Edge", () => {
authMethod: "origin-access-identity",
domainName: "my-bucket.s3.amazonaws.com",
path: "",
region: "us-east-1"
region: "us-west-2"
}
});
expect(request.uri).toEqual(expectedUri);
Expand Down Expand Up @@ -426,11 +426,11 @@ describe("Lambda@Edge", () => {
});
});

it("uses default s3 endpoint when bucket region is us-east-1", async () => {
it("uses default s3 endpoint when bucket region is us-west-2", async () => {
const event = createCloudFrontEvent({
uri: "/terms",
host: "mydistribution.cloudfront.net",
s3Region: "us-east-1"
s3Region: "us-west-2"
});

const result = await handler(event);
Expand All @@ -447,7 +447,7 @@ describe("Lambda@Edge", () => {
expect(request.headers.host[0].value).toEqual("my-bucket.s3.amazonaws.com");
});

it("uses regional endpoint for static page when bucket region is not us-east-1", async () => {
it("uses regional endpoint for static page when bucket region is not us-west-2", async () => {
const event = createCloudFrontEvent({
uri: "/terms",
host: "mydistribution.cloudfront.net",
Expand Down Expand Up @@ -475,7 +475,7 @@ describe("Lambda@Edge", () => {
);
});

it("uses regional endpoint for public asset when bucket region is not us-east-1", async () => {
it("uses regional endpoint for public asset when bucket region is not us-west-2", async () => {
const event = createCloudFrontEvent({
uri: "/favicon.ico",
host: "mydistribution.cloudfront.net",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("Regeneration Handler", () => {
basePath: undefined,
bucketName: "my-bucket",
cloudFrontEventRequest: event.Records[0].cf.request,
region: "us-east-1",
region: "us-west-2",
pageS3Path: `static-pages/build-id${locale}/preview.js`,
pagePath: "pages/preview.js"
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe("Regeneration Handler", () => {
basePath,
bucketName: "my-bucket",
cloudFrontEventRequest: event.Records[0].cf.request,
region: "us-east-1",
region: "us-west-2",
pageS3Path: `static-pages/build-id/preview.js`,
pagePath: "pages/preview.js"
})
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/lambda-at-edge/tests/s3/s3StorePage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("S3StorePage Tests", () => {
bucketName: "test",
html: "test",
buildId: "test-build-id",
region: "us-east-1",
region: "us-west-2",
pageData: {}
});

Expand Down
2 changes: 1 addition & 1 deletion packages/libs/lambda-at-edge/tests/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const createCloudFrontEvent = ({
origin: {
s3: {
path: "",
region: s3Region || "us-east-1",
region: s3Region || "us-west-2",
authMethod: "origin-access-identity",
domainName: s3DomainName || "my-bucket.s3.amazonaws.com"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe("triggerStaticRegeneration()", () => {
uri: "index.html",
origin: {
s3: {
region: "us-east-1",
domainName: `my-bucket.s3.us-east-1.amazonaws.com`
region: "us-west-2",
domainName: `my-bucket.s3.us-west-2.amazonaws.com`
}
}
} as AWSLambda.CloudFrontRequest,
Expand Down Expand Up @@ -104,9 +104,9 @@ describe("triggerStaticRegeneration()", () => {
});
expect(staticRegeneratedResponse.throttle).toBe(false);
expect(mockSendMessageCommand).toHaveBeenCalledWith({
QueueUrl: `https://sqs.us-east-1.amazonaws.com/my-bucket.fifo`,
QueueUrl: `https://sqs.us-west-2.amazonaws.com/my-bucket.fifo`,
MessageBody: JSON.stringify({
region: "us-east-1",
region: "us-west-2",
bucketName: "my-bucket",
pageS3Path: "/static-pages/build-id/index.html",
cloudFrontEventRequest: options.request,
Expand Down
6 changes: 3 additions & 3 deletions packages/libs/lambda/src/deploy/cdktf/nextJsLambdaApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { CoreBuildOptions } from "@sls-next/core";
import { LambdaBuildOptions } from "src/types";

const DEFAULT_OUTPUT_DIR = ".serverless_nextjs";
const DEFAULT_AWS_REGION = "us-east-1";
const DEFAULT_AWS_REGION = "us-west-2";

export type NextJsLambdaAppProps = {
/**
Expand All @@ -26,7 +26,7 @@ export type NextJsLambdaAppProps = {
appName: string;
/**
* The AWS region to provision the Next.js app infrastructure.
* If omitted, it will default to us-east-1.
* If omitted, it will default to us-west-2.
*/
region?: string;
coreBuildOptions?: CoreBuildOptions;
Expand Down Expand Up @@ -141,7 +141,7 @@ export class NextJsLambdaApp extends Construct {
type: "zip"
});

// Create infrastructure all within the same region, or us-east-1 if not specified
// Create infrastructure all within the same region, or us-west-2 if not specified
new AwsProvider(this, "AWS", {
region: this.props.region ?? DEFAULT_AWS_REGION
});
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/lambda/tests/build/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("Builder Tests", () => {

const lambdaBuildOptions: LambdaBuildOptions = {
bucketName: "test-bucket",
bucketRegion: "us-east-1"
bucketRegion: "us-west-2"
};

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jest.mock("aws-sdk", () => require("./aws-sdk.mock"));
const deleteOldAssets = (basePath?: string): Promise<void> => {
return deleteOldStaticAssets({
bucketName: "test-bucket-name",
bucketRegion: "us-east-1",
bucketRegion: "us-west-2",
basePath: basePath || "",
credentials: {
accessKeyId: "fake-access-key",
Expand Down Expand Up @@ -114,11 +114,11 @@ describe.each`

expect(AWS.S3).toBeCalledWith({
accessKeyId: "fake-access-key",
endpoint: "https://s3.us-east-1.amazonaws.com",
endpoint: "https://s3.us-west-2.amazonaws.com",
s3BucketEndpoint: false,
secretAccessKey: "fake-secret-key",
sessionToken: "fake-session-token",
region: "us-east-1"
region: "us-west-2"
});

expect(mockDeleteObjects).toBeCalledTimes(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const upload = (

return uploadStaticAssetsFromBuild({
bucketName: "test-bucket-name",
bucketRegion: "us-east-1",
bucketRegion: "us-west-2",
basePath: basePath || "",
nextConfigDir: path.join(__dirname, nextConfigDir),
nextStaticDir: staticDir,
Expand Down Expand Up @@ -63,8 +63,8 @@ describe("Upload tests from build", () => {
await upload("./fixtures/app-basic-upload-from-build");

expect(AWS.S3).toBeCalledWith({
region: "us-east-1",
endpoint: "https://s3.us-east-1.amazonaws.com",
region: "us-west-2",
endpoint: "https://s3.us-west-2.amazonaws.com",
s3BucketEndpoint: false,
accessKeyId: "fake-access-key",
secretAccessKey: "fake-secret-key",
Expand All @@ -81,8 +81,8 @@ describe("Upload tests from build", () => {

expect(AWS.S3).toBeCalledTimes(2);
expect(AWS.S3).toBeCalledWith({
region: "us-east-1",
endpoint: "https://s3.us-east-1.amazonaws.com",
region: "us-west-2",
endpoint: "https://s3.us-west-2.amazonaws.com",
s3BucketEndpoint: false,
accessKeyId: "fake-access-key",
secretAccessKey: "fake-secret-key",
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless-components/aws-cloudfront/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Bug Fixes

- **serverless-component:** fixes 307 errors when using bucket region outside us-east-1 ([#495](https://github.com/serverless-nextjs/serverless-next.js/issues/495)) ([561e05f](https://github.com/serverless-nextjs/serverless-next.js/commit/561e05f9ba9763fab4185b34adcde61dfcbb0a21))
- **serverless-component:** fixes 307 errors when using bucket region outside us-west-2 ([#495](https://github.com/serverless-nextjs/serverless-next.js/issues/495)) ([561e05f](https://github.com/serverless-nextjs/serverless-next.js/commit/561e05f9ba9763fab4185b34adcde61dfcbb0a21))

## [1.0.1](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2020-07-11)

Expand Down
Loading

0 comments on commit 450021b

Please sign in to comment.