Skip to content

Commit 80c7ab3

Browse files
committed
tfenv check while destroying
1 parent a09567a commit 80c7ab3

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
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.
44

5+
- [Remote-Code-Server](#remote-code-server)
6+
- [Requirements](#requirements)
7+
- [Build Image](#build-image)
8+
- [Environment Variables](#environment-variables)
9+
- [Creating a Remote Server](#creating-a-remote-server)
10+
- [Connecting to Remote Server](#connecting-to-remote-server)
11+
- [Destroying Remote Server](#destroying-remote-server)
12+
- [To Do](#to-do)
13+
514
## Requirements
615

716
* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html)

create.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ if [ ! -d ".terraform" ]; then
6262
terraform init
6363
fi
6464

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

87-
printf "Retrieving Amazon Linux 2 AMI ID for region $TF_VAR_region \n"
87+
printf "Retrieving Amazon Linux 2 AMI ID for region %s \n" "$TF_VAR_REGION"
8888
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')
8989
printf "\nAmazon Linux 2 AMI ID is: $TF_VAR_ami_id_amazon_linux \n\n"
9090

destroy.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ then
77
printf 'tfenv is installed, setting version of terraform \n'
88
tfenv use 0.11.13
99
else
10-
printf 'tfenv is not installed, ensure you are using terraform version 0.11.13 \n'
10+
tf_version=$(terraform version | head -n 1 | awk -F 'v' '{print $2}')
11+
printf 'tfenv is not installed, your terraform version is %s \n' "$tf_version"
12+
printf 'q to quit. enter to continue. \n'
13+
read -n1 answer
14+
if [ "$answer" == 'q' ] || [ "$answer" == 'Q' ]; then
15+
exit 0
16+
fi
1117
fi
1218

1319
if [ -e ".env" ]
1420
then
1521
printf "Reading environment variables \n"
1622
. ./.env
1723
else
18-
printf "Environment (.env) file not found \n"
24+
printf "Environment (.env) file not found, make sure env vars are set. \n"
1925
fi
2026

2127
# Set ami_id_amazon_linux to any value

0 commit comments

Comments
 (0)