Skip to content

Amplify CLI "Cannot read properties of undefined (reading 'Region')" when adding new environment

0

I am unable to create a new Amplify environment using the CLI. Every time I run amplify env add and enter a new environment name, I get the error: Cannot read properties of undefined (reading 'Region')

What I’ve tried:

Clean clone of my repo Reduced team-provider-info.json to only the main (master) environment Verified region is set everywhere (eu-west-1) Tried all authentication methods (Amplify Studio, AWS profile, access keys) Upgraded to Amplify CLI 14.0.0 Tried on multiple machines and OS users Manually edited config files as suggested in GitHub issue #12493 The Amplify Console does not show a "Create new environment" option for this app amplify env list only shows master Session Identifiers from CLI errors:

f5d770da-00bb-42b1-9091-9b83b07a9933 a22fc270-c2df-4476-b4fe-d786abb2bb06 AppId: d20z0issneg3fj Region: eu-west-1 CLI Version: 14.0.0

This is blocking all feature development and safe testing for my production SaaS app. Is there any way to fix this without starting a new Amplify app? Any help or official workaround would be greatly appreciated!

1 Answer
0

Based on the information provided, it appears you're encountering an issue with the Amplify CLI where it cannot read the Region property. This error typically occurs when there's a configuration problem with Amplify.

From your description, this could be related to how Amplify is configured in your project. Here are some potential solutions:

  1. Check your Amplify configuration files:
  • Ensure that your amplify/.config/project-config.json file has the correct region specified
  • Verify that your amplify/team-provider-info.json file has the proper structure with region information
  1. Try setting the AWS region explicitly as an environment variable before running Amplify commands:
export AWS_REGION=eu-west-1

Or for PowerShell:

$Env:AWS_REGION="eu-west-1"
  1. Check your Amplify configuration format:
  • If you're using Amplify Gen 2, make sure your configuration includes the proper nesting structure. For Auth configuration, for example, you might need to nest your settings under "Cognito" like this:
Auth: {
Cognito: {
region: 'eu-west-1',
// other properties
}
}
  1. Try initializing a new environment with the --yes flag to use default settings:
amplify env add --yes
  1. As a last resort, you might need to:
  • Back up your current Amplify configuration
  • Remove the Amplify directory (amplify)
  • Reinitialize Amplify with amplify init
  • Import your existing environment with amplify env import

If these solutions don't work, you might need to contact AWS Support as there could be an issue with your specific Amplify app configuration that requires more detailed investigation.
Sources
Amplify Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'configure') | AWS re:Post
Uncaught TypeError: Cannot read properties of undefined (reading 'loginWith') at AmplifyClass.notifyOAuthListener (Amplify.ts:63:49) | AWS re:Post
AWS CloudShell Concepts - AWS CloudShell

answered a year ago
  • Thank you for your suggestions. I have already tried all of these steps, including:

    Verifying that project-config.json and team-provider-info.json have the correct region (eu-west-1) and structure. Setting AWS_REGION and AWS_DEFAULT_REGION as environment variables. Using amplify env add --yes (same error). Attempting all authentication methods (Amplify Studio, AWS profile, access keys). Clean cloning the repo and reducing team-provider-info.json to only the master environment. Manually editing config files as suggested in GitHub issue #12493. The Amplify Console does not show a "Create new environment" option for this app, to provide an alternative I am not using Amplify Gen 2. The error persists in all cases: Cannot read properties of undefined (reading 'Region') This appears to be a bug in the Amplify CLI or a backend metadata issue with my Amplify app. Is there any official fix or workaround that does not require starting a new Amplify app? Any help from AWS engineering would be greatly appreciated, as this is blocking all development for my production app.

    Thank you!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.