Skip to content

Commit 3ead1ee

Browse files
author
carmat88
committed
Fixing incorrect owner id after aws migration
1 parent 37c2f84 commit 3ead1ee

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

aws_clean_images.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ set -e
88
# Installing necessary tool for the script: awscli
99
pip install -qq awscli --upgrade
1010

11+
# Account/Owner ID (also good for possible future migration)
12+
AWS_OWNER_ID=$(aws sts get-caller-identity --output text --query 'Account')
13+
export AWS_OWNER_ID
14+
1115
# Execute different script only for AWS and before main ones
1216
# Reason is to avoid concurrent APIs call (e.g. deletion of an AMI and checking if that AMI exists)
1317
bash aws_del_old_snaps.sh
@@ -28,7 +32,7 @@ for reg in ${aws_regions[*]}; do
2832

2933
# Extracting both KubeNow images that are flagged as "test" or "current"
3034
# Using tee and wc -l (which often returns 0) because of set -e. In case aws and grep return 1
31-
aws ec2 describe-images --filters "Name=name,Values=kubenow-*-*" "Name=owner-id,Values=105135433346" | tee /tmp/aws_out_images.json
35+
aws ec2 describe-images --filters "Name=name,Values=kubenow-*-*" "Name=owner-id,Values=$AWS_OWNER_ID" | tee /tmp/aws_out_images.json
3236
tot_no_amis=$(grep -i "imageid" </tmp/aws_out_images.json | wc -l)
3337
counter_del_img=0
3438
counter_del_snap=0

aws_del_old_snaps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ for reg in ${aws_regions[*]}; do
1515
echo -e "Current region is: $AWS_DEFAULT_REGION\n"
1616

1717
# Extracting both KubeNow images that are flagged as "test" or "current"
18-
aws ec2 describe-snapshots --owner-ids 105135433346 --query 'Snapshots[*].{ID:SnapshotId,Description:Description}' >/tmp/aws_snaps.json
18+
aws ec2 describe-snapshots --owner-ids "$AWS_OWNER_ID" --query 'Snapshots[*].{ID:SnapshotId,Description:Description}' >/tmp/aws_snaps.json
1919
sed -i '1s/^/{"Snapshots":/' /tmp/aws_snaps.json
2020
sed -i "$ a }" /tmp/aws_snaps.json
2121
tot_no_snaps=$(grep -c -i ID </tmp/aws_snaps.json)

0 commit comments

Comments
 (0)