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

fix(aws-custom-resource): switch off installLatestAwsSdk by default #23591

Merged
merged 9 commits into from
Jan 10, 2023

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Jan 6, 2023

The AwsCustomResource reaches out to the internet to install the latest AWS SDK by default. This will make it fail if it is being bound to a VPC that doesn't have internet connectivity, or in regions/partitions that are not able to freely connect to npmjs.com.

This was a poorly chosen default from the time we didn't know any better, but we do know right now. Switch the behavior off by default (under feature flag), and explicitly disable it for all AwsCustomResources the L2 library uses. Lambda advertises 2.1055.0 of the SDK everywhere, and I checked to make sure that all APIs we use are part of that SDK version, so we don't need any newer version.

That version is a year old (!) so this is not the end of the story, but it's at least an improvement over what we currently have.

Fixes #23113.


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

The `AwsCustomResource` reaches out to the internet to install the
latest AWS SDK by default. This will make it fail if it is being bound
to a VPC that doesn't have internet connectivity, or in
regions/partitions that are not able to freely connect to `npmjs.com`.

This was a poorly chosen default from the time we didn't know any
better, but we do know right now. Switch the behavior off by default
(under feature flag), and explicitly disable it for all
`AwsCustomResource`s the L2 library uses. Lambda advertises 2.1055.0
of the SDK everywhere, and I checked to make sure that all APIs we
use are part of that SDK version, so we don't need any newer version.

That version is a year old (!) so this is not the end of the story,
but it's at least an improvement over what we currently have.

Fixes #23113.
@rix0rrr rix0rrr requested a review from a team January 6, 2023 12:44
@rix0rrr rix0rrr self-assigned this Jan 6, 2023
@gitpod-io
Copy link

gitpod-io bot commented Jan 6, 2023

@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Jan 6, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team January 6, 2023 12:44
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 6, 2023
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 has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

@rix0rrr rix0rrr added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Jan 6, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 6, 2023 13:03

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

@mrgrain
Copy link
Contributor

mrgrain commented Jan 6, 2023

Re: Failing build. Looks like some integ test snapshots need to be updated.

@mergify
Copy link
Contributor

mergify bot commented Jan 10, 2023

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: eb3e6dc
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit c9b2548 into main Jan 10, 2023
@mergify mergify bot deleted the huijbers/aws-custom-resource-install-latest branch January 10, 2023 11:25
@mergify
Copy link
Contributor

mergify bot commented Jan 10, 2023

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

@s0enke
Copy link

s0enke commented Jan 18, 2023

Edit: After reading the change more thoroughly, I understood the mechanism of the new default: The @aws-cdk/customresources:installLatestAwsSdkDefault value is set to false for all new initialized CDK projects, so that nothing changes for existing projects.

The documentation still states that true is the default: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources.AwsCustomResource.html#installlatestawssdk

I suspect it's because the code documentation needs to be updated as well:

* @default - The value of `@aws-cdk/customresources:installLatestAwsSdkDefault`, otherwise `true`

DerkSchooltink pushed a commit to DerkSchooltink/aws-cdk that referenced this pull request Jan 23, 2023
…aws#23591)

The `AwsCustomResource` reaches out to the internet to install the latest AWS SDK by default. This will make it fail if it is being bound to a VPC that doesn't have internet connectivity, or in regions/partitions that are not able to freely connect to `npmjs.com`.

This was a poorly chosen default from the time we didn't know any better, but we do know right now. Switch the behavior off by default (under feature flag), and explicitly disable it for all `AwsCustomResource`s the L2 library uses. Lambda advertises 2.1055.0 of the SDK everywhere, and I checked to make sure that all APIs we use are part of that SDK version, so we don't need any newer version.

That version is a year old (!) so this is not the end of the story, but it's at least an improvement over what we currently have.

Fixes aws#23113.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
mergify bot pushed a commit that referenced this pull request Apr 12, 2024
…y Group reference (#29620)

### Issue # (if applicable)

Closes #23796

### Reason for this change

In #23591 `installLatestAwsSdk`. This results in a resource update for custom resources. The custom resource that fetches the security groups does not have an onUpdate handler (https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-globalaccelerator/lib/_accelerator-security-group.ts#L32).

When the empty object is returned, this results in an update failure in
CloudFormation because the specific property isn't available and so it will fail with error below:

```
CustomResource attribute error: Vendor response doesn't contain SecurityGroups.0.GroupId key in object
```

When the update occurs, the response object does not have a `SecurityGroups.0.GroupId` field, resulting in failures when `SecurityGroups` is referenced.

### Description of changes
Update the onCreate to onUpdate for custom resources to mitigate the CloudFormation update failure. Documentations: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources.AwsCustomResource.html#oncreate. 
Similar fix for Cognito: #23798

### Description of how you validated changes

The integration test is updated with the latest assets.

### 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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p1 pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
4 participants