Permalink
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Newer
100755
26 lines (16 sloc)
1.13 KB

1
#!/bin/bash
2
3
aws_acct_id="823003027569"
4
bucket="internet2-tier-appliance-us-west-1"

5
vagrant_key=$(aws s3api list-objects --bucket $bucket --query 'reverse(sort_by(Contents[?contains(Key, `vagrant`)], &LastModified))[0].[Key]' --output text | tr -d '\n' )
6
ova_key=$(aws s3api list-objects --bucket $bucket --query 'reverse(sort_by(Contents[?contains(Key, `ova`)], &LastModified))[0].[Key]' --output text | tr -d '\n' )

7
8
echo "Found $vagrant_key"
9
aws s3api put-object-acl --bucket $bucket --key $vagrant_key --acl public-read
10

11
echo "(https://s3-us-west-1.amazonaws.com/$bucket/$vagrant_key)"
12
13
echo $(md5 builds/$vagrant_key)
14

15
echo "Found $ova_key"
16
aws s3api put-object-acl --bucket $bucket --key $ova_key --acl public-read
17

18
echo "(https://s3-us-west-1.amazonaws.com/$bucket/$ova_key)"
19
20
echo $(md5 builds/$ova_key)
21

22
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' )

23
echo "Publishing $ami_id to $aws_acct_id"
24
25
aws ec2 modify-image-attribute --image-id $ami_id --launch-permission "{\"Add\":[{\"UserId\":\"$aws_acct_id\"}]}"

26