Skip to content

Commit

Permalink
Added explicit reference to AWS_REGION env var in build script
Browse files Browse the repository at this point in the history
  • Loading branch information
binarymist committed Jul 20, 2020
1 parent 55595aa commit 758667d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 4 additions & 5 deletions buildAndDeployCloudImages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# AWS_REGION
# AWS_PROFILE
# AWS_ACCOUNT_ID

export $(egrep -v '^#' .env | xargs)

echo
Expand All @@ -26,7 +25,7 @@ docker tag nodegoat_web:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com

echo "The following images are currently in the suts/nodegoat repository..............................."
echo
echo $(aws ecr list-images --repository-name suts/nodegoat --filter tagStatus=ANY --output json --query 'imageIds[*]') | jq
echo $(aws ecr list-images --region $AWS_REGION --repository-name suts/nodegoat --filter tagStatus=ANY --output json --query 'imageIds[*]') | jq
echo

echo "Pushing the new images............................................................................"
Expand All @@ -35,20 +34,20 @@ docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/suts/nodegoat:late
echo
echo "After pushing, the following images are currently in the suts/nodegoat repository................"
echo
echo $(aws ecr list-images --repository-name suts/nodegoat --filter tagStatus=ANY --output json --query 'imageIds[*]') | jq
echo $(aws ecr list-images --region $AWS_REGION --repository-name suts/nodegoat --filter tagStatus=ANY --output json --query 'imageIds[*]') | jq
echo
echo "Waiting 8 seconds for untagging..."
sleep 8
echo "Deleting the following old (untagged) images in the suts/nodegoat repository....................."
echo
untagedNodeGoatImages=$(aws ecr list-images --repository-name suts/nodegoat --filter tagStatus=UNTAGGED --output json --query 'imageIds[*]')
untagedNodeGoatImages=$(aws ecr list-images --region $AWS_REGION --repository-name suts/nodegoat --filter tagStatus=UNTAGGED --output json --query 'imageIds[*]')
echo $untagedNodeGoatImages | jq
echo
aws ecr batch-delete-image --repository-name suts/nodegoat --image-ids "$untagedNodeGoatImages"

echo
echo "The following images are left in the suts/nodegoat repository...................................."
echo
nodeGoatImages=$(aws ecr list-images --repository-name suts/nodegoat --filter tagStatus=ANY --output json --query 'imageIds[*]')
nodeGoatImages=$(aws ecr list-images --region $AWS_REGION --repository-name suts/nodegoat --filter tagStatus=ANY --output json --query 'imageIds[*]')
echo $nodeGoatImages | jq

6 changes: 2 additions & 4 deletions tf/roots/1_static/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ variable "AWS_PROFILE" {
type = string
}

variable "AWS_ACCOUNT_ID" {
description = "Not used. Is here to stop Terraform warnings."
}

provider "aws" {
profile = var.AWS_PROFILE
# Bug: region shouldn't be required but is: https://github.com/terraform-providers/terraform-provider-aws/issues/7750
region = var.AWS_REGION
}

variable "AWS_ACCOUNT_ID" { description = "Not used. Is here to stop Terraform warnings." }

variable "cloudflare_account_id" {
description = "Used in cloudflare provider. Not used in this root."
type = string
Expand Down

0 comments on commit 758667d

Please sign in to comment.