aws-amplify / amplify-cli

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

Cannot create Amplify project with containers in regions with fewer than 3 AZs #13904

Open palpatim opened 3 months ago

palpatim commented 3 months ago

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

No response

Amplify CLI Version

12.12.6

What operating system are you using?

macOS

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

N/A

Describe the bug

Attempting to create an Amplify project, with containers, in regions with fewer than 3 AZs results in an error: The requested number of subnets exceeds the number of AZs for the region. This appears to be because of a hardcoded value for the subnets argument to getEnvironmentNetworkInfo in env-level-constructs.ts.

Expected behavior

The number of requested subnets does not exceed the number of availability zones for the selected region.

Reproduction steps

  1. Initialize a new Amplify project in a region with < 3 availability zones (e.g., us-west-1)
  2. Add container support with amplify configure projects > Advanced: Container-based deployments
  3. Add a containerized API with amplify add api > REST > API Gateway + AWS Fargate (Container-based) > (accept defaults for remaining options)
  4. amplify push -y

Project Identifier

0ef4cab727ef3e2dd0a288133a105af9

Log output

``` 2024-08-28T16:29:54.915Z|info : amplify add api 2024-08-28T16:29:54.994Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({} 2024-08-28T16:30:07.403Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["personal"]) 2024-08-28T16:30:07.406Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"credential_process":"","region":"us-west-1"}]) 2024-08-28T16:30:12.437Z|info : amplify status core {"yes":false} 2024-08-28T16:30:12.515Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({} 2024-08-28T16:30:13.758Z|info : amplify-provider-awscloudformation.display-helpful-urls.showCognitoSandBoxMessage(["containeraztest"]) 2024-08-28T16:30:23.944Z|info : amplify push core {"yes":true} 2024-08-28T16:30:24.025Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({} 2024-08-28T16:30:25.443Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["personal"]) 2024-08-28T16:30:25.446Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"credential_process":"","region":"us-west-1"}]) 2024-08-28T16:30:25.455Z|info : amplify-provider-awscloudformation.zip-util.downloadZip.s3.getFile([{"Key":"[***]rent-[***]ud-[***]d.zip"},null]) 2024-08-28T16:30:25.456Z|info : amplify-provider-awscloudformation.aws-s3.s3.getFile([{"Key":"[***]rent-[***]ud-[***]d.zip","Bucket":"[***]ify-[***]aztest-[***]ev-[***]74-[***]ment"}]) 2024-08-28T16:30:25.766Z|info : amplify-provider-awscloudformation.initialize-env.run.cfn.updateamplifyMetaFileWithStackOutputs([{"StackName":"[***]ify-[***]aztest-[***]ev-[***]74"}]) 2024-08-28T16:30:25.767Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["personal"]) 2024-08-28T16:30:25.769Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"credential_process":"","region":"us-west-1"}]) 2024-08-28T16:30:25.778Z|info : amplify-provider-awscloudformation.aws-cfn.updateamplifyMetaFileWithStackOutputs.cfn.listStackResources([{"StackName":"[***]ify-[***]aztest-[***]ev-[***]74"}]) 2024-08-28T16:30:26.078Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]ify-[***]aztest-[***]ev-[***]74"}]) 2024-08-28T16:30:26.363Z|info : amplify-provider-awscloudformation.aws-s3.s3.getFile([{"Key":"[***]ify-[***]json","Bucket":"[***]ify-[***]aztest-[***]ev-[***]74-[***]ment"}]) 2024-08-28T16:30:26.811Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["personal"]) 2024-08-28T16:30:26.812Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"credential_process":"","region":"us-west-1"}]) 2024-08-28T16:30:27.043Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["personal"]) 2024-08-28T16:30:27.044Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"credential_process":"","region":"us-west-1"}]) 2024-08-28T16:30:27.481Z|error : The requested number of subnets exceeds the number of AZs for the region. { "subnets": 3, "azs": 2 } ConfigurationError: The requested number of subnets exceeds the number of AZs for the region. { "subnets": 3, "azs": 2 } 2024-08-28T16:31:39.010Z|info : amplify diagnose core {"send-report":true,"yes":false} 2024-08-28T16:31:39.091Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({} ```

Additional information

No response

Before submitting, please confirm: