forked from cogini/multi-env-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_env.sh.sample
59 lines (48 loc) · 1.89 KB
/
set_env.sh.sample
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
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# Configure for the environment
# Input env variables
# ENV: environment, e.g. `dev`, `stage`, `demo`, `prod`
if [ -z "$ENV" ]; then
echo "error: Environment var ENV not set" >&2
fi
# Organization that the app runs under, e.g. company or project
export ORG=cogini
# Application, group of services
export APP=foo
# Creator of resources, e.g. "ops" or a developer
export OWNER=jake
# Per org + environment
export AWS_PROFILE="$ORG-$ENV"
# Per app + environment
# export AWS_PROFILE="$APP-$ENV"
# Default region
# Location where Packer will build AMI
export AWS_REGION="${AWS_REGION:-us-east-1}"
export AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-us-east-1}"
#####################################################
# Terraform
# EC2 keypair used when creating instances
export TF_VAR_keypair_name=$ORG-$ENV
# export TF_VAR_keypair_name=$APP-$ENV
# Set Terraform vars matching the env vars
export TF_VAR_env=$ENV
# export TF_VAR_org=$ORG
export TF_VAR_app_name=$APP
# Create versions of app name with different conventions
# Default name is expected to be hyphen
export TF_VAR_app_name_hyphen=$APP
# export TF_VAR_app_name_underscore=$(echo "$APP" | tr '-' '_')
# export TF_VAR_app_name_alpha=$(echo "$APP" | tr -d -c '[a-zA-Z0-9]')
export TF_VAR_owner=$OWNER
# Name and location of Terraform state tracking bucket
export TF_VAR_remote_state_s3_bucket_name="${ORG}-${TF_VAR_app_name_hyphen}-${ENV}-tfstate"
export TF_VAR_remote_state_s3_bucket_name_prefix="${ORG}-${TF_VAR_app_name_hyphen}"
export TF_VAR_remote_state_s3_key_prefix="${ENV}/"
#export TF_VAR_remote_state_s3_key_prefix="${TF_VAR_app_name_hyphen}/${ENV}"
# Keep the Terraform state in a single place, no matter where the resources are.
# China is the exception due to slow network performance.
if [[ $ENV = *"china"* ]]; then
export TF_VAR_remote_state_s3_bucket_region=cn-north-1
else
export TF_VAR_remote_state_s3_bucket_region=us-east-1
fi