-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_create_newrelic_resources.sh
50 lines (42 loc) · 1.01 KB
/
00_create_newrelic_resources.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Get commandline arguments
while (( "$#" )); do
case "$1" in
--destroy)
flagDestroy="true"
shift
;;
--dry-run)
flagDryRun="true"
shift
;;
*)
shift
;;
esac
done
### Set variables
# cluster name
clusterName="my-dope-cluster"
if [[ $flagDestroy != "true" ]]; then
# Initialize Terraform
terraform -chdir=../terraform init
# Plan Terraform
terraform -chdir=../terraform plan \
-var NEW_RELIC_ACCOUNT_ID=$NEWRELIC_ACCOUNT_ID \
-var NEW_RELIC_API_KEY=$NEWRELIC_API_KEY \
-var NEW_RELIC_REGION=$NEWRELIC_REGION \
-var cluster_name=$clusterName \
-out "./tfplan"
# Apply Terraform
if [[ $flagDryRun != "true" ]]; then
terraform -chdir=../terraform apply tfplan
fi
else
# Destroy Terraform
terraform -chdir=../terraform destroy \
-var NEW_RELIC_ACCOUNT_ID=$NEWRELIC_ACCOUNT_ID \
-var NEW_RELIC_API_KEY=$NEWRELIC_API_KEY \
-var NEW_RELIC_REGION=$NEWRELIC_REGION \
-var cluster_name=$clusterName
fi