fix(aws-eks): Support for http proxy in EKS onEvent lambda#16652
Closed
fix(aws-eks): Support for http proxy in EKS onEvent lambda#16652
Conversation
…bdas `nodeModules` bundling opt
…da-http-proxy # Conflicts: # packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/common.ts # packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/package.json # packages/@aws-cdk/aws-eks/lib/cluster-resource-provider.ts
otaviomacedo
approved these changes
Sep 24, 2021
Contributor
Author
|
Blocking merge with |
…6597) Add `vault.addToAccessPolicy()` and `vault.blockRecoveryPointDeletion()`. A vault is automatically created when creating a plan: ```ts const plan = new backup.BackupPlan(this, 'BackupPlan'); ``` Theses methods allow, among other things, to customize the access policy of the automatically created vault: ```ts plan.backupVault.addToAccessPolicy(...); ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
… lambda" (#16651) A bug was introduced in [this commit](cf22280) that broke the `onEvent` EKS cluster handler lambda. ESBuild was inlining the node_module `proxy-agent` which was trying to read a file that did not exist (because all dependencies were bundled into a single file). e.g. ```ts var contextify = fs.readFileSync('/var/task/contextify.js'); ``` Error: ```log ENOENT: no such file or directory, open '/var/task/contextify.js' Logs: /aws/lambda/test-fixed-nobundle-eks-wit-OnEventHandler42BEBAE0-s2cZwaWDW0xt at Object.openSync (fs.js:462:3) at Object.readFileSync (fs.js:364:35) at loadAndCompileScript (/var/task/index.js:29479:23) at ../aws-cdk/node_modules/vm2/lib/main.js (/var/task/index.js:29490:25) at __require (/var/task/index.js:26:44) at ../aws-cdk/node_modules/vm2/index.js (/var/task/index.js:30079:23) at __require (/var/task/index.js:26:44) at ../aws-cdk/node_modules/degenerator/dist/src/index.js (/var/task/index.js:30091:17) at __require (/var/task/index.js:26:44) at ../aws-cdk/node_modules/pac-resolver/dist/index.js (/var/task/index.js:30857:25) (RequestId: c44d1357-fbce-4f96-8c23-b865c2c3aaff) ``` This reverts commit cf22280. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
# Conflicts: # packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/common.ts # packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/package.json # packages/@aws-cdk/aws-eks/lib/cluster-resource-provider.ts
Collaborator
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
ryparker
added a commit
that referenced
this pull request
Sep 25, 2021
Contributor
Author
|
The commits for this branch got messy after rebasing on the revert. Just to be safe I recreated this PR on a fresh branch off master: #16652 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Currently when a user wants to route all of the EKS lambda's SDK requests through a proxy then they are instructed to configure an env var named
HTTP_PROXYorhttp_proxy.e.g.
However the JS SDK requires further configuration to enable proxy support.
This PR:
package.jsonwith the dependency 'http-proxy-agent' to thecluster-resource-handler/lambda bundleNodeJSFunctionto install lambda dependencies and bundle.HTTP_PROXYorhttp_proxyvalues. If present then configures the aws-sdk to use that proxy (usinghttp-proxy-agent).Note: I placed the
http-proxy-agentin thedevDependenciesofpackage.json. If the dependency is placed in thedependenciessection then the CDK builder throws an error:NPM Package cluster-resources-handler inside jsii package '@aws-cdk/aws-eks', can only have devDependenciesFixes: SIM D29159517, #12469
Tested this using squid proxy on an ec2 instance within the same VPC as the EKS cluster.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license