Common Deployment Issues
Below are some common issues you may face while SAM deploying to AWS.
Orphaned S3 Bucket
This is when an s3 bucket is no longer linked to the cloudformation stack but still exists in AWS. Can occur when attempting to delete a populated s3 bucket.
Solution
In order to properly deploy without having to clear and delete the S3 bucket we can import the existing S3 bucket as a resource into the existing stack. To do this we will use IaC generator to generate the modified template file. First navigate in AWS to CloudFormation > IaC generator. Then, scan the AWS account (only if the resource is not already detected otherwise continue). Then generate the template file. Select the current stack as the base template to import and name the template something arbitrary. Then continue and search for the s3 bucket, or other resource, and select it to add it to the template. Finally, save and run the template on the existing stack. This should allow you to deploy normally afterwards.