amplify-cli: Duplicate Pinpoint projects created when creating new Amplify environment (breaks push notifications)

Describe the bug I have a project which uses push notifications. Upon creating a new environment by following the steps outlined here, the Amplify CLI prompts the user for APNS and FCM credentials prior to pushing. After supplying the credentials, the Pinpoint project gets created on AWS. This all happens before pushing the project to the cloud. After successfully going through all the amplify env add steps, and finishing with amplify push, the Amplify CLI creates another Pinpoint project, resulting in 2 Pinpoint projects.

I compared the amplify-meta.json files from my initial env (dev) and my new env (test), and noticed that the new (test) environment has a different output.Id under analytics than the output.Id under notifications. The initial env has the same output IDs for these categories.

This is problematic, because I have 2 Lambda functions which send out push notifications. They both have all the permissions for the ‘analytics’ category. Whenever one of these functions attempts to send a push notification in the test env, it fails because the function has the wrong Pinpoint ID.

Amplify CLI Version @aws-amplify/cli@4.27.1

To Reproduce

  1. Create an Amplify project
  2. Add push notifications
  3. Create a new environment
  4. Witness duplicate Pinpoint project

Expected behavior I expect only one Pinpoint project to be created, and my new enviroment to match my original environment.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macOS Catalina
  • Node Version. v14.4.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 15 (3 by maintainers)

Most upvoted comments

For anyone else facing this issue, the workaround for now is:

  1. Remove Lambda function Analytics category dependencies/permissions
  2. Remove Analytics category
  3. Remove Notifications category
  4. Push changes
  5. Add Analytics category
  6. Push changes
  7. Add Notifications category
  8. Add Lambda function Analytics category dependencies/permissions

After basically removing and re-adding the Analytics and Notifications categories, your new environment will only end up with one shared Pinpoint project.

This is still a problem, even on the latest Amplify CLI.
Makes CI/CD with fresh backend environments really frustrating when anything that depends on Pinpoint starts failing. For me, this breaks anything that touches Pinpoint, (Push,SMS, Analytics etc)

It just happened to us using amplify cli version 7.6.23.

Current workaround when adding a new environment

  • amplify env add NAME - to create the new environment
  • Find the appid in team-provider.json for pinpoint
  • Update amplify/backend/analytics/NAME/parameter.skon and set AppId
  • amplify push