-
Notifications
You must be signed in to change notification settings - Fork 17
Fix: support aws-cdk>=2.177.0 #107
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a21c989
Set envars for aws-cdk>=2.177.0
simonrw f4412a8
Update changelog
simonrw ba1d3ee
Bump version number
simonrw 989c753
Add AWS_ENDPOINT_URL_S3 entry in configurations
simonrw 48ff247
Format
simonrw 04f1dba
Include 2.177 in versions array
simonrw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,7 +252,7 @@ const patchToolkitInfo = (ToolkitInfo) => { | |
await prefetchBucketUrl(toolkitInfoObject); | ||
return toolkitInfoObject; | ||
}; | ||
|
||
const fromStackFn = ToolkitInfo.fromStack; | ||
ToolkitInfo.fromStack = (...args) => { | ||
const toolkitInfoObject = fromStackFn(...args); | ||
|
@@ -451,6 +451,13 @@ const patchPre_2_14 = () => { | |
applyPatches(provider, CdkToolkit, SDK, ToolkitInfo); | ||
}; | ||
|
||
const configureEnvironment = () => { | ||
// This _must_ use localhost.localstack.cloud as we require valid subdomains of these paths to | ||
// resolve. Unfortunately though `curl` seems to support subdomains of localhost, the CDK does not. | ||
process.env.AWS_ENDPOINT_URL_S3 = process.env.AWS_ENDPOINT_URL_S3 || `${PROTOCOL}://s3.localhost.localstack.cloud:${EDGE_PORT}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot to share, but by default, we are also using |
||
process.env.AWS_ENDPOINT_URL = process.env.AWS_ENDPOINT_URL || `${PROTOCOL}://localhost.localstack.cloud:${EDGE_PORT}`; | ||
}; | ||
|
||
const patchPost_2_14 = () => { | ||
var lib = null; | ||
try { | ||
|
@@ -463,7 +470,27 @@ const patchPost_2_14 = () => { | |
} | ||
} | ||
|
||
applyPatches(lib, lib, lib.SDK, lib.ToolkitInfo, false); | ||
// detect if we are using version 2.177.0 or later. This version has reorganised the package | ||
// structure so that we cannot import and patch the aws-cdk package as we did for versions | ||
// <2.177.0. We use the specific error raised by the node require system to determine if we are | ||
// using pre or post 2.177.0. | ||
try { | ||
require("aws-cdk/lib/legacy-exports"); | ||
} catch (e) { | ||
switch (e.code) { | ||
case "MODULE_NOT_FOUND": | ||
// pre 2.177 | ||
applyPatches(lib, lib, lib.SDK, lib.ToolkitInfo, false); | ||
break; | ||
case "ERR_PACKAGE_PATH_NOT_EXPORTED": | ||
// post 2.177 | ||
configureEnvironment(); | ||
break; | ||
default: | ||
// a different error | ||
throw e | ||
} | ||
} | ||
}; | ||
|
||
if (isEsbuildBundle()) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So
s3.localhost
didn't work for you with cdklocal buts3.localhost.localstack.cloud
did? 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup unfortunately. I think it depends on the dns resolver and tool making the dns query, so sometimes it works and sometimes it doesn't depending on the tool.