aws-samples / amazon-mwaa-examples

Amazon Managed Workflows for Apache Airflow (MWAA) Examples repository contains example DAGs, requirements.txt, plugins, and CloudFormation templates focused on Amazon MWAA.
MIT No Attribution
106 stars 61 forks source link

start-stop-mwaa-environment - npm build error #77

Closed JianhengHou closed 4 months ago

JianhengHou commented 5 months ago

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:

lib/lambda/dags-cli.test.ts:49:7 - error TS2322: Type 'AwsStub<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>' is not assignable to type 'never'.

49       mwaaMock = mockClient(MWAAClient);
         ~~~~~~~~

lib/lambda/dags-cli.test.ts:49:29 - error TS2345: Argument of type 'typeof MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.
  Type 'typeof MWAAClient' is not assignable to type 'ClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.
    The types of 'prototype.middlewareStack.concat' are incompatible between these types.
      Type '<InputType extends ServiceInputTypes, OutputType extends ServiceOutputTypes>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>' is not assignable to type '<InputType extends ServiceInputTypes, OutputType extends MetadataBearer>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<InputType, OutputType>'.
        Types of parameters 'from' and 'from' are incompatible.
          Type 'MiddlewareStack<InputType, OutputType>' is not assignable to type 'MiddlewareStack<InputType, ServiceOutputTypes>'.
            Types of property 'addRelativeTo' are incompatible.
              Type '(middleware: MiddlewareType<InputType, OutputType>, options: RelativeMiddlewareOptions) => void' is not assignable to type '(middleware: MiddlewareType<InputType, ServiceOutputTypes>, options: RelativeMiddlewareOptions) => void'.
                Types of parameters 'middleware' and 'middleware' are incompatible.
                  Type 'MiddlewareType<InputType, ServiceOutputTypes>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                    Type 'InitializeMiddleware<InputType, ServiceOutputTypes>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                      Type 'InitializeMiddleware<InputType, ServiceOutputTypes>' is not assignable to type 'InitializeMiddleware<InputType, OutputType>'.
                        Call signature return types 'InitializeHandler<InputType, ServiceOutputTypes>' and 'InitializeHandler<InputType, OutputType>' are incompatible.
                          Type 'Promise<InitializeHandlerOutput<ServiceOutputTypes>>' is not assignable to type 'Promise<InitializeHandlerOutput<OutputType>>'.
                            Type 'InitializeHandlerOutput<ServiceOutputTypes>' is not assignable to type 'InitializeHandlerOutput<OutputType>'.
                              Types of property 'output' are incompatible.
                                Type 'ServiceOutputTypes' is not assignable to type 'OutputType'.
                                  'ServiceOutputTypes' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'MetadataBearer'.
                                    Type 'CreateCliTokenCommandOutput' is not assignable to type 'OutputType'.
                                      'CreateCliTokenCommandOutput' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'MetadataBearer'.

49       mwaaMock = mockClient(MWAAClient);
                               ~~~~~~~~~~

lib/lambda/dags-cli.test.ts:50:16 - error TS2339: Property 'on' does not exist on type 'never'.

50       mwaaMock.on(CreateCliTokenCommand).resolves(token);
                  ~~

lib/lambda/dags-cli.test.ts:54:16 - error TS2339: Property 'restore' does not exist on type 'never'.

54       mwaaMock.restore();
                  ~~~~~~~

