Reputation: 435
I am writing a userdata script that generates random strings for a set of SSM parameters. I am getting errors on all parameters except the last and can't understand why. I am thinking that the error is misleading.
Here is part of the script I am referencing:
url="myTestParam"
Params=("SQL_PASS", "WP_PASS", "HTTP_PASS")
for str in ${!Params[@]}
do
echo $str
aws ssm put-parameter --region us-east-1 --profile WPOpsAdmin --name "/qa/${url}/${Params[$str]}" --value $RANDOM --type "SecureString";
done
The output:
0
An error occurred (ValidationException) when calling the PutParameter operation: Parameter name: can't be prefixed with "ssm" (case-insensitive). If formed as a path, it can consist of sub-paths divided by slash symbol; each sub-path can be formed as a mix of letters, numbers and the following 3 symbols .-_
1
An error occurred (ValidationException) when calling the PutParameter operation: Parameter name: can't be prefixed with "ssm" (case-insensitive). If formed as a path, it can consist of sub-paths divided by slash symbol; each sub-path can be formed as a mix of letters, numbers and the following 3 symbols .-_
2 { "Version": 1, "Tier": "Standard" }
So it seems to work correct only for the last index.
Upvotes: 0
Views: 1685
Reputation: 435
Thanks to @markp-fuso for the suggestion. There was faulty syntax in the array.
These changes worked for me
#!/bin/bash
url="myTestParam"
Params=("SQL_PASS" "WP_PASS" "HTTP_PASS")
for str in "${!Params[@]}"
do
echo "$str"
aws ssm put-parameter --region us-east-1 --profile WPOpsAdmin --name "/qa/${url}/${Params[$str]}" --value $RANDOM --type "SecureString";
done
Upvotes: 1