aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Set --no-confirm-changeset when CI=true

Open iRoachie opened this issue 6 years ago • 6 comments

Describe your idea/feature/enhancement

In CI environments, sam deploy will fail if the --no-confirm-changeset is not set. Obviously this precaution makes sense when working locally, but in a CI environment, there's no user interaction available to press Y/n.

When CI=true is present as ci tools will do (travis/github actions/etc) the --no-confirm-changeset should be set to true.

Proposal

On the deploy command, check for the ci environment variable and if it is present and set to true, then attach --no-confirm-changeset to the deploy options.

iRoachie avatar Aug 22 '20 23:08 iRoachie

The feature request here is possible for looking at an ENV variable, but there's a conflict here. By default, we don't ask users to confirm their changesets on deployment. Do you have a samconfig.toml file present? What is the full command you are running?

awood45 avatar Sep 04 '20 21:09 awood45

The command i'm running is sam deploy.

Full output from terminal:

	SAM CLI now collects telemetry to better understand customer needs.

	You can OPT OUT and disable telemetry collection by setting the
	environment variable SAM_CLI_TELEMETRY=0 in your shell.
	Thanks for your help!

	Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html



	Deploying with following values
	===============================
	Stack name                 : ay-sing-lyrics
	Region                     : us-east-1
	Confirm changeset          : True
	Deployment s3 bucket       : aws-sam-cli-managed-default-samclisourcebucket-8vwbkpv8iuy7
	Capabilities               : ["CAPABILITY_IAM"]
	Parameter overrides        : {'VERSION': '0.0.4'}

Initiating deployment
=====================
GetLyricsFunction may not have authorization defined.
Uploading to ay-sing-lyrics/c1115a85feac4905ff4f411984111ba9  43500 / 43500.0  (100.00%)


Waiting for changeset to be created..

CloudFormation stack changeset
------------------------------------------------------------------------------------------------
Operation                        LogicalResourceId                ResourceType                   
------------------------------------------------------------------------------------------------
Uploading to ay-sing-lyrics/fd11935cbda09582db2447653c4643b0.template  1649 / 1649.0  (100.00%)
* Modify                         GetLyricsFunctionLyricsApiEven   AWS::Lambda::Permission        
                                 tPermission                                                     
* Modify                         GetLyricsFunction                AWS::Lambda::Function          
* Modify                         LyricsAPIApiGatewayDefaultStag   AWS::ApiGatewayV2::Stage       
                                 e                                                               
* Modify                         LyricsAPI                        AWS::ApiGatewayV2::Api         
------------------------------------------------------------------------------------------------

Changeset created successfully. arn:aws:cloudformation:us-east-1:755806416572:changeSet/samcli-deploy1598136712/0f50ba79-a681-4b87-84d5-de1222a0a965


Previewing CloudFormation changeset before deployment
======================================================
Aborted!
Deploy this changeset? [y/N]: 
##[error]Process completed with exit code 1.

iRoachie avatar Sep 04 '20 21:09 iRoachie

Sorry guys. I just realized that the default samconfig.toml created by the --guided flag is what sets the confirm_changeset to true.

iRoachie avatar Sep 04 '20 21:09 iRoachie

Had the same issue, you just need to make sure in your samconfig.toml, under [default.deploy.parameters] it has confirm_changeset = false

zeenotheinventor avatar Apr 14 '23 15:04 zeenotheinventor

It is very frustrating that the default hello-world sam templates need so many changes to actually work. I have been troubleshooting the template for more than 3-4 hours, first the package versions are not working, then the commands themselves are conflicting by default. Please maintain your templates.

cmoutafidis avatar Apr 20 '23 12:04 cmoutafidis

Same. This is killing me. The bookkeeping required for permissions, setting up IAC, GitHub actions, and all that is hard enough to manage without working templates. I get that AWS isn't meant for small-time developers, but when choosing a platform to adopt to scale a project up, it doesn't help AWS' credibility when something doesn't work out of the box.

dmlambo avatar Aug 26 '23 13:08 dmlambo