lib/lambda/dags-cli.test.ts:75:48 - error TS2345: Argument of type 'typeof CreateCliTokenCommand' is not assignable to parameter of type 'new (input: CreateCliTokenCommandInput) => AwsCommand<CreateCliTokenCommandInput, MetadataBearer>'.
  Construct signature return types 'CreateCliTokenCommand' and 'AwsCommand<CreateCliTokenCommandInput, MetadataBearer>' are incompatible.
    The types of 'middlewareStack.concat' are incompatible between these types.
      Type '<InputType extends CreateCliTokenCommandInput, OutputType extends CreateCliTokenCommandOutput>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>' is not assignable to type '<InputType extends CreateCliTokenCommandInput, OutputType extends MetadataBearer>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>'.
        Types of parameters 'from' and 'from' are incompatible.
          Type 'MiddlewareStack<InputType, OutputType>' is not assignable to type 'MiddlewareStack<InputType, CreateCliTokenCommandOutput>'.
            Types of property 'addRelativeTo' are incompatible.
              Type '(middleware: MiddlewareType<InputType, OutputType>, options: RelativeMiddlewareOptions) => void' is not assignable to type '(middleware: MiddlewareType<InputType, CreateCliTokenCommandOutput>, options: RelativeMiddlewareOptions) => void'.
                Types of parameters 'middleware' and 'middleware' are incompatible.
                  Type 'MiddlewareType<InputType, CreateCliTokenCommandOutput>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                    Type 'InitializeMiddleware<InputType, CreateCliTokenCommandOutput>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                      Type 'InitializeMiddleware<InputType, CreateCliTokenCommandOutput>' is not assignable to type 'InitializeMiddleware<InputType, OutputType>'.
                        Call signature return types 'InitializeHandler<InputType, CreateCliTokenCommandOutput>' and 'InitializeHandler<InputType, OutputType>' are incompatible.
                          Type 'Promise<InitializeHandlerOutput<CreateCliTokenCommandOutput>>' is not assignable to type 'Promise<InitializeHandlerOutput<OutputType>>'.
                            Type 'InitializeHandlerOutput<CreateCliTokenCommandOutput>' is not assignable to type 'InitializeHandlerOutput<OutputType>'.
                              Types of property 'output' are incompatible.
                                Type 'CreateCliTokenCommandOutput' is not assignable to type 'OutputType'.
                                  'CreateCliTokenCommandOutput' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'MetadataBearer'.

75         expect(mwaaMock).toHaveReceivedCommand(CreateCliTokenCommand);
                                                  ~~~~~~~~~~~~~~~~~~~~~

lib/lambda/dags-cli.test.ts:85:53 - error TS2345: Argument of type 'typeof CreateCliTokenCommand' is not assignable to parameter of type 'new (input: CreateCliTokenCommandInput) => AwsCommand<CreateCliTokenCommandInput, MetadataBearer>'.
  Type 'CreateCliTokenCommand' is not assignable to type 'AwsCommand<CreateCliTokenCommandInput, MetadataBearer>'.

85         expect(mwaaMock).toHaveReceivedCommandTimes(CreateCliTokenCommand, 1);
                                                       ~~~~~~~~~~~~~~~~~~~~~

lib/lambda/mwaa-new-environment-function.test.ts:27:5 - error TS2322: Type 'AwsStub<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>' is not assignable to type 'never'.

27     mwaaMock = mockClient(MWAAClient);
       ~~~~~~~~

lib/lambda/mwaa-new-environment-function.test.ts:27:27 - error TS2345: Argument of type 'typeof MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

27     mwaaMock = mockClient(MWAAClient);
                             ~~~~~~~~~~

lib/lambda/mwaa-new-environment-function.test.ts:31:14 - error TS2339: Property 'restore' does not exist on type 'never'.

31     mwaaMock.restore();
                ~~~~~~~

lib/lambda/mwaa-new-environment-function.test.ts:35:14 - error TS2339: Property 'on' does not exist on type 'never'.

35     mwaaMock.on(CreateEnvironmentCommand).resolves({ Arn: 'my-env-arn' });
                ~~

lib/lambda/mwaa-new-environment-function.test.ts:48:44 - error TS2345: Argument of type 'typeof CreateEnvironmentCommand' is not assignable to parameter of type 'new (input: CreateEnvironmentCommandInput) => AwsCommand<CreateEnvironmentCommandInput, MetadataBearer>'.
  Construct signature return types 'CreateEnvironmentCommand' and 'AwsCommand<CreateEnvironmentCommandInput, MetadataBearer>' are incompatible.
    The types of 'middlewareStack.concat' are incompatible between these types.
      Type '<InputType extends CreateEnvironmentCommandInput, OutputType extends CreateEnvironmentCommandOutput>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>' is not assignable to type '<InputType extends CreateEnvironmentCommandInput, OutputType extends MetadataBearer>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>'.
        Types of parameters 'from' and 'from' are incompatible.
          Type 'MiddlewareStack<InputType, OutputType>' is not assignable to type 'MiddlewareStack<InputType, CreateEnvironmentCommandOutput>'.
            Types of property 'addRelativeTo' are incompatible.
              Type '(middleware: MiddlewareType<InputType, OutputType>, options: RelativeMiddlewareOptions) => void' is not assignable to type '(middleware: MiddlewareType<InputType, CreateEnvironmentCommandOutput>, options: RelativeMiddlewareOptions) => void'.
                Types of parameters 'middleware' and 'middleware' are incompatible.
                  Type 'MiddlewareType<InputType, CreateEnvironmentCommandOutput>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                    Type 'InitializeMiddleware<InputType, CreateEnvironmentCommandOutput>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                      Type 'InitializeMiddleware<InputType, CreateEnvironmentCommandOutput>' is not assignable to type 'InitializeMiddleware<InputType, OutputType>'.
                        Call signature return types 'InitializeHandler<InputType, CreateEnvironmentCommandOutput>' and 'InitializeHandler<InputType, OutputType>' are incompatible.
                          Type 'Promise<InitializeHandlerOutput<CreateEnvironmentCommandOutput>>' is not assignable to type 'Promise<InitializeHandlerOutput<OutputType>>'.
                            Type 'InitializeHandlerOutput<CreateEnvironmentCommandOutput>' is not assignable to type 'InitializeHandlerOutput<OutputType>'.
                              Types of property 'output' are incompatible.
                                Type 'CreateEnvironmentCommandOutput' is not assignable to type 'OutputType'.
                                  'CreateEnvironmentCommandOutput' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'MetadataBearer'.

