fix(deadline): fix import and HTTPS redirect errors in stage-deadline #181
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.
Fixes #177
Problem
There are two issues with the
stage-deadline
script in RFDK 0.18.0 (see #177):1. Failed import of
aws-sdk
The
stage-deadline.ts
file imported some code from the shared lambda directory:aws-rfdk/packages/aws-rfdk/bin/stage-deadline.ts
Line 15 in 90c83a4
This then imports from
handler.ts
:aws-rfdk/packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/index.ts
Line 6 in 90c83a4
Which imports from
custom-resource.ts
:aws-rfdk/packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/handler.ts
Line 9 in 90c83a4
Which imports from
dynamo-backed-resource.ts
:aws-rfdk/packages/aws-rfdk/lib/core/lambdas/nodejs/lib/custom-resource/index.ts
Line 6 in 90c83a4
Which imports the
aws-sdk
:aws-rfdk/packages/aws-rfdk/lib/core/lambdas/nodejs/lib/custom-resource/dynamo-backed-resource.ts
Line 9 in 90c83a4
This causes an import error when running the command through
npx
since we do not specifyaws-sdk
in the list of dependencies for theaws-rfdk
package that containsstage-deadline
.2. HTTP 301 Redirect from HTTP -> HTTPS causes abort
The
VersionProvider
class uses Node.JS's built-inhttp
module to fetch the download index.aws-rfdk/packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider.ts
Line 157 in 90c83a4
But, the download index is an HTTPS URL:
aws-rfdk/packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider.ts
Line 147 in 90c83a4
The
http
module appears to accept thehttps://
URL, but makes a plain-HTTP request. The response comes back as an HTTP 301 redirect. TheVersionProvider
handles this as an error:aws-rfdk/packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider.ts
Lines 167 to 177 in 90c83a4
Solution
Create a 0.18.1 patch release of RFDK that resolves the two bugs mentioned above. Each of the fix is addressed in their own commit. Summary of the changes:
1. Failed import of
aws-sdk
Import the symbols directly from
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider' to avoid the import of
aws-sdk`.2. HTTP 301 Redirect from HTTP -> HTTPS causes abort
Replaced the usage of
http
module withhttps
.Patch release
Created a bump commit that increments the patch version. Also note that this pull request targets the
releases/0.18.1
branch. Once this is merged, a release pipeline will be ran against this branch.Follow-up PR(s) will be created to merge the fixing commits back to the
mainline
branch.Testing
Reproduce issue using a dev build
Created a new CDK application in a separate directory:
Link the dev build using the
link-all.sh
script${PATH_TO_RFDK_CHECKOUT}/link-all.sh
Rename the
aws-sdk
directory in${PATH_TO_RFDK_CHECKOUT}/node_modules
toaws-sdk2
Attempt to stage Deadline:
Confirmed I get the reproduced error message:
After fixing confirm the errors are gone and Deadline is staged
Same process as above after applying the fix to my changes to my RFDK development build
Confirmed no errors and Deadline is staged:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license