I'm initiating a sam project with sam init and immediately call sam build and sam deploy -g afterwards. When I fill in the steps the following way I get the error. Not sure if I'm missing something in my aws account setup or what, yet I'm able to deploy if I do it manually - call sam package and sam deploy with manually giving the required fields.
~/1/a/sam $ sam init -r nodejs12.x
Which template source would you like to use?
1 - AWS Quick Start Templates
2 - Custom Template Location
Choice: 1
Project name [sam-app]: hello-world
Cloning app templates from https://github.com/awslabs/aws-sam-cli-app-templates.git
-----------------------
Generating application:
-----------------------
Name: hello-world
Runtime: nodejs12.x
Dependency Manager: npm
Application Template: hello-world
Output Directory: .
Next steps can be found in the README file at ./hello-world/README.md
~/1/a/sam $ cd hello-world/
~/1/a/s/hello-world $ sam build
Building resource 'HelloWorldFunction'
Running NodejsNpmBuilder:NpmPack
Running NodejsNpmBuilder:CopyNpmrc
Running NodejsNpmBuilder:CopySource
Running NodejsNpmBuilder:NpmInstall
Running NodejsNpmBuilder:CleanUpNpmrc
Build Succeeded
Built Artifacts : .aws-sam/build
Built Template : .aws-sam/build/template.yaml
Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Deploy: sam deploy --guided
~/1/a/s/hello-world $ sam deploy -g --debug
Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
Configuring SAM deploy
======================
Looking for samconfig.toml : Not found
Setting default arguments for 'sam deploy'
=========================================
Stack Name [sam-app]: HelloWordSamStack
AWS Region [us-east-1]: eu-central-1
#Shows you resources changes to be deployed and require a 'Y' to initiate deploy
Confirm changes before deploy [y/N]: N
#SAM needs permission to be able to create roles to connect to the resources in your template
Allow SAM CLI IAM role creation [Y/n]: Y
No Parameters detected in the template
2 resources found in the template
Found Serverless function with name='HelloWorldFunction' and CodeUri='HelloWorldFunction'
Detected Inline Swagger definition
Auth checks done on swagger are not exhaustive!
HelloWorldFunction may not have authorization defined, Is this okay? [y/N]: y
Save arguments to samconfig.toml [Y/n]: Y
Looking for resources needed for deployment: Found!
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam deploy', 'duration': 29557, 'exitReason': 'UserException', 'exitCode': 1, 'requestId': 'eb649800-de68-4d33-934c-d03ee3e88d08', 'installationId': '1239613e-49d3-45ba-8b31-fc799e972190', 'sessionId': 'dd2a893b-88cc-46cc-bf9d-69883795dece', 'executionEnvironment': 'CLI', 'pyversion': '3.6.9', 'samcliVersion': '0.48.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: Stack aws-sam-cli-managed-default exists, but the ManagedStackSource tag is missing. Failing as the stack was likely not created by the AWS SAM CLI.
I expected a smooth deploy of the initiated sam project.
sam --version: 0.48.0Looks like the stack used for managing all the built artifacts, aws-sam-cli-managed-default already exists in the account you are deploying, but somehow is not tagged as such. Was this stack created externally and not through sam cli? If so, that could be the case.
One option to unblock would be add "ManagedStackSource" tag to the stack with a value of AwsSamCli
For anyone else hitting this error, deleting the "aws-sam-cli-managed-default" CloudFormation stack (status was stuck at "Review in progress") and re-running sam deploy -g worked for me.
Most helpful comment
For anyone else hitting this error, deleting the "aws-sam-cli-managed-default" CloudFormation stack (status was stuck at "Review in progress") and re-running
sam deploy -gworked for me.