48     expect(mwaaMock).toHaveReceivedCommand(CreateEnvironmentCommand);
                                              ~~~~~~~~~~~~~~~~~~~~~~~~

lib/lambda/mwaa-new-environment-function.test.ts:53:14 - error TS2339: Property 'on' does not exist on type 'never'.

53     mwaaMock.on(CreateEnvironmentCommand).resolves({ Arn: 'my-env-arn' });
                ~~

lib/lambda/mwaa-new-environment-function.test.ts:66:44 - error TS2345: Argument of type 'typeof CreateEnvironmentCommand' is not assignable to parameter of type 'new (input: CreateEnvironmentCommandInput) => AwsCommand<CreateEnvironmentCommandInput, MetadataBearer>'.

66     expect(mwaaMock).toHaveReceivedCommand(CreateEnvironmentCommand);
                                              ~~~~~~~~~~~~~~~~~~~~~~~~

lib/lambda/mwaa-new-environment-function.test.ts:71:14 - error TS2339: Property 'on' does not exist on type 'never'.

71     mwaaMock.on(CreateEnvironmentCommand).resolves({ Arn: 'my-env-arn' });
                ~~

lib/lambda/mwaa-new-environment-function.test.ts:83:44 - error TS2345: Argument of type 'typeof CreateEnvironmentCommand' is not assignable to parameter of type 'new (input: CreateEnvironmentCommandInput) => AwsCommand<CreateEnvironmentCommandInput, MetadataBearer>'.

83     expect(mwaaMock).toHaveReceivedCommand(CreateEnvironmentCommand);
                                              ~~~~~~~~~~~~~~~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:33:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.
  Type 'MWAAClient' is not assignable to type 'Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>'.

33       const mwaaClientMock = mockClient(mwaaClient);
                                           ~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:35:9 - error TS2353: Object literal may only specify known properties, and 'Environment' does not exist in type 'CommandResponse<MetadataBearer>'.

