amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

AuthMode in Amplify Config is incorrect when using old Amplify config format (`--config-version 0`)

Open Jordan-Nelson opened this issue 1 year ago • 0 comments

Environment information

System:
  OS: macOS 13.6.6
  CPU: (10) arm64 Apple M1 Pro
  Memory: 175.64 MB / 32.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
  Yarn: 1.22.19 - ~/.nvm/versions/node/v18.16.0/bin/yarn
  npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
  pnpm: 8.6.11 - ~/Library/pnpm/pnpm
NPM Packages:
  @aws-amplify/backend: 1.0.2
  @aws-amplify/backend-cli: 1.0.3
  aws-amplify: 6.3.2
  aws-cdk: 2.142.1
  aws-cdk-lib: 2.142.1
  typescript: 5.4.5
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Description

Steps to reproduce:

  1. Create new app. In my case I am using a Flutter app (flutter create my_amplify_app) but I think this is likely reproducible on all platforms
  2. Run npm create amplify@latest to create the backend
  3. Deploy the app in sandbox with the standard config. For Flutter: npx ampx sandbox --outputs-format dart --outputs-out-dir lib
  4. Observe lib/amplify_outputs.dart contains the following under "data" for auth modes. Observe that authorization_types contains "AMAZON_COGNITO_USER_POOLS"
"default_authorization_type": "AWS_IAM",
"authorization_types": [
  "AMAZON_COGNITO_USER_POOLS"
],
  1. Deploy the app in sandbox with the old config. For Flutter: npx ampx sandbox --outputs-format dart --outputs-out-dir lib --config-version 0
  2. Observe that lib/amplifyconfiguration.dart contains the following under "AppSync". Observe that data_AMAZON_COGNITO_USER_POOLS.AuthMode is "AWS_IAM". "AMAZON_COGNITO_USER_POOLS" is not listed as an auth mode.
"Default": {
  "ApiUrl": "https://<id>.appsync-api.us-east-1.amazonaws.com/graphql",
  "Region": "us-east-1",
  "AuthMode": "AWS_IAM",
  "ClientDatabasePrefix": "data_AWS_IAM"
},
"data_AMAZON_COGNITO_USER_POOLS": {
  "ApiUrl": "https://<id>.appsync-api.us-east-1.amazonaws.com/graphql",
  "Region": "us-east-1",
  "AuthMode": "AWS_IAM",
  "ClientDatabasePrefix": "data_AMAZON_COGNITO_USER_POOLS"
}

Expected behavior: Both config formats should contain an auth mode of "AMAZON_COGNITO_USER_POOLS".

Actual behavior: "AMAZON_COGNITO_USER_POOLS" is only listed as an auth mode when using the new config.

Jordan-Nelson avatar May 22 '24 21:05 Jordan-Nelson