Amplify-cli: Need ability to specify AWS Region for Pinpoint

Created on 3 Aug 2019  路  7Comments  路  Source: aws-amplify/amplify-cli

Revisiting a feature request from #817, but with additional context.

Cognito User Pools allows customers to send auth events to a Pinpoint project. However, I found out that it only allows a customer to send events to projects in the us-east-1 region, regardless of the region in which the User Pool resides.

In order to have amplify CLI manage a Pinpoint project used to receive auth events, the options I see are:

  1. Create all resources in us-east-1
  2. Manually edit the awsconfiguration.json file to add the Pinpoint project configuration (which they have to do anyway to add the Pinpoint appId to the config. This would be persisted across amplify push invocations, but the project would not be a fully-fledged managed resource.
  3. Add a CLI feature allowing the customer to override a region for their Pinpoint project during creation, or afterwards with a configure
  4. Add a CLI feature allowing the customer to import a manually-created Pinpoint project into their amplify backend, where the resource may be in a different region than the "main" CFn stack

This is tangentially related to #513, which mapped services to available regions; any feature developed from this request would have to consider service availability as well.

analytics enhancement

Most helpful comment

Any news about this? I am also experiencing the same case.

So far I have created pinpoint resources in us-east-1 manually and then I have referenced them in the app with Amplify.configure(Analytics:{..}), but I am interested in having Amplify automatically generating these resources in us-east-1 even if my app region is eu-west-1, so that I do not have to manage different environment variables and different environment configurations by myself (I currently have dev, test, and master, environments).

All 7 comments

Running into this issue as well, trying to configure PinPoint to region ap-southeast-2.

Any news about this? I am also experiencing the same case.

So far I have created pinpoint resources in us-east-1 manually and then I have referenced them in the app with Amplify.configure(Analytics:{..}), but I am interested in having Amplify automatically generating these resources in us-east-1 even if my app region is eu-west-1, so that I do not have to manage different environment variables and different environment configurations by myself (I currently have dev, test, and master, environments).

Any news about this? I am also experiencing the same case.

So far I have created pinpoint resources in us-east-1 manually and then I have referenced them in the app with Amplify.configure(Analytics:{..}), but I am interested in having Amplify automatically generating these resources in us-east-1 even if my app region is eu-west-1, so that I do not have to manage different environment variables and different environment configurations by myself (I currently have dev, test, and master, environments).

Sorry if this is too late but for anyone who is interested you just need to create a profile in us-east-1 from amplify configure and in amplify init stage select that profile and when you do amplify add analytics it will create the pinpoint resource in that region.

Any news about this? I am also experiencing the same case.
So far I have created pinpoint resources in us-east-1 manually and then I have referenced them in the app with Amplify.configure(Analytics:{..}), but I am interested in having Amplify automatically generating these resources in us-east-1 even if my app region is eu-west-1, so that I do not have to manage different environment variables and different environment configurations by myself (I currently have dev, test, and master, environments).

Sorry if this is too late but for anyone who is interested you just need to create a profile in us-east-1 from amplify configure and in amplify init stage select that profile and when you do amplify add analytics it will create the pinpoint resource in that region.

Hi,
A quick snippet of example code would be very helpful @wvyeun. Trying to keep all my resources where they are now ( in us-west-1 ) and to work around the limitation of Analytics being able to send events to pinpoint only in us-east-1, I want to create my pinpoint in us-east-1 via amplify. Am using Cognito User Pools if that makes any difference. Thanks !

Any news about this? I am also experiencing the same case.
So far I have created pinpoint resources in us-east-1 manually and then I have referenced them in the app with Amplify.configure(Analytics:{..}), but I am interested in having Amplify automatically generating these resources in us-east-1 even if my app region is eu-west-1, so that I do not have to manage different environment variables and different environment configurations by myself (I currently have dev, test, and master, environments).

Sorry if this is too late but for anyone who is interested you just need to create a profile in us-east-1 from amplify configure and in amplify init stage select that profile and when you do amplify add analytics it will create the pinpoint resource in that region.

Hi,
A quick snippet of example code would be very helpful @wvyeun. Trying to keep all my resources where they are now ( in us-west-1 ) and to work around the limitation of Analytics being able to send events to pinpoint only in us-east-1, I want to create my pinpoint in us-east-1 via amplify. Am using Cognito User Pools if that makes any difference. Thanks !

INSTRUCTIONS ON MANUAL SETUP

In the CLI
$ npm install -g @aws-amplify/cli@latest
$ npx create-react-app amplify-app
$ cd amplify-app
$ amplify init
$ npm install aws-amplify

  • Paste the following in App.js
import React from 'react';
import Amplify, { Analytics } from "aws-amplify";
import './App.css';

function App() {
  const analytics = () => {
      Amplify.configure({
        Auth: {
          identityPoolId: "youridentitypoolid",
          region: "identitypoolidregion",
        },
        Analytics: {
          disabled: false,
          AWSPinpoint: {
            appId: "pinpointprojectidhere",
            region: "us-east-1",
          },
        },
      });
    Analytics.record("Test");
    window.LOG_LEVEL = 'DEBUG';
  };
  return (
    <div className="App">
      {analytics()}
      <header className="App-header">
        <p>
          Hola from Amplify
        </p>

      </header>
    </div>
  );
}

export default App;

As a final step In cli

$ amplify push

  • Navigate to Pinpoint console > Analytics > Usage - you should see some activity coming in there

INSTRUCTIONS ON INTEGRATION VIA CLI

https://docs.amplify.aws/start/getting-started/setup/q/integration/react#create-a-new-react-app

$ npm install -g @aws-amplify/cli@latest
$ amplify configure

  • Configure a profile in us-east-1
  • Follow CLI prompts and when directed to console make note of access key and secret key from console

$ npx create-react-app pinpoint-amplify
$ cd pinpoint-amplify
$ amplify init

  • Go through configuration. At the 'Please choose profile step choose the previously created profile in us-east-1. After the configurations you will see an amplify folder created under src folder.
    $ npm install aws-amplify
    $ amplify add analytics

    1. Provide resource name 2. Enter Yes for unauthenticated

      amplify push

  • Press Yes
  • this should create a aws-exports file inside src folder
  • Once completed there should be a pinpoint url created in us-east-1

Now inside the app

  • When you look in the root of your project folder there should be a folder called amplify
  • Inside the src folder should be a aws-exports file.

In your App.js add the following Import statements.

import React from 'react';
import Amplify, { Analytics } from "aws-amplify";
import awsconfig from './aws-exports';
import './App.css';
Amplify.configure(awsconfig);

function App() {
  const analytics = () => {
    Analytics.record("Test");
  };
  return (
    <div className="App">
      {analytics()}
    </div>
  );
}

export default App;
  • Navigate to Pinpoint url > Analytics > Usage - You should see some activity coming in

It should create pinpoint project in region where amplify is created ideally

I follwed as @wvyeun suggested but ended up making a new amplify app.
Making a new profile and amplify configure project in existing project didn't work either.

I had to manually change the region value in the pinpoint-cloud-....json file like below.

"Mappings": {
        "RegionMapping": {
            "us-east-1": {
                "pinpointRegion": "ap-northeast-2"  // it was us-east-1 or us-west-2 whatever the region I didn't wanted. So I changed it to ap-northeast-2
            },
            "us-east-2": {
                "pinpointRegion": "ap-northeast-2"
            },
            "sa-east-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "ca-central-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "us-west-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "us-west-2": {
                "pinpointRegion": "ap-northeast-2"
            },
            "cn-north-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "cn-northwest-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "ap-south-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "ap-northeast-3": {
                "pinpointRegion": "ap-northeast-2"
            },
            "ap-northeast-2": {
                "pinpointRegion": "ap-northeast-2"
            },
            "ap-southeast-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "ap-southeast-2": {
                "pinpointRegion": "ap-northeast-2"
            },
            "ap-northeast-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "eu-central-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "eu-west-1": {
                "pinpointRegion": "ap-northeast-2"
            },
            "eu-west-2": {
                "pinpointRegion": "ap-northeast-2"
            },
            "eu-west-3": {
                "pinpointRegion": "ap-northeast-2"
            }
        }
    }

Now it creates pinpoint at ap-northeast-2 region but not sure if it has any side effects.
ughh.. so tired of doing workaround to avoid unwanted settings using amplify...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

undefobj picture undefobj  路  78Comments

DonPepone picture DonPepone  路  70Comments

rygo6 picture rygo6  路  93Comments

kaustavghosh06 picture kaustavghosh06  路  51Comments

mikeparisstuff picture mikeparisstuff  路  48Comments