Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the
Amplify Console GitHub Issue Tracker
Describe the bug
Can't create a bucket
Amplify CLI Version
You can use amplify -v to check the amplify cli version on your system
amplify -v
4.5.0
The project was created with an earlier version of the CLI (not sure which one)
To Reproduce
Steps to reproduce the behavior or terminal output if applicable
amplify add storage
? Please select from one of the below mentioned services: Content (Images, audio, video, etc.)
? Please provide a friendly name for your resource that will be used to label this category in the project: s326a12cbf
? Please provide bucket name: testadminrolee5d2d1154a9c49cd8670eae587a9ba1c
? Who should have access: Auth users only
? What kind of access do you want for Authenticated users? create/update
? Do you want to add a Lambda Trigger for your S3 Bucket? No
Successfully added resource s326a12cbf locally
amplify push --yes
Expected behavior
It should create the bucket, but it giving me this message
CREATE_FAILED S3Bucket AWS::S3::Bucket Thu Dec 05 2019 16:27:16 GMT+1300 (New Zealand Daylight Time) Bucket name should be between 3 and 63 characters long
â ¦ Updating resources in the cloud. This may take a few minutes...
CREATE_FAILED testadminrole-dev-20191010090338-storages326a12cbf-YQJZ0LXBU0J0 AWS::CloudFormation::Stack Thu Dec 05 2019 16:27:17 GMT+1300 (New Zealand Daylight Time) The following resource(s) failed to create: [S3Bucket].
â ‡ Updating resources in the cloud. This may take a few minutes...
CREATE_FAILED storages326a12cbf AWS::CloudFormation::Stack Thu Dec 05 2019 16:27:19 GMT+1300 (New Zealand Daylight Time) Embedded stack arn:aws:cloudformation:us-east-1:268930017986:stack/testadminrole-dev-20191010090338-storages326a12cbf-YQJZ0LXBU0J0/1e426f00-170f-11ea-86b1-12505ef78976 was not successfully created: The following resource(s) failed to create: [S3Bucket].
UPDATE_ROLLBACK_IN_PROGRESS testadminrole-dev-20191010090338 AWS::CloudFormation::Stack Thu Dec 05 2019 16:27:20 GMT+1300 (New Zealand Daylight Time) The following resource(s) failed to create: [storages326a12cbf].
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional info If I don't use the defaults It gives me a different error
amplify storage add
? Please select from one of the below mentioned services: Content (Images, audio, video, etc.)
? Please provide a friendly name for your resource that will be used to label this category in the project: files
? Please provide bucket name: admin
? Who should have access: Auth users only
? What kind of access do you want for Authenticated users? create/update
? Do you want to add a Lambda Trigger for your S3 Bucket? No
Successfully added resource files locally
amplify push
CREATE_FAILED S3Bucket AWS::S3::Bucket Thu Dec 05 2019 16:31:00 GMT+1300 (New Zealand Daylight Time) Bucket name should not contain uppercase characters
CREATE_FAILED winedabquestionnaire-20190530173537-storagefiles-Q7RVG3W850PY AWS::CloudFormation::Stack Thu Dec 05 2019 16:31:01 GMT+1300 (New Zealand Daylight Time) The following resource(s) failed to create: [S3Bucket].
To get around the issue I temporarily edited the cloud formation template taking the stack name out of the bucket name and it worked.
Attached cloud formation templates (original and edited) as txt files because github does not let me to upload json files
s3-cloudformation-template - original .txt
s3-cloudformation-template - edited .txt
"S3Bucket": {
"Type": "AWS::S3::Bucket",
"DeletionPolicy" : "Retain",
"Properties": {
"BucketName": {
"Fn::If": [
"ShouldNotCreateEnvResources",
{
"Ref": "bucketName"
},
{
"Fn::Join": [
"",
[
{
"Ref": "bucketName"
},
{
"Fn::Select": [
3,
{
"Fn::Split": [
"-",
{
"Ref": "AWS::StackName"
}
]
}
]
},
"-",
{
"Ref": "env"
}
]
]
}
]
},
@emanuelherrmann Thanks for the updates we will be looking and get back to you
Hi @emanuelherrmann I was unable to reproduce this using the same bucket name and a 10 character env name. What was BucketName in your amplify-meta file?
Hi @nikhname
I did had the bucket name in the amplify-meta.json
I think it has to do with the fact that is using the 4th element of the stack name split for the bucket name.
I think the issue happened because I created the project and the production environment with an older version of the cli.
Then i added a new environment because I wanted to do a lot of changes I was using version 4.5.0 of the cli at that time that's when I created the bucket and it worked in the new environment. But when I merged the changes into the production environment I got the error "Bucket name should not contain uppercase characters ".
This is exacted from my team-provider-info.json (See the stack names)
"production": {
"awscloudformation": {
...
"StackName": "winedabquestionnaire-20190515135000",
...
},
"eherrmann": {
"awscloudformation": {
...
"StackName": "amplify-winedabquestionnaire-eherrmann-124307",
...
}, ...
'eherrrmann' was the new env I created with 4.5.0 so the stack name has a 4th element if you split by '-', but in case of production it doesn't so that returns undefined and apparently the cli uses random uppercase characters in that case which causes the bucket name to have uppercase characters and fail while creating the bucket.
Am I doing something wrong? How do I Keep my production up to date when amplify updates the cli?
@emanuelherrmann could you describe the way you merged your new environment into the prod environment?
Hi @nikhname below is a summary of the steps I followed
After that, I tried to create the bucket directly in the production env (reverting the merge first ), but it gave me the error as well. The only workaround I found was to remove the following from the bucket name in the cloud formation template.
{
"Fn::Select": [
3,
{
"Fn::Split": [
"-",
{
"Ref": "AWS::StackName"
}
]
}
]
},
I had this problem too, on a greenfield project. Once I started using a custom bucket name instead of the suggested default (the one w/ the long UUID), everything worked fine.
Hi @emanuelherrmann I have been able to repro this issue but we have decided not to move forward with a general fix for it. You are correct that the issue arises because the old version of the CLI generated stack names with a different format than newer versions.
To work around the issue, we recommend that you change the selection index in the S3 CloudFormation template to be the number component of the stack name listed in team-provider-info.json (in your case I think this would be index 1). Or you can remove that part of the CFN template altogether as you mentioned above. However this may have adverse effects if someone clones your Amplify project into another account and uses the same environment name because S3 bucket names must be globally unique.
Sorry we aren't able to work on a fix at this time. However, if more people run into this migration issue we may revisit that decision in the future.
Please provide a general fix for this.
I'm running into a related issue regarding capitalized letters in the Resource Name (AppStorage) with the bucket name set to "app-storage". My new environment was able to create an s3 bucket no problem, even with the resource name being capitalized, but my old environment, my production environment wasn't able to create the bucket because it said there were capital letters in the bucket name. The cloudformation templates are the same between the two and I'm not sure how to fix it.
Most helpful comment
Please provide a general fix for this.