Describe the bug
amplify init allows duplicate environments to be created locally that will fail on first amplify push. Ideally, it should detect this and fail on init.
To Reproduce
Steps to reproduce the behavior:
amplify push. Choose a name for the environment, say "dupenv"git checkout master (without merging the other branch)amplify init, and choose "dupenv" (or the same as you chose before) as the env name. Operation succeedsamplify push - this will fail with an error including something like:CREATE_FAILED S3Bucket...
projectname-20190103155640-hostingbucket-dupenv already exists
Expected behavior
Amplify should be able to detect this issue and fail on step 3 (init) with a more helpful error: "that environment name is already in use in stack arn:xxxx...". If you want to go further, amplify could offer to import the environment.
Additional context
This will only occur between unmerged branches. It is more likely if a developer wants to create an environment that they can reuse or in the context of learning amplify itself.
This might fit work-wise with #2364, which also relates to environment name validation.
@kaustavghosh06 I'd like to tack onto this issue, the user should be given the option to have sub-resources be suffixed with the environment name. When we briefly used multi-env (will pick it back up when it's ready for primetime!), the NONE env and a named environment that we copied from NONE resulted in sub-resources with identical names. So e.g. there's two AppSync endpoints with identical names corresponding to different multi-envs.
@jkeys-ecg-nmsu I beleive that issue was fixed. Not the API names get suffixed with environment name (except the NONE envornment).
I haven't deleted the CF stack created by multi-env, so I didn't have insight into your latest patches.
Does your team plan to deprecate the single environment CLI when the multi-env is deemed stable?
@jkeys-ecg-nmsu Yes, we're planning to do that soon.
I've also been running into what appears to be the issue described here. However, I'm not sure this is directly related to environment name duplication. Shouldn't the timestamp (20190103155640) in the hostingbucket name be regenerated for new environments preventing the environment name conflict?
We're resorting to resolving this by manually creating (using an updated timestamp) the "amplify/backend/hosting/S3AndCloudFront/parameters.json" when adding new environments and placing that file in the .gitignore to keep the environment specific data out of the repo.
A couple ideas for solving this (bug?):
Most helpful comment
@jkeys-ecg-nmsu Yes, we're planning to do that soon.