Skip to content

Conversation

@go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Nov 25, 2025

Issue # (if applicable)

N/A

Reason for this change

Synth fails when using the AutoDeleteObjects mixin:

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 specifies:

  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 copies the dist files.

But .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


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

@aws-cdk-automation aws-cdk-automation requested a review from a team November 25, 2025 07:11
@github-actions github-actions bot added p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Nov 25, 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.

(This review is outdated)

@go-to-k
Copy link
Contributor Author

go-to-k commented Nov 25, 2025

Exemption Request: This PR changes the npmignore file only.

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Nov 25, 2025
@mrgrain mrgrain added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Nov 25, 2025
@mrgrain mrgrain changed the title fix(mixins-preview): AutoDeleteObjects mixin is not working fix(mixins-preview): AutoDeleteObjects mixin fails with cannot find file error Nov 25, 2025
mrgrain
mrgrain previously approved these changes Nov 25, 2025
Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

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

Ha, thanks for that 🙈

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 25, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 25, 2025 09:07

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@mergify mergify bot dismissed mrgrain’s stale review November 25, 2025 09:08

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Nov 25, 2025

Merge Queue Status Beta

✅ The pull request has been merged

This pull request spent 28 minutes 15 seconds in the queue, including 28 minutes 6 seconds waiting for CI.
The checks were run in-place.

Required conditions to merge

@mergify
Copy link
Contributor

mergify bot commented Nov 25, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Contributor

mergify bot commented Nov 25, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 3ef337d into aws:main Nov 25, 2025
18 of 19 checks passed
@github-actions
Copy link
Contributor

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 github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2025
@go-to-k go-to-k deleted the fix-mixins-auto-delete-objects-prv branch November 25, 2025 10:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-test The PR linter will not require test changes 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.

3 participants