aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.52k stars 3.86k forks source link

aws-cdk-lib: Resolution error: Cannot find module '../../region-info/build-tools/fact-tables' #31492

Closed ajaylamba-provar closed 3 hours ago

ajaylamba-provar commented 11 hours ago

Please add your +1 👍 to let us know you have encountered this

Status:

Overview:

cdk build failure in stacks due to incorrect export of '../../region-info/build-tools/fact-tables'

Complete Error Message:

On running command npx cdk synth

Error: Resolution error: Resolution error: Resolution error: Cannot find module '../../region-info/build-tools/fact-tables' Require stack: `- /Documents/GitHub/test/node_modules/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.js

Versions: "aws-cdk-lib": "^2.159.0",

Regression Issue

Last Known Working CDK Version

2.158.0

Expected Behavior

The synth operation should be successful without any error.

Current Behavior

The synth command is getting failed with the error: Error: Resolution error: Resolution error: Resolution error: Cannot find module '../../region-info/build-tools/fact-tables' Require stack:

Workaround:

Pin CDK version to 2.158.0

Solution:

Revert PR https://github.com/aws/aws-cdk/pull/31496

Reproduction Steps

Create a VPC stack by using import statement as import * as ec2 from 'aws-cdk-lib/aws-ec2';

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.159.0

Framework Version

No response

Node.js Version

18.17.0

OS

MacOS

Language

TypeScript

Language Version

No response

Other information

No response

ajaylamba-provar commented 11 hours ago

After inspecting the node_modules folder of the project, I found that build-tools folder is not present inside aws-cdk-lib/region-info

nelsonsilva-code commented 9 hours ago

I have also encountered this issue, and can confirm that this is only happening in 2.159.0, since my builds started breaking after the last package publishing.

Temporary solution: Pin to 2.158.0 or prior

shani-asad commented 9 hours ago

I'm also experiencing this issue

ajaylamba-provar commented 8 hours ago

Pinning to version 2.158.0 works, thanks @nelsonsilva-code

pahud commented 4 hours ago

Taking a look

pahud commented 4 hours ago

Can't reproduce it.

cdk init a new empty project using 2.159.0 with

import * as cdk from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { Construct } from 'constructs';
// import * as sqs from 'aws-cdk-lib/aws-sqs';

export class CdktestStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new ec2.Vpc(this, 'MyVpc');
  }
}

npx cdk synth works to me.

 % ls node_modules/aws-cdk-lib/region-info 
README.md       index.d.ts      index.js        lib

I found that build-tools folder is not present inside aws-cdk-lib/region-info

Yes! I noticed it. But I think build-tools should not be there. It's not installed in 2.158.0 as well.

still investigating

esteban-ricalde-mysa commented 4 hours ago

Ran into the same issue. Pinning to version 2.158.0 worked for me too

pahud commented 4 hours ago

For those having this issue: @esteban-ricalde-mysa @ajaylamba-provar @shani-asad @nelsonsilva-code

Are you having the same error indicating fact-tables is missing?

Error: Resolution error: Resolution error: Resolution error: Cannot find module '../../region-info/build-tools/fact-tables'

esteban-ricalde-mysa commented 4 hours ago

@pahud Yes, exactly the same error

pahud commented 4 hours ago

OK reproducible.

export class Cdk2159Stack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    // create a random vpc endpoint for a new vpc
    const vpc = new ec2.Vpc(this, 'vpc', {
      maxAzs: 2,
      natGateways: 1,
    });
    const securityGroup = new ec2.SecurityGroup(this, 'sg', { vpc });
    securityGroup.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(443));
    const endpoint = vpc.addInterfaceEndpoint('endpoint', {
      service: ec2.InterfaceVpcEndpointAwsService.EC2,
      securityGroups: [securityGroup],
    });
  }
}

root cause could be - https://github.com/aws/aws-cdk/commit/95c49abdfa4ad77a0c0fcb82a230778dcc2ea59a

github-actions[bot] commented 3 hours ago

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

github-actions[bot] commented 3 hours ago

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.