Commit 3ef337d
authored
fix(mixins-preview):
### Issue # (if applicable)
N/A
### Reason for this change
Synth fails when using the `AutoDeleteObjects` mixin:
```ts
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { CfnBucket } from 'aws-cdk-lib/aws-s3';
import { AutoDeleteObjects } from '@aws-cdk/mixins-preview/aws_s3/mixins';
import '@aws-cdk/mixins-preview/with';
import { Mixins } from '@aws-cdk/mixins-preview/core';
export class CdkSampleStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const bucket = new CfnBucket(this, 'MyBucket');
Mixins.of(bucket).apply(new AutoDeleteObjects());
}
}
```
Error messages:
```
❯ npx cdk synth
/Users/goto/cdk-sample/node_modules/@aws-cdk/mixins-preview/lib/custom-resource-handlers/aws-s3/auto-delete-objects-provider.ts:15
return existing ?? new AutoDeleteObjectsProvider(stack, id, props);
^
ValidationError: cannot find /Users/goto/cdk-sample/node_modules/@aws-cdk/mixins-preview/lib/custom-resource-handlers/dist/aws-s3/auto-delete-objects-handler/index.js
at path [CdkSampleStack/Custom::S3AutoDeleteObjectsCustomResourceProvider] in aws-cdk-lib.CustomResourceProviderBase
at Function.getOrCreateProvider (/Users/goto/cdk-sample/node_modules/@aws-cdk/mixins-preview/lib/custom-resource-handlers/aws-s3/auto-delete-objects-provider.ts:15:24)
at AutoDeleteObjects.applyTo (/Users/goto/cdk-sample/node_modules/@aws-cdk/mixins-preview/lib/services/aws-s3/bucket.ts:27:48)
at MixinApplicator.apply (/Users/goto/cdk-sample/node_modules/@aws-cdk/mixins-preview/lib/core/applicator.ts:29:17)
at new CdkSampleStack (/Users/goto/cdk-sample/lib/cdk-sample-stack.ts:14:53)
at Object.<anonymous> (/Users/goto/cdk-sample/bin/cdk-sample.ts:9:1)
at Module._compile (node:internal/modules/cjs/loader:1554:14)
at Module.m._compile (/Users/goto/cdk-sample/node_modules/ts-node/src/index.ts:1618:23)
at node:internal/modules/cjs/loader:1706:10
at Object.require.extensions.<computed> [as .ts] (/Users/goto/cdk-sample/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1289:32)
```
[AutoDeleteObjectsProvider](https://github.com/aws/aws-cdk/blob/v2.229.0/packages/@aws-cdk/mixins-preview/lib/custom-resource-handlers/aws-s3/auto-delete-objects-provider.ts#L21) specifies:
```ts
private constructor(scope: Construct, id: string, props?: CustomResourceProviderOptions) {
super(scope, id, {
...props,
codeDirectory: path.join(__dirname, '..', 'dist', 'aws-s3', 'auto-delete-objects-handler'),
```
And the [script](https://github.com/aws/aws-cdk/blob/v2.229.0/packages/@aws-cdk/mixins-preview/scripts/airlift-custom-resource-handlers.sh) copies the dist files.
But [.npmignore](https://github.com/aws/aws-cdk/blob/v2.229.0/packages/@aws-cdk/mixins-preview/.npmignore) ignores `dist`, so code for auto-delete-objects-provider cannot be provided to user's module.
```
# There should be a 'dist' folder, but it is not there...
❯ ls node_modules/@aws-cdk/mixins-preview/lib/custom-resource-handlers/
aws-s3
```
### Description of changes
### Describe any new or updated permissions being added
Added `!lib/custom-resource-handlers/dist` to packages/@aws-cdk/mixins-preview/.npmignore.
### Description of how you validated changes
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*AutoDeleteObjects mixin fails with cannot find file error (#36188)1 parent 0b9d7e6 commit 3ef337d
1 file changed
+1
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
0 commit comments