Skip to content
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

CloudFormation CLI parameters parsing issue #2392

Closed
stuffandthings opened this issue Jan 18, 2017 · 8 comments
Closed

CloudFormation CLI parameters parsing issue #2392

stuffandthings opened this issue Jan 18, 2017 · 8 comments
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.

Comments

@stuffandthings
Copy link

stuffandthings commented Jan 18, 2017

I'm unable to pass an ssh key in as a comma-delimitted-string and get parsing errors. I've iterated through a couple of times and get slightly different parsing errors, below is a list of the command run and the error I get:

aws cloudformation create-stack --stack-name box --template-body file://template.yaml --parameters ParameterKey=GitSshKey,ParameterValue=-----BEGIN RSA PRIVATE KEY-----,private,key,-----END RSA PRIVATE KEY-----	

Error parsing parameter '--parameters': Expected: '=', received: 'EOF' for input:
        RSA
 	^

Next I tried to wrap the Parameter with ". Note that it added single quotes inside the parameter value (after BEGIN and before KEY)

aws cloudformation create-stack --stack-name box --template-body file://template.yaml --parameters "ParameterKey=GitSshKey,ParameterValue=-----BEGIN' RSA PRIVATE KEY-----,private,key,-----END RSA PRIVATE 'KEY-----"

Error parsing parameter '--parameters': Expected: '=', received: '"' for input:
 	"ParameterKey=GitSshKey,ParameterValue=-----BEGIN
 	^

I also tried to surround the ParameterKey=..,ParameterValue.. block in single quotes ', with the actual RSA key surrounded with double quotes ". Again, note the added 's after BEGIN and before KEY.

aws cloudformation create-stack --stack-name box --template-body file://template.yaml --parameters 'ParameterKey=GitSshKey,ParameterValue="-----BEGIN' RSA PRIVATE KEY-----,private,key,-----END RSA PRIVATE 'KEY-----"'

Error parsing parameter '--parameters': Expected: '<double quoted>', received: '<none>' for input:
 	ParameterKey=GitSshKey,ParameterValue="-----BEGIN
 	                                      ^

I have also tried escaping the ,s with a \ to no avail. How do I pass a key as comma separated with spaces using the CLI tool?

@stuffandthings
Copy link
Author

I've also tried passing it as a json blob, but it seems to cut it off after some number of characters, so I can't pass all my parameters.

aws cloudformation create-stack --stack-name box --template-body file://template.yaml --parameters '[{"ParameterKey":"SecurityGroupName","ParameterValue":"sec-group"},{"ParameterKey":"VpcId","ParameterValue":"vpc-id"},{"ParameterKey":"InstanceName","ParameterValue":"box"},{"ParameterKey":"SalsifyIp","ParameterValue":"192.168.1.1/32"},{"ParameterKey":"ImageId","ParameterValue":"ami-0000"},{"ParameterKey":"InstanceSize","ParameterValue":"t2.small"},{"ParameterKey":"Environment","ParameterValue":"env"},{"ParameterKey":"Category","ParameterValue":"cat"},{"ParameterKey":"SubCategory","ParameterValue":"subcat"},{"ParameterKey":"Platform","ParameterValue":"plat"},{"ParameterKey":' '"GitSshKey","ParameterValue":' '"-----BEGIN' RSA PRIVATE KEY-----,secret,key,goes,here,-----END RSA PRIVATE 'KEY-----"}]'
 	
 	Error parsing parameter '--parameters': Invalid JSON:
 	[{"ParameterKey":"SecurityGroupName","ParameterValue":"sec-group"},{"ParameterKey":"VpcId","ParameterValue":"vpc-id"},{"ParameterKey":"InstanceName","ParameterValue":"box"},{"ParameterKey":"SalsifyIp","ParameterValue":"192.168.1.1/32"},{"ParameterKey":"ImageId","ParameterValue":"ami-0000"},{"ParameterKey":"InstanceSize","ParameterValue":"t2.small"},{"ParameterKey":"Environment","ParameterValue":"env"},{"ParameterKey":"Category","ParameterValue":"cat"},{"ParameterKey":"SubCategory","ParameterValue":"sub-cat"},{"ParameterKey":"Platform","ParameterValue":"plat"},{"ParameterKey":

@kyleknap
Copy link
Contributor

@stuffandthings

Have you tried something like this?

aws cloudformation create-stack --stack-name box \
   --template-body file://template.yaml \
   --parameters ParameterKey=GitSshKey,ParameterValue="'-----BEGIN RSA PRIVATE KEY-----,private,key,-----END RSA PRIVATE KEY-----'"

The single quotes ensure to use the literal value and the double quotes should ensure that spaces are not interpreted as additional values in --parameters. That worked for me when I tried it.

@kyleknap kyleknap added closing-soon This issue will automatically close in 4 days unless further comments are made. question labels Jan 18, 2017
@stuffandthings
Copy link
Author

stuffandthings commented Jan 18, 2017

I get the same issue:

Error parsing parameter '--parameters': Expected: '<double quoted>', received: '<none>' for input:
 	ParameterKey=GitSshKey,ParameterValue="'-----BEGIN
 	                                      ^	

@stuffandthings
Copy link
Author

Is there a character limit to how long the parameters can be?

@stuffandthings
Copy link
Author

FWIW, I'm using Jenkins as an interface to deploy my CloudFormation template. I don't want to check in my GitHub Deploy Key into a cf_input.json parameters file, and so I'm exposing a UI form to enter this key into.

@kyleknap
Copy link
Contributor

There is no limit on the value you can provide to the CLI command. So it may be a limit in the Jenkins interface. What OS are you running this on? Also could you run the command with --debug (and make sure you have the sensitive material stripped out)? That can tell you at least what exact value is getting passed in to the CLI.

@stuffandthings
Copy link
Author

Hm. I'll try the debug flag. I'm getting the same issue if I run the command locally, so it seems unlikely that it's a limitation with my Jenkins interface.

@stuffandthings
Copy link
Author

stuffandthings commented Jan 18, 2017

Ah, Doing ParameterKey=GitSshKey,ParameterValue='"key,here"' worked locally but not through Jenkins. Going to close this now and debug my build server. Thanks!

@diehlaws diehlaws added guidance Question that needs advice or information. and removed question labels Jan 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants