tradle / serverless-iot-local

MIT License
14 stars 7 forks source link

Improve mock support for AWS SDK #1

Closed karlsnyder0 closed 6 years ago

karlsnyder0 commented 6 years ago

Improves the describeEndpoint mock (Serverless Offline)

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Iot.html#describeEndpoint-property

Add mocks for getCallerIdentity and assumeRole.

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/STS.html https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/STS.html#assumeRole-property https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/STS.html#getCallerIdentity-property

Add Support for Redis Host, Port and Database.

mvayngrib commented 6 years ago

@karlsnyder0 thanks for the PR! A few questions and comments:

karlsnyder0 commented 6 years ago

@mvayngrib

BTW, I have another PR coming for adding secure communication and self signed certificate support. You see, we are using the AWS Device Client to communicate with AWS IoT. The AWS Device Client does not allow non-secure communication.

mvayngrib commented 6 years ago

@karlsnyder0 cool, looking forward to the next PR!

the main issue I have with the STS mocking bit is that STS is used for all kinds of identity-related scenarios, not limited to Iot. If serverless-offline decides to mock it too (which i hope they won't for the same reason this module doesn't), or some other plugin does, or the user themselves, those mocks will conflict with each other, or just error out. On the other hand, it's relatively easy for the user to add the mocks in their setup, e.g. conditioned on the NODE_ENV or IS_OFFLINE env vars. That's what I currently do in my project - have a bunch of additional mocks that are specific to my use cases. Does that make sense?

karlsnyder0 commented 6 years ago

@mvayngrib Please review the latest changes.

If you would prefer the STS Mocks be left out I can certainly do that. It seemed to make sense to me that this would be completely isolated from the implementation however I can certainly create another plugin to mock STS. Are you sure you don't want STS in this plugin?

mvayngrib commented 6 years ago

@karlsnyder0 how about let's make it optional, and add a mockSTS config flag, which defaults to false

karlsnyder0 commented 6 years ago

@mvayngrib I've removed the STS mocks.

karlsnyder0 commented 6 years ago

@mvayngrib fyi- I'm planning to propose to Serverless Offline that they add AWS Mocks so that the AWS SDK works with offline.

karlsnyder0 commented 6 years ago

I can definitely see as this grows there should be a separate method in charge of building the mosca backend config. See latest changes.

karlsnyder0 commented 6 years ago

@mvayngrib Please review when you get the chance. Thanks!

mvayngrib commented 6 years ago

@karlsnyder0 lgtm. Fix the README and I'll merge?

mvayngrib commented 6 years ago

@karlsnyder0 thanks! Released in 1.3.0

karlsnyder0 commented 6 years ago

@mvayngrib Thanks! I'll followup with my next PR.