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

Govcloud custom resource fix #6996

Merged
merged 7 commits into from Nov 25, 2019

Conversation

jmb12686
Copy link
Contributor

@jmb12686 jmb12686 commented Nov 21, 2019

What did you implement

Closes #6995 . Fix GovCloud Region ARN and Environment parsing utilities in the AWS Plugin for Custom Resources.

How can we verify it

Deploy a serverless function to us-gov-west-1 or us-gov-east-1 that uses S3 Bucket events on an existing S3 bucket, for example:

service:
  name: myService
provider:
  name: aws
  runtime: nodejs10.x
  stage: dev
  region: us-gov-west-1
functions:
  users:
    handler: users.handler
    events:
      - s3:
          bucket: legacy-photos
          event: s3:ObjectCreated:*
          rules:
            - prefix: uploads/
            - suffix: .jpg
          existing: true

Todos

Useful Scripts
  • npm run test-ci --> Run all validation checks on proposed changes
  • npm run lint-updated --> Lint all the updated files
  • npm run lint:fix --> Automatically fix lint problems (if possible)
  • npm run prettier-check-updated --> Check if updated files adhere to Prettier config
  • npm run prettify-updated --> Prettify all the updated files
  • Write and run all tests
  • Write documentation
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@codecov-io
Copy link

codecov-io commented Nov 21, 2019

Codecov Report

Merging #6996 into master will increase coverage by 0.05%.
The diff coverage is 4.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6996      +/-   ##
==========================================
+ Coverage   88.43%   88.48%   +0.05%     
==========================================
  Files         229      229              
  Lines        8420     8414       -6     
==========================================
- Hits         7446     7445       -1     
+ Misses        974      969       -5
Impacted Files Coverage Δ
...ws/customResources/resources/s3/lib/permissions.js 0% <0%> (ø) ⬆️
...urces/resources/cognitoUserPool/lib/permissions.js 0% <0%> (ø) ⬆️
...rces/resources/apiGatewayCloudWatchRole/handler.js 0% <0%> (ø) ⬆️
...s/customResources/resources/eventBridge/handler.js 0% <0%> (ø) ⬆️
...stomResources/resources/cognitoUserPool/handler.js 0% <0%> (ø) ⬆️
...Resources/resources/eventBridge/lib/permissions.js 0% <0%> (ø) ⬆️
...lugins/aws/customResources/resources/s3/handler.js 0% <0%> (ø) ⬆️
lib/plugins/aws/customResources/resources/utils.js 21.21% <100%> (ø) ⬆️
lib/utils/downloadTemplateFromRepo.js 96.22% <0%> (-0.04%) ⬇️
...ompile/events/apiGateway/lib/method/integration.js 98.14% <0%> (ø) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e022ba...67d8478. Read the comment docs.

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmb12686 great thanks for proposal! We definitely should sort this out, still please see my comments

lib/plugins/aws/customResources/resources/utils.js Outdated Show resolved Hide resolved
@medikoo medikoo added this to the 1.59.0 milestone Nov 22, 2019
@medikoo medikoo added the bug label Nov 22, 2019
…and china regions. Add utility function to obtain partition from region
@jmb12686
Copy link
Contributor Author

I made the modifications requested. I also found 3 additional locations under the /lib/plugins/aws/customResources/resources/* tree that were not properly handling AWS Partition for US GovCloud. I went ahead and created a utility function to properly parse from Region -> Partition for the permissions.js scripts.

@jmb12686
Copy link
Contributor Author

jmb12686 commented Nov 23, 2019

I was able to test this PR's changes successfully in us-gov-west-1 region with the scenario I reported in bug #6995 . @medikoo Let me know if there's anything else I need to do to get this approved and merged into master.
Thanks.

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jmb12686 it looks great!

I've just proposed one improvement, which should allow us to also resolve partition in all cases via getEnvironment and not try to assume it from region (which doesn't seem 100% bulletproof)

lib/plugins/aws/customResources/resources/utils.js Outdated Show resolved Hide resolved
@jmb12686
Copy link
Contributor Author

@medikoo I've updated the PR with the latest changes you requested.

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you @jmb12686

I've run it against our integration tests, and all works as expected

@medikoo medikoo merged commit 1cc8778 into serverless:master Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom Resource does not support AWS US Gov Cloud Region (us-gov-west-1)
5 participants