From 09d818893c9b3acc52d9df3b4970cae1512ea615 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Sat, 29 Mar 2014 16:43:25 +0100 Subject: [PATCH] MT#6257 Support --public option to mark AMIs as public available --- ec2-create-ce | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ec2-create-ce b/ec2-create-ce index cecfe3c..191e7c2 100755 --- a/ec2-create-ce +++ b/ec2-create-ce @@ -32,12 +32,14 @@ Supported OPTIONS: (if unset defaults to m1.medium) --ngcp-release sip:provider release version (if unset defaults to ) + --public Make AMI available to the public + (if unset defaults to private) --region specify region that should be used (if unset defaults to the eu-west-1 zone) " } -CMDLINE_OPTS=base-ami:,help,instance-type:,ngcp-release:,region: +CMDLINE_OPTS=base-ami:,help,instance-type:,ngcp-release:,public,region: _opt_temp=$(getopt --name $0 -o +bch --long $CMDLINE_OPTS -- "$@") if [ $? -ne 0 ]; then @@ -46,6 +48,8 @@ if [ $? -ne 0 ]; then fi eval set -- "$_opt_temp" +_opt_public=false + while :; do case "$1" in --base-ami) @@ -60,6 +64,9 @@ while :; do --ngcp-release) shift; NGCP_RELEASE="$1" ;; + --public) + _opt_public=true + ;; --region) shift; AWS_REGION="$1" ;; @@ -210,6 +217,15 @@ else exit 1 fi +if $_opt_public ; then + echo "Marking AMI as public" + ec2-modify-image-attribute "$AMI-ID" --launch-permission -a all + if [ $? -ne 0 ] ; then + echo "Noticed problem when trying to mark AMI with ID $AMI_ID as public." >&2 + exit 1 + fi +fi + echo "*** Debugging information ***" echo "--- user-data-file ---" cat "$USER_DATA_FILE"