Skip to content

Commit

Permalink
tfenv check while destroying
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkarim committed Apr 12, 2020
1 parent a09567a commit 80c7ab3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

This repo contains the terraform scripts necessary to create a remote VS Code environment using [code-server](https://github.com/cdr/code-server) on your existing AWS account.

- [Remote-Code-Server](#remote-code-server)
- [Requirements](#requirements)
- [Build Image](#build-image)
- [Environment Variables](#environment-variables)
- [Creating a Remote Server](#creating-a-remote-server)
- [Connecting to Remote Server](#connecting-to-remote-server)
- [Destroying Remote Server](#destroying-remote-server)
- [To Do](#to-do)

## Requirements

* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html)
Expand Down
4 changes: 2 additions & 2 deletions create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if [ ! -d ".terraform" ]; then
terraform init
fi

printf "\nSecure domain value: $secure_domain \n"
printf "\nSecure domain value: %s \n" "$secure_domain"
if [ $secure_domain == false ] && [ ! -e "./server.crt" ] && [ ! -e "./server.key" ]
then
export TF_VAR_protocol=HTTP
Expand All @@ -84,7 +84,7 @@ then
fi
fi

printf "Retrieving Amazon Linux 2 AMI ID for region $TF_VAR_region \n"
printf "Retrieving Amazon Linux 2 AMI ID for region %s \n" "$TF_VAR_REGION"
export TF_VAR_ami_id_amazon_linux=$(aws ec2 describe-images --filters "Name=owner-alias,Values=amazon" "Name=architecture,Values=x86_64" "Name=description,Values='Amazon Linux 2 AMI 2.0.20191024.3 x86_64 HVM gp2'" --profile $TF_VAR_aws_profile --region $TF_VAR_region | jq -r '.Images[].ImageId')
printf "\nAmazon Linux 2 AMI ID is: $TF_VAR_ami_id_amazon_linux \n\n"

Expand Down
10 changes: 8 additions & 2 deletions destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ then
printf 'tfenv is installed, setting version of terraform \n'
tfenv use 0.11.13
else
printf 'tfenv is not installed, ensure you are using terraform version 0.11.13 \n'
tf_version=$(terraform version | head -n 1 | awk -F 'v' '{print $2}')
printf 'tfenv is not installed, your terraform version is %s \n' "$tf_version"
printf 'q to quit. enter to continue. \n'
read -n1 answer
if [ "$answer" == 'q' ] || [ "$answer" == 'Q' ]; then
exit 0
fi
fi

if [ -e ".env" ]
then
printf "Reading environment variables \n"
. ./.env
else
printf "Environment (.env) file not found \n"
printf "Environment (.env) file not found, make sure env vars are set. \n"
fi

# Set ami_id_amazon_linux to any value
Expand Down

0 comments on commit 80c7ab3

Please sign in to comment.