Skip to content

Conversation

m4rw3r
Copy link

@m4rw3r m4rw3r commented Oct 1, 2025

Reason for this change

When attempting to use @aws-cdk/aws-ec2-alpha I get the following import error:

node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-cdk/aws-ec2-alpha/lib/subnet-v2.d.ts:5:33 -
  error TS2307: Cannot find module 'aws-cdk-lib/aws-ec2/lib/ec2.generated' or its corresponding type declarations.

5 import { SubnetReference } from 'aws-cdk-lib/aws-ec2/lib/ec2.generated';

I'm using pnpm as the package manager, and typescript is using bundler as the moduleResolution. Following the typescript module resolution output from tsc --traceResolution it seems like ./aws-ec2/lib/ec2.generated is not exposed publicly in the package.json, and it will not attempt to load the file directly since it is a module-import and not a local import.

From what I can tell it was introduced by #35032

Description of changes

This PR changes the imports of SubnetReference and VPCReference to use the publicly available symbols from aws-cdk-lib/aws-ec2 instead of importing them directly from the file itself. The alternative would be to add ./aws-ec2/lib/ec2.generated to aws-cdk-lib's package.json exports.

Description of how you validated changes

Manual update of the relevant .d.ts-files in a project importing @aws-cdk/aws-ec2-alpha will solve the issue.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

The private reference to the full file fails due to `package.json` not
exposing it.
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Oct 1, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team October 1, 2025 23:51
@github-actions github-actions bot added the p2 label Oct 1, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter fails with the following errors:

❌ Fixes must contain a change to a test file.
❌ Fixes must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@m4rw3r
Copy link
Author

m4rw3r commented Oct 1, 2025

Exemption Request: Not sure how I would go about testing this, besides creating a separate project which runs tsc --check.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants