Closed JianhengHou closed 4 months ago
Hey @JianhengHou, happy to help! Did you try running commands in the following order:
npm i
npm run build
npm test
Did all commands before npm test
run successfully? What NodeJs version are you using?
Hi @crupakheti,
Yes, I do run the code in that order.
npm i
returns things below and I think it works fine:
> mwaa-pause-resume@0.1.0 postinstall
> (cd lib/lambda && npm install) && (cd ../../../.. && husky install usecases/start-stop-mwaa-environment/lib/lambda)
up to date, audited 91 packages in 315ms
3 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
install command is deprecated
up to date, audited 702 packages in 1s
164 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm run build
returns the content I posted initially, where the problem starts to show, it seems it fails since this many errors.
And I'm using Node.js v20.14.0
Can you try using Node 18 LTS and report back if you get the same error?
I have the exact same issues as the OP using Node.js v18.20.3. Removing the 4 test files does fix the build issues, but proceeding to run npm test
creates more errors within the infrastructure code...
npm test
> mwaa-pause-resume@0.1.0 test
> jest --coverage --silent
FAIL lib/infrastructure/mwaa-notification-stack.test.ts
● MWAANotificationStack › when a notification email is specified › should create a notification stack with event a bridge rule, a sns topic, and an email subscription
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at Object.<anonymous> (lib/infrastructure/mwaa-notification-stack.test.ts:40:19)
● MWAANotificationStack › when several notification emails are specified › should create a notification stack with event bridge rule, sns topic, and multiple email subscriptions
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at Object.<anonymous> (lib/infrastructure/mwaa-notification-stack.test.ts:93:19)
● MWAANotificationStack › when no notification emails are specified › should not create the notification stack
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at Object.<anonymous> (lib/infrastructure/mwaa-notification-stack.test.ts:150:19)
● MWAANotificationStack › when an invalid email is specified › should not create the notification stack
expect(received).toEqual(expected) // deep equality
Expected: "Invalid email [def@example] supplied in the MWAA_NOTIFICATION_EMAILS environment variable!"
Received: "Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure \"env\" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details."
167 | new MwaaMainStack(app, 'mwaa-main-stack', config);
168 | } catch (error) {
> 169 | expect(error.message).toEqual('Invalid email [def@example] supplied in the MWAA_NOTIFICATION_EMAILS environment variable!');
| ^
170 | }
171 | });
172 | });
at Object.<anonymous> (lib/infrastructure/mwaa-notification-stack.test.ts:169:31)
FAIL lib/infrastructure/mwaa-polling-stack.test.ts
● Test suite failed to run
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at lib/infrastructure/mwaa-polling-stack.test.ts:29:21
at Object.<anonymous> (lib/infrastructure/mwaa-polling-stack.test.ts:25:1)
FAIL lib/infrastructure/mwaa-common-stack.test.ts
● MwaaCommonStack › when MWAA_UPDATE_EXECUTION_ROLE is set to yes › should define a backup bucket, source bucket DAG deployment, dag trigger function, source MWAA role change
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at Object.<anonymous> (lib/infrastructure/mwaa-common-stack.test.ts:36:25)
● MwaaCommonStack › when MWAA_UPDATE_EXECUTION_ROLE is set to no › should define a backup bucket, source bucket DAG deployment, and dag trigger function
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at Object.<anonymous> (lib/infrastructure/mwaa-common-stack.test.ts:81:25)
FAIL lib/infrastructure/mwaa-resuming-stack.test.ts
● MwaaResumingStack › when update after restore is enabled › should define a scheduler, state machine, a new env function, and an update env function
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at Object.<anonymous> (lib/infrastructure/mwaa-resuming-stack.test.ts:39:25)
● MwaaResumingStack › when update after restore is disabled › should define a scheduler, state machine, and a new env function
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at Object.<anonymous> (lib/infrastructure/mwaa-resuming-stack.test.ts:57:25)
PASS lib/lambda/dags-trigger-function.test.ts
FAIL lib/infrastructure/mwaa-pausing-stack.test.ts
● MwaaPausingStack › should define a scheduler and state machine
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at Object.<anonymous> (lib/infrastructure/mwaa-pausing-stack.test.ts:35:23)
FAIL lib/infrastructure/mwaa-main-stack.test.ts
● MwaaMainStack › should compose the common, polling, pausing, and resuming nested stacks
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
80 | lookupVpc(props: MwaaMainStackProps): MwaaVpc {
81 | if (props.vpcId) {
> 82 | const vpc = ec2.Vpc.fromLookup(this, `${props.mainStackName}-external-vpc`, {
| ^
83 | vpcId: props.vpcId,
84 | });
85 |
at Function.getValue (node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
at Function.fromLookup (node_modules/aws-cdk-lib/aws-ec2/lib/vpc.js:1:9305)
at MwaaMainStack.fromLookup [as lookupVpc] (lib/infrastructure/mwaa-main-stack.ts:82:27)
at new lookupVpc (lib/infrastructure/mwaa-main-stack.ts:60:25)
at Object.<anonymous> (lib/infrastructure/mwaa-main-stack.test.ts:33:23)
PASS lib/infrastructure/mwaa-base-stack.test.ts
PASS lib/lambda/mwaa-status-poller-function.test.ts
PASS lib/commons/config.test.ts
-------------------------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------------------------|---------|----------|---------|---------|-------------------
All files | 40 | 42.62 | 24.63 | 39.64 |
commons | 100 | 100 | 100 | 100 |
config.ts | 100 | 100 | 100 | 100 |
prepare-test-environment.ts | 100 | 100 | 100 | 100 |
infrastructure | 28.2 | 16.66 | 8.51 | 28.44 |
mwaa-base-stack.ts | 100 | 100 | 100 | 100 |
mwaa-common-stack.ts | 28.12 | 0 | 0 | 28.12 | 50-145
mwaa-main-stack.ts | 24.48 | 50 | 22.22 | 25.53 | 61-77,86-149
mwaa-notification-stack.ts | 28.57 | 0 | 0 | 28.57 | 40-77
mwaa-pause-resume-base-stack.ts | 42.85 | 100 | 0 | 42.85 | 64-118
mwaa-pausing-stack.ts | 24 | 100 | 0 | 24 | 43-136
mwaa-polling-stack.ts | 32.35 | 100 | 0 | 32.35 | 45-137
mwaa-resuming-stack.ts | 18.86 | 0 | 0 | 18.86 | 48-318
lambda | 34.78 | 26.82 | 30.76 | 32.4 |
dags-cli.ts | 15 | 6.25 | 20 | 10.52 | 32-93
dags-trigger-function.ts | 100 | 100 | 100 | 100 |
mwaa-new-environment-function.ts | 0 | 0 | 0 | 0 | 18-37
mwaa-status-poller-function.ts | 100 | 100 | 100 | 100 |
mwaa-status-poller.ts | 24 | 7.69 | 33.33 | 20.83 | 31-62
...-update-environment-function.ts | 0 | 100 | 0 | 0 | 18-29
-------------------------------------|---------|----------|---------|---------|-------------------
Test Suites: 6 failed, 4 passed, 10 total
Tests: 10 failed, 10 passed, 20 total
Snapshots: 0 total
Time: 15.765 s
Thank you for the bug report @jmflynn81, planning to look into it sometimes next week. Thank you!
Hi @crupakheti we are also facing similar deploying issue due to Node JS version change.
Let us know if you still encounter this issue. The fix was tested using Node 18 and 20.
Hi team,
I strictly followed the instructions - having prerequisite prepared and exporting relevant env variables in shell, but I got this error when I ran
npm build
:Could you please help to direct the right way to troubleshoot the issues above? Thank you!