Skip to content

Instantly share code, notes, and snippets.

@Maniacal
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maniacal/6b164f59be9d7a064b9f to your computer and use it in GitHub Desktop.
Save Maniacal/6b164f59be9d7a064b9f to your computer and use it in GitHub Desktop.
## Here's the block_mappings snippet where I'm setting that up and the part of the script where I create the build command
===========================================================================================================================
block_mappings='[{\"DeviceName\":\"/dev/xvdf\",\"Ebs\":{\"VolumeSize\":100,\"VolumeType\":\"gp2\",\"DeleteOnTermination\":false}},{\"DeviceName\":\"/dev/xvdg\",\"Ebs\":{\"VolumeSize\":1000,\"VolumeType\":\"gp2\",\"DeleteOnTermination\":false}}]'
# Create the build command
build_command="aws ec2 run-instances --image-id $image_id --key-name $key_name --security-group-ids $security_group_ids --instance-type $instance_type --subnet-id ${subnet_ids[$i]} --iam-instance-profile Name=${env_prefix}-wallet-server --user-data file://${env_prefix}_wallet.sh"
if [[ "$environment" != development ]]; then
build_command="$build_command --block-device-mappings \"$block_mappings\""
fi
# Run the build command
echo "Running build command:"
echo "$build_command"
$build_command
## OUTPUT when run
===================
Running build command:
aws ec2 run-instances --image-id ami-76817c1e --instance-type m3.large --block-device-mappings "[{\"DeviceName\":\"/dev/xvdf\",\"Ebs\":{\"VolumeSize\":100,\"VolumeType\":\"gp2\",\"DeleteOnTermination\":false}}]"
Error parsing parameter '--block-device-mappings': Invalid JSON:
### If I copy/paste that output'd command it runs fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment