Bash JSON string into variable
Put quotes around $JSON:
aws iam create-login-profile --cli-input-json "$JSON"
The quotes that are there during the assignment get consumed by the shell. You can verify this by issuing echo $JSON
.By adding the quotes you will make sure that the entire string is passed to the command "aws" as a single argument.