aws-sam-cli: sam deploy --guided errors with "S3 Bucket does not exist"
Description
Using sam deploy --guided
, the process fails with “Error: S3 Bucket does not exist.”
Steps to reproduce
- A developer deployed this stack using
sam deploy --guided --template-file realtime.yaml
. - Output: Deploying with following values =============================== Stack name : askAroundMe-realtime Region : us-east-1 Confirm changeset : False Deployment s3 bucket : aws-sam-cli-managed-default-samclisourcebucket-kll3li4nzc9r Capabilities : [“CAPABILITY_IAM”] Parameter overrides : {}
Initiating deployment
Error: S3 Bucket does not exist.
Provide steps to replicate.
The developer has also renamed the template to template.yaml to avoid the template parameter, with the same result. Then tried after deleting the toml file with the same result.
Observed result
sam deploy –guided Deploying with following values
Stack name : askAroundMe-realtime
Region : us-east-1
Confirm changeset : False
Deployment s3 bucket : aws-sam-cli-managed-default-samclisourcebucket-kll3li4nzc9r
Capabilities : ["CAPABILITY_IAM"]
Parameter overrides : {}
Initiating deployment
Error: S3 Bucket does not exist.
Expected result
The sam deployment should create a deployment bucket and complete.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS:
sam --version
:
Add --debug flag to command you are running
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (2 by maintainers)
In addition to the bucket, a sam deployment also creates two cloudformation stacks. One for keeping track of SAM CLI resources, and the other to track the app’s resources. Try deleting these as well.
Okay I see. This is what happened to me:
sam
sam deploy --guided
it told me it had found the necessary resources for deployment. Meaning, it found the stacksam deploy --guided
. This recreated the sam deployment bucket and deploy worked.Deleting the aws-sam-cli-managed-default stack on cloudformation console fixed this for me
SAM looks up a cloudformation stack with the name
aws-sam-cli-managed-default
link` first, and then looks for bucket within the output of that stack.This worked for me. Thanks a lot. Go to
CloundFormation
Service -> deleteaws-sam-cli-managed-default
stackCan someone expand on this? In my case, runing
sam deploy --guided
, sam appears to disregard a custom bucket already defined insamconfig.toml
.Also running
sam deploy
when params3_bucket
is defined insamconfig.toml
recreates Error: S3 Bucket does not exist. It doesn’t look too different from this issueThe
sam deploy --guided
process looks for a CloudFormation stack, rather than the bucket, to decide whether or not to create a new bucket (S3 API doesn’t give us a good way to search by tags, for example, and since S3 bucket names need to be globally unique this is the approach we need to take). If you’re going to delete the S3 bucket, you’ll also need to delete the associated stack.You can, of course, always provide your own S3 bucket via
samconfig.toml
or as a parameter to deployments.Given that this was filed on another developer’s behalf, I think the question would be what the contents of the
aws-sam-cli-managed-default
template are, and if there is a bucket present there and this error persists, please reopen this issue. Otherwise, delete the stack and re-run.Were you able to figure this out? This is happening to me because I deleted the S3 bucket that SAM created on AWS when I first ran
sam deploy --guided
, but now it’s not recreating that bucket. I’m wondering if there is a way to reset SAM, but deleting the.aws-sam
and~/.aws-sam
directories did not work.