Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create bucket Bucket name should be between 3 and 63 characters long #2928

Closed
emanuelherrmann opened this issue Dec 5, 2019 · 12 comments
Assignees
Labels
bug Something isn't working storage Issues tied to the storage category wontfix This will not be worked on

Comments

@emanuelherrmann
Copy link

emanuelherrmann commented Dec 5, 2019

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):

  • OS: popOs 18.04
  • Node Version. node -v v10.17.0
@emanuelherrmann emanuelherrmann changed the title Bucket name should be between 3 and 63 characters long Can't create bucket Bucket name should be between 3 and 63 characters long Dec 5, 2019
@emanuelherrmann
Copy link
Author

emanuelherrmann commented Dec 5, 2019

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]. 

@emanuelherrmann
Copy link
Author

emanuelherrmann commented Dec 5, 2019

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"
                    }
                ]
            ]
        }
    ]
},

@ammarkarachi ammarkarachi added bug Something isn't working storage Issues tied to the storage category labels Dec 6, 2019
@ammarkarachi
Copy link
Contributor

@emanuelherrmann Thanks for the updates we will be looking and get back to you

@nikhname
Copy link
Contributor

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?

@nikhname nikhname added the not-reproducible Not able to reproduce the issue label Dec 16, 2019
@emanuelherrmann
Copy link
Author

emanuelherrmann commented Dec 16, 2019

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?

@nikhname nikhname added multienv Issues tied to multiple environment feature in the CLI and removed storage Issues tied to the storage category not-reproducible Not able to reproduce the issue labels Dec 17, 2019
@nikhname
Copy link
Contributor

nikhname commented Dec 17, 2019

@emanuelherrmann could you describe the way you merged your new environment into the prod environment?

@emanuelherrmann
Copy link
Author

Hi @nikhname below is a summary of the steps I followed

  1. I started on my production branch and environment (which was created with an older version of the CLI)
  2. I created a new branch I called amplify env add to create a new env
  3.  I created the bucket and implemented my feature
  4. After my feature was tested I switched the git branch to production
  5. Merged from new branch to production
  6. Run amplify env checkout production
  7. run amplify publish and it gave me the error. 

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"
}
]
}
]
},

@kaustavghosh06 kaustavghosh06 added storage Issues tied to the storage category and removed multienv Issues tied to multiple environment feature in the CLI labels Dec 18, 2019
@edwardfoyle edwardfoyle assigned edwardfoyle and unassigned nikhname Jan 27, 2020
@dkennell
Copy link

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.

@edwardfoyle
Copy link
Contributor

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.

@ahansson89
Copy link

Please provide a general fix for this.

@julien-tamade
Copy link

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.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working storage Issues tied to the storage category wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

8 participants