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

Commit 72610eb

Browse files
fix credentials and refactor tests
1 parent 3d4810a commit 72610eb

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

packages/serverless-component/__tests__/custom-inputs.test.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ const {
1010
API_LAMBDA_CODE_DIR
1111
} = require("../constants");
1212

13+
const createNextComponent = inputs => {
14+
const component = new NextjsComponent(inputs);
15+
component.context.credentials = {
16+
aws: {
17+
accessKeyId: "123",
18+
secretAccessKey: "456"
19+
}
20+
};
21+
return component;
22+
};
23+
1324
describe("Custom inputs", () => {
1425
let tmpCwd;
1526
let componentOutputs;
@@ -52,7 +63,8 @@ describe("Custom inputs", () => {
5263
domains: [expectedDomain]
5364
});
5465

55-
const component = new NextjsComponent();
66+
const component = createNextComponent();
67+
5668
componentOutputs = await component.default({
5769
policy: "arn:aws:iam::aws:policy/CustomRole",
5870
domain: inputDomains,
@@ -116,7 +128,10 @@ describe("Custom inputs", () => {
116128
url: "https://cloudfrontdistrib.amazonaws.com"
117129
});
118130

119-
const component = new NextjsComponent();
131+
const component = createNextComponent({
132+
memory: inputMemory
133+
});
134+
120135
componentOutputs = await component.default({
121136
memory: inputMemory
122137
});
@@ -164,7 +179,8 @@ describe("Custom inputs", () => {
164179
url: "https://cloudfrontdistrib.amazonaws.com"
165180
});
166181

167-
const component = new NextjsComponent();
182+
const component = createNextComponent();
183+
168184
componentOutputs = await component.default({
169185
timeout: inputTimeout
170186
});
@@ -221,7 +237,8 @@ describe("Custom inputs", () => {
221237
url: "https://cloudfrontdistrib.amazonaws.com"
222238
});
223239

224-
const component = new NextjsComponent();
240+
const component = createNextComponent();
241+
225242
componentOutputs = await component.default({
226243
name: inputName
227244
});
@@ -341,7 +358,8 @@ describe("Custom inputs", () => {
341358
url: "https://cloudfrontdistrib.amazonaws.com"
342359
});
343360

344-
const component = new NextjsComponent();
361+
const component = createNextComponent();
362+
345363
componentOutputs = await component.default({
346364
cloudfront: inputCloudfrontConfig
347365
});

packages/serverless-component/__tests__/deploy.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ describe("deploy tests", () => {
4242
});
4343

4444
const component = new NextjsComponent();
45+
component.context.credentials = {
46+
aws: {
47+
accessKeyId: "123",
48+
secretAccessKey: "456"
49+
}
50+
};
4551

4652
await component.build();
4753

packages/serverless-component/serverless.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class NextjsComponent extends Component {
9797
await uploadAssetsToS3.default({
9898
bucketName: bucketOutputs.name,
9999
nextConfigDir: nextConfigPath,
100-
credentials: this.context.credentials
100+
credentials: this.context.credentials.aws
101101
});
102102

103103
defaultBuildManifest.cloudFrontOrigins = {

0 commit comments

Comments
 (0)