Permalink
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Sep 6, 2016
Sep 13, 2016
Sep 6, 2016
Sep 6, 2016
Newer
100755
29 lines (18 sloc)
1.28 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

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

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

25
ami_image_description=$(aws ec2 describe-images --image-ids $ami_id --query 'Images[0].{Description:Tags[0].Value}')
26
echo $ami_image_description
27

28
aws ec2 modify-image-attribute --image-id $ami_id --launch-permission "{\"Add\":[{\"UserId\":\"$aws_acct_id\"}]}"

29