35         Environment: {
           ~~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:48:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

48       const mwaaClientMock = mockClient(mwaaClient);
                                           ~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:50:9 - error TS2353: Object literal may only specify known properties, and 'Environment' does not exist in type 'CommandResponse<MetadataBearer>'.

50         Environment: {
           ~~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:63:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

63       const mwaaClientMock = mockClient(mwaaClient);
                                           ~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:74:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

74       const mwaaClientMock = mockClient(mwaaClient);
                                           ~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:87:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

87       const mwaaClientMock = mockClient(mwaaClient);
                                           ~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:102:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

102       const mwaaClientMock = mockClient(mwaaClient);
                                            ~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:104:9 - error TS2353: Object literal may only specify known properties, and 'Environment' does not exist in type 'CommandResponse<MetadataBearer>'.

104         Environment: {
            ~~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:117:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

117       const mwaaClientMock = mockClient(mwaaClient);
                                            ~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:119:9 - error TS2353: Object literal may only specify known properties, and 'Environment' does not exist in type 'CommandResponse<MetadataBearer>'.

119         Environment: {
            ~~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:132:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

132       const mwaaClientMock = mockClient(mwaaClient);
                                            ~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:143:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

143       const mwaaClientMock = mockClient(mwaaClient);
                                            ~~~~~~~~~~

lib/lambda/mwaa-status-poller.test.ts:156:41 - error TS2345: Argument of type 'MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

156       const mwaaClientMock = mockClient(mwaaClient);
                                            ~~~~~~~~~~

lib/lambda/mwaa-update-environment-function.test.ts:27:5 - error TS2322: Type 'AwsStub<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>' is not assignable to type 'never'.

27     mwaaMock = mockClient(MWAAClient);
       ~~~~~~~~

lib/lambda/mwaa-update-environment-function.test.ts:27:27 - error TS2345: Argument of type 'typeof MWAAClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, SmithyResolvedConfiguration<HttpHandlerOptions>>>'.

27     mwaaMock = mockClient(MWAAClient);
                             ~~~~~~~~~~

lib/lambda/mwaa-update-environment-function.test.ts:31:14 - error TS2339: Property 'restore' does not exist on type 'never'.

31     mwaaMock.restore();
                ~~~~~~~

lib/lambda/mwaa-update-environment-function.test.ts:35:14 - error TS2339: Property 'on' does not exist on type 'never'.

35     mwaaMock.on(UpdateEnvironmentCommand).resolves({ Arn: 'my-env-arn' });
                ~~

lib/lambda/mwaa-update-environment-function.test.ts:39:44 - error TS2345: Argument of type 'typeof UpdateEnvironmentCommand' is not assignable to parameter of type 'new (input: UpdateEnvironmentCommandInput) => AwsCommand<UpdateEnvironmentCommandInput, MetadataBearer>'.
  Construct signature return types 'UpdateEnvironmentCommand' and 'AwsCommand<UpdateEnvironmentCommandInput, MetadataBearer>' are incompatible.
    The types of 'middlewareStack.concat' are incompatible between these types.
      Type '<InputType extends UpdateEnvironmentCommandInput, OutputType extends UpdateEnvironmentCommandOutput>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>' is not assignable to type '<InputType extends UpdateEnvironmentCommandInput, OutputType extends MetadataBearer>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>'.
        Types of parameters 'from' and 'from' are incompatible.
          Type 'MiddlewareStack<InputType, OutputType>' is not assignable to type 'MiddlewareStack<InputType, UpdateEnvironmentCommandOutput>'.
            Types of property 'addRelativeTo' are incompatible.
              Type '(middleware: MiddlewareType<InputType, OutputType>, options: RelativeMiddlewareOptions) => void' is not assignable to type '(middleware: MiddlewareType<InputType, UpdateEnvironmentCommandOutput>, options: RelativeMiddlewareOptions) => void'.
                Types of parameters 'middleware' and 'middleware' are incompatible.
                  Type 'MiddlewareType<InputType, UpdateEnvironmentCommandOutput>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                    Type 'InitializeMiddleware<InputType, UpdateEnvironmentCommandOutput>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                      Type 'InitializeMiddleware<InputType, UpdateEnvironmentCommandOutput>' is not assignable to type 'InitializeMiddleware<InputType, OutputType>'.
                        Call signature return types 'InitializeHandler<InputType, UpdateEnvironmentCommandOutput>' and 'InitializeHandler<InputType, OutputType>' are incompatible.
                          Type 'Promise<InitializeHandlerOutput<UpdateEnvironmentCommandOutput>>' is not assignable to type 'Promise<InitializeHandlerOutput<OutputType>>'.
                            Type 'InitializeHandlerOutput<UpdateEnvironmentCommandOutput>' is not assignable to type 'InitializeHandlerOutput<OutputType>'.
                              Types of property 'output' are incompatible.
                                Type 'UpdateEnvironmentCommandOutput' is not assignable to type 'OutputType'.
                                  'UpdateEnvironmentCommandOutput' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'MetadataBearer'.

39     expect(mwaaMock).toHaveReceivedCommand(UpdateEnvironmentCommand);
                                              ~~~~~~~~~~~~~~~~~~~~~~~~

Found 34 errors in 4 files.

Errors  Files
     6  lib/lambda/dags-cli.test.ts:49
     9  lib/lambda/mwaa-new-environment-function.test.ts:27
    14  lib/lambda/mwaa-status-poller.test.ts:33
     5  lib/lambda/mwaa-update-environment-function.test.ts:27

Could you please help to direct the right way to troubleshoot the issues above? Thank you!

crupakheti commented 5 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?

JianhengHou commented 5 months ago

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

crupakheti commented 5 months ago

Can you try using Node 18 LTS and report back if you get the same error?

jmflynn81 commented 4 months ago

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
crupakheti commented 4 months ago

Thank you for the bug report @jmflynn81, planning to look into it sometimes next week. Thank you!

skpune commented 4 months ago

Hi @crupakheti we are also facing similar deploying issue due to Node JS version change.

crupakheti commented 4 months ago

Let us know if you still encounter this issue. The fix was tested using Node 18 and 20.