aws-amplify / aws-amplify/amplify-cli
Cannot create Amplify project with containers in regions with fewer than 3 AZs
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### 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](https://github.com/aws-amplify/amplify-cli/blob/91436e81f46ad4e8b8251921bfe8307f0cad2952/packages/amplify-provider-awscloudformation/src/utils/env-level-constructs.ts#L78-L83).
### 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:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Contributor guide
Research direction
Inspect packages/amplify-provider-awscloudformation/src/utils/env-level-constructs.ts at lines 78–83, especially the getEnvironmentNetworkInfo call. Reproduce the failure with a container-based project in us-west-1, then verify that the requested subnet count does not exceed the region's availability zones and that the reported push scenario succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100