aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.82k stars 820 forks source link

Add "amplify add pubsub" resource to use AWS IoT as pubsub backend #5730

Open matwerber1 opened 4 years ago

matwerber1 commented 4 years ago

Note: If your feature-request is regarding the AWS Amplify Console service, please log it in the official AWS Amplify Console forum

Is your feature request related to a problem? Please describe.

When using the Amplify PubSub library with AWS IoT, there are several manual steps we need to perform (e.g. create an IoT policy, look up our user's federated identity and run a CLI command to attach the policy to the user, manually look up our account / region-specific AWS IoT endpoint and hardcode into the configuration of the PubSub module).

This is manual and time consuming. I'd like to see a way to do this in an automated fashion.

Describe the solution you'd like

Ideally, I'd like to see an amplify add pubsub command added to the CLI that provides a guided walkthrough (or framework for configuring) the pubsub module.

For example, a question that asks "do you want to use AWS IoT as your pubsub broker?" and if user says yes, the module will:

  1. Look up the AWS IoT endpoint and add to aws-exports.js
  2. Create a local file defining an IoT policy to attach to Federated Identities; the policy definition can later be customized (sort of like the groups feature in Auth module)
  3. Attach the policy to federated identities

Describe alternatives you've considered

Right now, I could add a custom CloudFormation resource type to my amplify project to define the IoT policy. However, this does not address attaching it to my users or how to lookup and dynamically embed the proper IoT endpoint into my code when running PubSub.AddPluggable.

Additional context Add any other context or screenshots about the feature request here.

PatrykMilewski commented 4 years ago

@matwerber1 If you want to achieve it quickly, then consider writing your own plugin for that. Details about creating custom plugins for Amplify are here: https://docs.amplify.aws/cli/plugins