Skip to content
Permalink
Newer
Older
100755 26 lines (15 sloc) 1.05 KB
1
#!/bin/bash
2
3
aws_acct_id="823003027569"
villadalmine
Nov 15, 2016
4
aws_acct_id_plus="886593122405"
5
6
bucket="internet2-tier-appliance-us-west-1"
7
8
ova_key=$(aws s3api list-objects --bucket $bucket --query 'reverse(sort_by(Contents[?contains(Key, `ova`)], &LastModified))[0].[Key]' --output text | tr -d '\n' )
Jim Van Fleet
Sep 6, 2016
9
10
echo "Found $ova_key"
11
aws s3api put-object-acl --bucket $bucket --key $ova_key --acl public-read
12
Jim Van Fleet
Sep 6, 2016
13
echo "(https://s3-us-west-1.amazonaws.com/$bucket/$ova_key)"
14
15
echo $(md5sum builds/$ova_key)
Jim Van Fleet
Sep 6, 2016
16
17
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' )
villadalmine
Nov 15, 2016
18
villadalmine
Nov 15, 2016
19
echo "Publishing $ami_id to all accounts"
Jim Van Fleet
Sep 6, 2016
20
21
ami_image_description=$(aws ec2 describe-images --image-ids $ami_id --query 'Images[0].{Description:Tags[0].Value}')
22
echo $ami_image_description
23
Jim Van Fleet
Sep 6, 2016
24
aws ec2 modify-image-attribute --image-id $ami_id --launch-permission "{\"Add\":[{\"UserId\":\"$aws_acct_id\"}]}"
villadalmine
Nov 15, 2016
25
aws ec2 modify-image-attribute --image-id $ami_id --launch-permission "{\"Add\":[{\"UserId\":\"$aws_acct_id_plus\"}]}"
You can’t perform that action at this time.