Skip to content

Commit 930eedd

Browse files
authored
feat: make stack optional (#6)
* feat: make stack optional * feat: add notes in README about TF_PROJECT_NAME
1 parent 181c7d3 commit 930eedd

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ TLDR, but really, go read the post, it's way better then what I'm going to write
77
The Current production [terraform version](https://github.com/FitnessKeeper/terraform-runkeeper#terraform-version) can be found here
88
### To create a new repo using the terraform-reference repo.
99

10-
- Clone the repo `git clone https://github.com/FitnessKeeper/terraform-reference`
11-
- Edit .env in the root of the repo, in particular make sure you add a TF_PROJECT_NAME
10+
- Clone the repo into a new directory for your project `git clone https://github.com/FitnessKeeper/terraform-reference terraform-<project name>`
11+
- Edit .env in the root of the repo, in particular make sure you add a TF_PROJECT_NAME (this should be the new name of the repo, `terraform-<project name>`)
1212
- When creating a `spike` make sure you update TF_SPINE in env if something other then `rk` is needed, at the time of this writing `rk` and `asics` are valid spines.
1313
- Also when creating ASICS `spikes` update to `TF_LOCK_TABLE=asics-services-terraformStateLock`
14+
- If needed, set TF_STACK for the `stack` variable
1415
- Initialize variables.tf, this only needs to be done once, when the repo is created run `./init-variables.tf.sh`
1516
- Remove the old origin `git remote rm origin`
16-
- Add your new repo `git remote add origin https://github.com/FitnessKeeper/terraform-reference.git`
17+
- Add your new repo `git remote add origin https://github.com/FitnessKeeper/terraform-<project name>.git`
1718
- Commit your changes
1819
- `git push -u origin master`
1920
- Edit variables.tf to reflect your new service

init-variables.tf.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ echo $TF_PROJECT_NAME
1313

1414
tf_spine="${TF_SPINE:-rk}"
1515

16+
# Set stack if TF_STACK is set; if not, comment out the stack variable entirely
17+
if [[ "${TF_STACK}" ]] ; then
18+
STACK_VAR_COMMENT_OPTIONAL=""
19+
STACK_VAR_DEFAULT="$TF_STACK"
20+
else
21+
STACK_VAR_COMMENT_OPTIONAL="# "
22+
STACK_VAR_DEFAULT="ref"
23+
fi
24+
1625
export VARIABLES_TF=$(cat <<EOF
1726
# Variables.tf declares has the default variables that are shared by all environments
1827
# \$var.region, \$var.domain, \$var.tf_s3_bucket
@@ -58,7 +67,7 @@ variable "region" { default = "${aws_default_region}" }
5867
5968
# This should be changed to reflect the service / stack defined by this repo
6069
# for example replace "ref" with "cms", "slackbot", etc
61-
variable "stack" { default = "ref" }
70+
${STACK_VAR_COMMENT_OPTIONAL}variable "stack" { default = "${STACK_VAR_DEFAULT}" }
6271
6372
variable "tf_s3_bucket" {
6473
description = "S3 bucket Terraform can use for state"

0 commit comments

Comments
 (0)