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

(aws_events_targets): Confusing installLatestAwsSdk warning #23956

Closed
mvs5465 opened this issue Feb 1, 2023 · 5 comments
Closed

(aws_events_targets): Confusing installLatestAwsSdk warning #23956

mvs5465 opened this issue Feb 1, 2023 · 5 comments
Assignees
Labels
@aws-cdk/aws-events-targets documentation This is a problem with documentation.

Comments

@mvs5465
Copy link

mvs5465 commented Feb 1, 2023

Describe the issue

We are using the aws_events_targets module and this appears to be creating a custom resource. Specifically working with cloudtrail events for the onEvent static method: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudtrail.Trail.html#static-onwbreventscope-id-options

When compiling, there is a warning:

installLatestAwsSdk was not specified, and defaults to true. You probably do not want this. Set the global context flag '@aws-cdk/customresources:installLatestAwsSdkDefault' to false to switch this behavior off project-wide, or set the property explicitly to true if you know you need to call APIs that are not in Lambda's built-in SDK version.

What is the intended way to set this flag? Is this something the user should set? I see this PR from 3 weeks ago saying the default value is now false: #23591

Links

#23591

@mvs5465 mvs5465 added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Feb 1, 2023
@peterwoodworth
Copy link
Contributor

peterwoodworth commented Feb 3, 2023

Hey @mvs5465, could you please provide sample code which will generate this issue?

The error message describes setting the global context flag @aws-cdk/customresources:installLatestAwsSdkDefault to false. You can do this in your cdk.json file 🙂

@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 3, 2023
@peterwoodworth peterwoodworth self-assigned this Feb 3, 2023
@mvs5465
Copy link
Author

mvs5465 commented Feb 3, 2023

@peterwoodworth Sure, this will generate the warning as of cdk 2.63.0:

import * as cdk from 'aws-cdk-lib';
import { aws_cloudtrail as ct, aws_events_targets as targets, aws_logs as logs } from 'aws-cdk-lib';

export class LoginEventStack extends cdk.Stack {

  constructor(scope: cdk.App, id: string, props: cdk.StackProps) {
    super(scope, id, props);

    const loginEvent = ct.Trail.onEvent(this, 'login-event', {
      eventPattern: {
        source: ['aws.signin'],
        detailType: ['AWS Console Sign In via CloudTrail'],
        detail: {
          eventName: [
            'ConsoleLogin',
          ],
        },
      },
    });

    loginEvent.addTarget(new targets.CloudWatchLogGroup(new logs.LogGroup(this, 'login-event-logs')));
  }
}

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Feb 3, 2023
@peterwoodworth
Copy link
Contributor

peterwoodworth commented Feb 3, 2023

Thanks for the code @mvs5465, that was really easy to copy and paste and reproduce the warning 🙂

Were you able to successfully disable the warning by setting the flag in cdk.json? You can view more information about feature flags here

@mvs5465
Copy link
Author

mvs5465 commented Feb 7, 2023

Yes @peterwoodworth thanks for the fantastic link! We added the rest of the recommended feature flags too. The warning is gone and we got a few other improvements out of that. Appreciate it.

@mvs5465 mvs5465 closed this as completed Feb 7, 2023
@github-actions
Copy link

github-actions bot commented Feb 7, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-events-targets documentation This is a problem with documentation.
Projects
None yet
Development

No branches or pull requests

2 participants