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 #7149 <WSS> Use AWS partition pseudo param #7430

Conversation

austinjalexander
Copy link
Contributor

What did you implement?

During compileApi, the websockets AWS policy generated currently assumes the standard 'aws' partition (see here). This PR replaces 'aws' with the AWS::Partition pseudo parameter.

Closes #7149

How can we verify it?

A new websockets service using a non-standard region; for example:

service: api
frameworkVersion: '>=1.28.0 <2.0.0'

provider:
  name: aws
  runtime: go1.x

  stage: production
  region: us-gov-west-1
...

Will result in something like the following error:

Serverless: Packaging service...
Serverless: Excluding development dependencies...
...
CloudFormation - UPDATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
CloudFormation - UPDATE_FAILED - AWS::IAM::Role - IamRoleLambdaExecution
...
Serverless: Operation failed!
...
An error occurred: IamRoleLambdaExecution - Partition "aws" is not valid for resource "arn:aws:execute-api:*:*:*/@connections/*". (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument...
...

Using the changes in this PR, while deploying in a non-standard partition (e.g., 'aws-us-gov'), will result in success! :)

Prior Art

Resources

Todos

  • 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

@austinjalexander austinjalexander changed the title Fix #7149 Use AWS partition pseudo param Fix #7149 <Websockets> Use AWS partition pseudo param Mar 6, 2020
@austinjalexander austinjalexander changed the title Fix #7149 <Websockets> Use AWS partition pseudo param Fix #7149 <WSS> Use AWS partition pseudo param Mar 6, 2020
@austinjalexander
Copy link
Contributor Author

@medikoo It looks like Travis errored out; would you mind re-running, please?

@medikoo
Copy link
Contributor

medikoo commented Mar 6, 2020

@austinjalexander thanks for update. It looks way better!

Concerning CI fails, it looks that npm went nuts (issue we didn't see before got exposed).

To have that fixed I needed to update our CI configuration in master, therefore when you update your branch with master issue will be resolved.

@austinjalexander
Copy link
Contributor Author

Fantastic! Thank you, @medikoo! 😄

@medikoo
Copy link
Contributor

medikoo commented Mar 7, 2020

@austinjalexander I've updated your branch automatically with master, and still one CI issue got exposed.
Can you ensure changes follow Prettier formatting? You can easily fix it by running npm run prettify:updated

@austinjalexander austinjalexander force-pushed the aja/fix-websockets-use-partition-param branch from ab67a25 to f31cbfa Compare March 8, 2020 20:40
@codecov-io
Copy link

Codecov Report

Merging #7430 into master will decrease coverage by 0.02%.
The diff coverage is 89.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7430      +/-   ##
==========================================
- Coverage   87.99%   87.96%   -0.03%     
==========================================
  Files         240      240              
  Lines        9052     9101      +49     
==========================================
+ Hits         7965     8006      +41     
- Misses       1087     1095       +8
Impacted Files Coverage Δ
lib/classes/Service.js 97.43% <ø> (ø) ⬆️
commitlint.config.js 0% <ø> (ø) ⬆️
lib/plugins/print/print.js 98.5% <ø> (ø) ⬆️
...s/aws/package/compile/events/websockets/lib/api.js 100% <ø> (ø) ⬆️
...esources/resources/cognitoUserPool/lib/userPool.js 0% <0%> (ø) ⬆️
lib/plugins/aws/lib/naming.js 97.41% <100%> (+0.01%) ⬆️
lib/plugins/aws/provider/awsProvider.js 92.72% <80%> (-0.51%) ⬇️
...lugins/aws/package/compile/events/httpApi/index.js 88.6% <90.9%> (+0.17%) ⬆️
lib/plugins/aws/package/compile/functions/index.js 96.71% <91.3%> (-1.27%) ⬇️

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 2c0a0e2...f31cbfa. Read the comment docs.

@austinjalexander
Copy link
Contributor Author

@medikoo All set! :)

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 @austinjalexander !

@medikoo medikoo merged commit 9b627fb into serverless:master Mar 8, 2020
@austinjalexander austinjalexander deleted the aja/fix-websockets-use-partition-param branch March 8, 2020 23:26
@austinjalexander
Copy link
Contributor Author

Thank you for taking such swift action, @medikoo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please do not hard code ARN partition for websocket
3 participants