Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(custom-resource-handlers): */generated.ts file imports do not support alpha modules #28788

Open
paulhcsun opened this issue Jan 19, 2024 · 0 comments
Assignees
Labels
aws-cdk-lib Related to the aws-cdk-lib package bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Comments

@paulhcsun
Copy link
Contributor

Describe the bug

When a module has a dependency on custom-resource-handlers we will use an script to airlift the necessary files into the package to be released alongside that module.

For the */generated.ts files, the import paths

class LambdaModule extends ExternalModule {
public readonly Function = Type.fromName(this, 'Function');
public readonly SingletonFunction = Type.fromName(this, 'SingletonFunction');
public readonly FunctionOptions = Type.fromName(this, 'FunctionOptions');
public constructor() {
super('../../../aws-lambda');
}
}
used only work under the assumption that the file is being airlifted and released alongside aws-cdk-lib and therefore can't be supported for alpha modules.

For now when airlifting custom-resource-handlers into alpha modules, we can only airlift the index.js file and a */generated.ts files must be added to custom-resources-framework/config.ts as ComponentType.NO_OP (i.e.

'aws-redshift-alpha': {
'cluster-reboot-provider': [
{
type: ComponentType.NO_OP,
sourceCode: path.resolve(__dirname, '..', 'aws-redshift-alpha', 'cluster-parameter-change-reboot-handler', 'index.ts'),
).

Expected Behavior

The import paths in the */generated.ts files should work when they're airlifted into an alpha module.

Current Behavior

The import does not because the import path assumes that the current module is located within aws-cdk-lib.

Reproduction Steps

Add

$customresourcedir/dist/*[^-alpha]/*.generated.ts)
          cr=$(echo $file | rev | cut -d "/" -f 2-3 | rev)
          airlift $cr $cr/*.generated.ts
          ;;

to the aws-redshift-alpha airlift script and run yarn package

Possible Solution

Update the import paths in https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/custom-resource-handlers/lib/custom-resources-framework/modules.ts so that it can be used for alpha modules.

Additional Information/Context

No response

CDK CLI Version

2.121.1

Framework Version

No response

Node.js Version

21.1.0

OS

14.2.1

Language

TypeScript

Language Version

No response

Other information

No response

@paulhcsun paulhcsun added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 19, 2024
@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Jan 19, 2024
@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 22, 2024
@paulhcsun paulhcsun self-assigned this Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-cdk-lib Related to the aws-cdk-lib package bug This issue is a bug. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

No branches or pull requests

2 participants