-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
sam deploy --guided doesn't escape quotation marks for parameters written to samconfig.toml #2034
Comments
Hi @senorkrabs,
|
PR is released. |
This issue should be reopened. Specifying parameter values containing double quotes So, if a value is For example: $ sam --version
SAM CLI, version 1.29.0
$ sam deploy -g --confirm-changeset
Configuring SAM deploy
======================
Looking for config file [samconfig.toml] : Found
Reading default arguments : Success
Setting default arguments for 'sam deploy'
=========================================
Stack Name [myapp-backend]:
AWS Region [us-east-1]:
Parameter DBInstanceClass [db.t3.micro]:
Parameter DBName [mydb]:
Parameter DBAdminUser [admin]:
Parameter DBAdminPassword []: "
Parameter DBWriterPassword []: \
Parameter DBReaderPassword []: ' On the subsequent run, the values are: $ sam deploy -g --confirm-changeset
Configuring SAM deploy
======================
Looking for config file [samconfig.toml] : Found
Reading default arguments : Success
Setting default arguments for 'sam deploy'
=========================================
Stack Name [myapp-backend]:
AWS Region [us-east-1]:
Parameter DBInstanceClass [db.t3.micro]:
Parameter DBName [mydb]:
Parameter DBAdminUser [admin]:
Parameter DBAdminPassword []:
Parameter DBWriterPassword [" DBReaderPassword=]:
Parameter DBReaderPassword []: ^CAborted!
$ grep parameter_overrides samconfig.toml
parameter_overrides = "DBInstanceClass=\"db.t3.micro\" DBName=\"mydb\" DBAdminUser=\"admin\" DBAdminPassword=\"\"\" DBWriterPassword=\"\\\" DBReaderPassword=\"'\"" I've got a use case where I'd like to use strong passwords generated by I've got a script that pre-populates the password values in Escaping |
Also, in reference to #2139, single quotes ( That means a value pre-populated as |
My current working solution is to escape #!/usr/bin/env sh
echo -n "Generating strong passwords for database access and administration"
function pw () {
# Escape \ as \\ and replace " with '
echo $(aws secretsmanager get-random-password --output=text | sed 's/\\/\\\\/g' | sed "s/\"/'/g")
}
p1="DBAdminPassword=\\\"$(pw)\\\"" && echo -n .
p2="DBWriterPassword=\\\"$(pw)\\\"" && echo -n .
p3="DBReaderPassword=\\\"$(pw)\\\"" && echo -n .
echo parameter_overrides = \"$p1 $p2 $p3\" >> samconfig.toml
echo \ done Which works well: $ cat samconfig.toml
version = 0.1
[default]
[default.deploy]
[default.deploy.parameters]
stack_name = "myapp-backend"
$ ./prepare
Generating strong passwords for database access and administration... done
$ sam deploy -g --confirm-changeset
Configuring SAM deploy
======================
Looking for config file [samconfig.toml] : Found
Reading default arguments : Success
Setting default arguments for 'sam deploy'
=========================================
Stack Name [myapp-backend]:
AWS Region [us-east-1]:
Parameter DBInstanceClass [db.t3.micro]:
Parameter DBName [mydb]:
Parameter DBAdminUser [admin]:
Parameter DBAdminPassword [@Tv+lFiB~N7fSUj(7l6?pLkG#Nh:?Z8`]:
Parameter DBWriterPassword [|fS';v,5HA`89{`Bfx),MS9%ZXR(90Y@]:
Parameter DBReaderPassword [SgZ^TVh[d&>xvKmM)L4Nn^yOR/9b>r4O]: However, I would like to be able to have double quotes as well. |
Pending release. |
Description
When using
sam deploy --guided
, parameters with quotation marks"
are written toparameter_overrides
in samconfig.toml without proper escaping. As a result, the parameter isn't correctly populated the next timesam deploy
is called.Steps to reproduce
Run
sam deploy --guided
and use these parameters:Observed result
Written to
samconfig.toml
:What happens when
sam deploy
is called again:(Note that Parameter overrides is incorrect)
Please provide command output with
--debug
flag set.Expected result
Written to
samconfig.toml
:Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 0.52.0Add --debug flag to command you are running
The text was updated successfully, but these errors were encountered: