Reputation: 61
I am writing a cloudformation script which is supposed to pick the stack name, template body and parameter file from a .txt file for deployment. I would not want the yaml and json file to be edited during a new deployment instead the .txt file should be edited The code is below
aws cloudformation create-stack --stack-name $(<stack_name.txt) --template-body
file://$(<stack_template_file_name.txt) --parameters file://$(<stack_parameter_file_name.txt) capabilities "CAPABILITY_IAM" "CAPABILITY_NAMED_IAM" --region=us-west-2
note: stack_name.txt contains the name to be used the stack, stack_template_file_name.txt contains the name of the template.yml file, stack_parameter_file_name.txt contains the name of the parameter.json file
when I type the command directly in the cli, the stack is deployed but when I copy it into create.sh and run ./create.sh I get the error below
`' doesn't match a supported format.`
How can I fix this?
Upvotes: 1
Views: 4784
Reputation: 2826
In my case I was using Ubuntu Windows Linux Subsystem.
I was getting shell variables from properties
file.
For e.g. My properties file abc.properties
.
#VSRX
region=us-west-1
key_name=cft111
key_location=/var/cft111.pem
My Shell script abc.sh
#!/bin/bash
action=$1
source ./abc.properties
if [[ $action == "create" ]]; then
aws cloudformation deploy \
--template-file abc.yml \
--stack-name ${parent_stack_name} \
--capabilities CAPABILITY_NAMED_IAM \
--region ${region} \
--parameter-overrides KeyName=${key_name}
fi
I faced the similar issue and i tried echoing the command as well and i saw region parameter itself were invisible in echoed command.
To my resolution : it was only formatting issue and i fixed it with below two commands.
sed -i 's/\r$//' abc.sh
sed -i 's/\r$//' abc.properties
Upvotes: 1
Reputation: 664
I just wanted to comment I found the same error from a different issue in the aws CLI.
' doesn't match a supported format.
When running:
aws s3 cp file.txt s3://bucket-name/
The issue was a malformed configuration in the
~/.aws
config folder.
Re-running the
~/.aws configure
command didn't seem to fix the issue
however by inspecting the files in the
~/.aws
folder I was able to remove the random characters that were causing the issue.
Upvotes: 1
Reputation: 61
I found out that it had to do with the EC2 environment, the exact command worked in a Windows and Ubuntu system.
Upvotes: 0