Skip to content
Permalink
dc9603d19b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 29 lines (18 sloc) 1.28 KB
#!/bin/bash
aws_acct_id="823003027569"
bucket="internet2-tier-appliance-us-west-1"
vagrant_key=$(aws s3api list-objects --bucket $bucket --query 'reverse(sort_by(Contents[?contains(Key, `vagrant`)], &LastModified))[0].[Key]' --output text | tr -d '\n' )
ova_key=$(aws s3api list-objects --bucket $bucket --query 'reverse(sort_by(Contents[?contains(Key, `ova`)], &LastModified))[0].[Key]' --output text | tr -d '\n' )
echo "Found $vagrant_key"
aws s3api put-object-acl --bucket $bucket --key $vagrant_key --acl public-read
echo "(https://s3-us-west-1.amazonaws.com/$bucket/$vagrant_key)"
echo $(md5sum builds/$vagrant_key)
echo "Found $ova_key"
aws s3api put-object-acl --bucket $bucket --key $ova_key --acl public-read
echo "(https://s3-us-west-1.amazonaws.com/$bucket/$ova_key)"
echo $(md5sum builds/$ova_key)
ami_id=$(aws ec2 describe-images --owners $aws_acct_id --query 'reverse(sort_by(Images[?starts_with(Name, `import-ami`)], &CreationDate))[0].[ImageId]' --output text | tr -d '\n' )
echo "Publishing $ami_id to $aws_acct_id"
ami_image_description=$(aws ec2 describe-images --image-ids $ami_id --query 'Images[0].{Description:Tags[0].Value}')
echo $ami_image_description
aws ec2 modify-image-attribute --image-id $ami_id --launch-permission "{\"Add\":[{\"UserId\":\"$aws_acct_id\"}]}"