mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-10 06:26:57 +02:00
Merge pull request #466 from marineam/share
ami: automatically grant access to AMIs for testing
This commit is contained in:
commit
c0ff1b2965
@ -20,6 +20,8 @@ USAGE="Usage: $0 -a ami-id
|
|||||||
-V VERSION Find AMI by CoreOS version.
|
-V VERSION Find AMI by CoreOS version.
|
||||||
-b BOARD Set to the board name, default is amd64-usr
|
-b BOARD Set to the board name, default is amd64-usr
|
||||||
-g GROUP Set the update group, default is alpha
|
-g GROUP Set the update group, default is alpha
|
||||||
|
-l ACCOUNT Grant launch permission to a given AWS account ID.
|
||||||
|
-r REGION Copy to the specified region, may be repeated.
|
||||||
-h this ;-)
|
-h this ;-)
|
||||||
-v Verbose, see all the things!
|
-v Verbose, see all the things!
|
||||||
|
|
||||||
@ -30,6 +32,7 @@ AMI=
|
|||||||
VER=
|
VER=
|
||||||
BOARD="amd64-usr"
|
BOARD="amd64-usr"
|
||||||
GROUP="alpha"
|
GROUP="alpha"
|
||||||
|
GRANT_LAUNCH=""
|
||||||
REGIONS=()
|
REGIONS=()
|
||||||
|
|
||||||
add_region() {
|
add_region() {
|
||||||
@ -44,13 +47,14 @@ clean_version() {
|
|||||||
sed -e 's%[^A-Za-z0-9()\\./_-]%_%g' <<< "$1"
|
sed -e 's%[^A-Za-z0-9()\\./_-]%_%g' <<< "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "a:V:b:g:r:hv" OPTION
|
while getopts "a:V:b:g:l:r:hv" OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
a) AMI="$OPTARG";;
|
a) AMI="$OPTARG";;
|
||||||
V) VER="$OPTARG";;
|
V) VER="$OPTARG";;
|
||||||
b) BOARD="$OPTARG";;
|
b) BOARD="$OPTARG";;
|
||||||
g) GROUP="$OPTARG";;
|
g) GROUP="$OPTARG";;
|
||||||
|
l) GRANT_LAUNCH="${OPTARG}";;
|
||||||
r) add_region "$OPTARG";;
|
r) add_region "$OPTARG";;
|
||||||
h) echo "$USAGE"; exit;;
|
h) echo "$USAGE"; exit;;
|
||||||
v) set -x;;
|
v) set -x;;
|
||||||
@ -129,6 +133,13 @@ do_copy() {
|
|||||||
while ec2-describe-images "$r_amiid" --region="$r" | grep -q pending; do
|
while ec2-describe-images "$r_amiid" --region="$r" | grep -q pending; do
|
||||||
sleep 30
|
sleep 30
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ -n "${GRANT_LAUNCH}" ]]; then
|
||||||
|
echo "Granting launch permission to ${GRANT_LAUNCH} for $r_amiid in $r"
|
||||||
|
ec2-modify-image-attribute --region="$r" "${r_amiid}" \
|
||||||
|
--launch-permission --add "${GRANT_LAUNCH}"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "AMI $virt_type copy to $r as $r_amiid in complete"
|
echo "AMI $virt_type copy to $r as $r_amiid in complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ IMAGE="coreos_production_ami_image.bin.bz2"
|
|||||||
GS_URL="gs://builds.release.core-os.net"
|
GS_URL="gs://builds.release.core-os.net"
|
||||||
IMG_URL=""
|
IMG_URL=""
|
||||||
IMG_PATH=""
|
IMG_PATH=""
|
||||||
|
GRANT_LAUNCH=""
|
||||||
USE_GPG=1
|
USE_GPG=1
|
||||||
# accepted via the environment
|
# accepted via the environment
|
||||||
: ${EC2_IMPORT_BUCKET:=}
|
: ${EC2_IMPORT_BUCKET:=}
|
||||||
@ -34,6 +35,7 @@ Options:
|
|||||||
-s STORAGE GS URL for Google storage (used to generate URL)
|
-s STORAGE GS URL for Google storage (used to generate URL)
|
||||||
-B BUCKET S3 bucket to use for temporary storage.
|
-B BUCKET S3 bucket to use for temporary storage.
|
||||||
-Z ZONE EC2 availability zone to use.
|
-Z ZONE EC2 availability zone to use.
|
||||||
|
-l ACCOUNT Grant launch permission to a given AWS account ID.
|
||||||
-X Disable GPG verification of downloads.
|
-X Disable GPG verification of downloads.
|
||||||
-h this ;-)
|
-h this ;-)
|
||||||
-v Verbose, see all the things!
|
-v Verbose, see all the things!
|
||||||
@ -41,7 +43,7 @@ Options:
|
|||||||
This script must be run from an ec2 host with the ec2 tools installed.
|
This script must be run from an ec2 host with the ec2 tools installed.
|
||||||
"
|
"
|
||||||
|
|
||||||
while getopts "V:b:g:p:u:s:t:B:Z:Xhv" OPTION
|
while getopts "V:b:g:p:u:s:t:l:B:Z:Xhv" OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
V) VERSION="$OPTARG";;
|
V) VERSION="$OPTARG";;
|
||||||
@ -52,6 +54,7 @@ do
|
|||||||
s) GS_URL="$OPTARG";;
|
s) GS_URL="$OPTARG";;
|
||||||
B) EC2_IMPORT_BUCKET="${OPTARG}";;
|
B) EC2_IMPORT_BUCKET="${OPTARG}";;
|
||||||
Z) EC2_IMPORT_ZONE="${OPTARG}";;
|
Z) EC2_IMPORT_ZONE="${OPTARG}";;
|
||||||
|
l) GRANT_LAUNCH="${OPTARG}";;
|
||||||
t) export TMPDIR="$OPTARG";;
|
t) export TMPDIR="$OPTARG";;
|
||||||
X) USE_GPG=0;;
|
X) USE_GPG=0;;
|
||||||
h) echo "$USAGE"; exit;;
|
h) echo "$USAGE"; exit;;
|
||||||
@ -227,6 +230,14 @@ amiid=$(ec2-register \
|
|||||||
--block-device-mapping /dev/sdb=ephemeral0 |
|
--block-device-mapping /dev/sdb=ephemeral0 |
|
||||||
cut -f2)
|
cut -f2)
|
||||||
|
|
||||||
|
if [[ -n "${GRANT_LAUNCH}" ]]; then
|
||||||
|
echo "Granting launch permission to ${GRANT_LAUNCH}"
|
||||||
|
ec2-modify-image-attribute "${hvm_amiid}" \
|
||||||
|
--launch-permission --add "${GRANT_LAUNCH}"
|
||||||
|
ec2-modify-image-attribute "${amiid}" \
|
||||||
|
--launch-permission --add "${GRANT_LAUNCH}"
|
||||||
|
fi
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
$description
|
$description
|
||||||
architecture: $arch
|
architecture: $arch
|
||||||
|
@ -13,9 +13,9 @@ fi
|
|||||||
set -e
|
set -e
|
||||||
source $DIR/marineam-auth.sh
|
source $DIR/marineam-auth.sh
|
||||||
args="-b $BOARD -g $GROUP -V $VER"
|
args="-b $BOARD -g $GROUP -V $VER"
|
||||||
$DIR/import.sh ${args}
|
$DIR/import.sh -l 477645798544 ${args}
|
||||||
$DIR/test_ami.sh -v ${args}
|
$DIR/test_ami.sh -v ${args}
|
||||||
$DIR/copy_ami.sh ${args}
|
$DIR/copy_ami.sh -l 477645798544 ${args}
|
||||||
|
|
||||||
source $DIR/ami-builder-us-gov-auth.sh
|
source $DIR/ami-builder-us-gov-auth.sh
|
||||||
$DIR/import.sh ${args}
|
$DIR/import.sh ${args}
|
||||||
|
Loading…
Reference in New Issue
Block a user