Skip to content

Commit

Permalink
15 improve developer experience by restructuring files (#16)
Browse files Browse the repository at this point in the history
* initial structure, docs upcoming

* updated readme to match new structure

* updated to pingone v1.0.0

* comments for clarity
  • Loading branch information
samir-gandhi authored Jul 21, 2024
1 parent 3cba3f3 commit c1a206f
Show file tree
Hide file tree
Showing 22 changed files with 236 additions and 454 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/prune.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

- run: |-
_tfdir=terraform/dev
_tfdir=terraform
echo $TERRAFORM_ENV_BASE64 | base64 -d > tfvars
source tfvars
echo "base: ${GITHUB_BASE_REF}"
Expand All @@ -32,5 +32,9 @@ jobs:
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=dev/${TF_VAR_pingone_environment_name}/terraform.tfstate"
terraform -chdir=${_tfdir} destroy --auto-approve
-backend-config="key=${TF_VAR_tf_state_key_prefix}/dev/${TF_VAR_pingone_environment_name}/terraform.tfstate"
terraform -chdir=${_tfdir} destroy \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=${TF_VAR_tf_state_key_prefix}/dev/${TF_VAR_pingone_environment_name}/terraform.tfstate" \
--auto-approve
26 changes: 18 additions & 8 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
_branch="${GITHUB_BASE_REF}"
case "${_branch}" in
"prod")
_tfdir=terraform/prod
_tfdir=terraform
;;
"qa")
_tfdir=terraform/qa
_tfdir=terraform
;;
*)
echo "ERROR: Unknown target branch: ${_branch}"
Expand All @@ -62,18 +62,23 @@ jobs:
echo $TERRAFORM_ENV_BASE64 | base64 -d > tfvars
source tfvars
_branch="${GITHUB_BASE_REF}"
_tfdir=terraform
export TF_VAR_pingone_environment_name="${_branch}"
case "${_branch}" in
"prod")
_tfdir=terraform/prod
_stateKey=${TF_VAR_tf_state_key_prefix}/prod/terraform.tfstate
;;
"qa")
_tfdir=terraform/qa
_stateKey=${TF_VAR_tf_state_key_prefix}/qa/terraform.tfstate
;;
*)
echo "ERROR: Unknown target branch: ${_branch}"
exit 1
esac
terraform -chdir=${_tfdir} init
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=${_stateKey}"
echo "***Running terraform validate***"
terraform -chdir=${_tfdir} validate
Expand Down Expand Up @@ -105,17 +110,22 @@ jobs:
echo $TERRAFORM_ENV_BASE64 | base64 -d > tfvars
source tfvars
_branch="${GITHUB_BASE_REF}"
_tfdir=terraform
export TF_VAR_pingone_environment_name="${_branch}"
case "${_branch}" in
"prod")
_tfdir=terraform/prod
_stateKey="${TF_VAR_tf_state_key_prefix}/prod/terraform.tfstate"
;;
"qa")
_tfdir=terraform/qa
_stateKey="${TF_VAR_tf_state_key_prefix}/qa/terraform.tfstate"
;;
*)
echo "ERROR: Unknown target branch: ${_branch}"
exit 1
esac
terraform -chdir=${_tfdir} init
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=${_stateKey}"
echo "***Running terraform plan***"
terraform -chdir=${_tfdir} plan
50 changes: 17 additions & 33 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,24 @@ jobs:
- run: |-
echo $TERRAFORM_ENV_BASE64 | base64 -d > tfvars
source tfvars
_tfdir=""
_tfdir=terraform
_branch=$(echo "${GITHUB_REF}" | sed -e "s#refs/heads/##g")
export TF_VAR_pingone_environment_name=${_branch}
case $_branch in
prod)
_tfdir=terraform/prod
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=prod/terraform.tfstate"
_stateKey="${TF_VAR_tf_state_key_prefix}/prod/terraform.tfstate"
;;
qa)
_tfdir=terraform/qa
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=qa/terraform.tfstate"
_stateKey="${TF_VAR_tf_state_key_prefix}/qa/terraform.tfstate"
;;
*)
_tfdir=terraform/dev
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=dev/${TF_VAR_pingone_environment_name}/terraform.tfstate"
_stateKey="${TF_VAR_tf_state_key_prefix}/dev/${_branch}/terraform.tfstate"
;;
esac
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=${_stateKey}"
echo "***Running terraform validate***"
terraform -chdir=${_tfdir} validate
Expand All @@ -90,31 +82,23 @@ jobs:
- run: |-
echo $TERRAFORM_ENV_BASE64 | base64 -d > tfvars
source tfvars
_tfdir=""
_tfdir=terraform
_branch=$(echo "${GITHUB_REF}" | sed -e "s#refs/heads/##g")
export TF_VAR_pingone_environment_name=${_branch}
case $_branch in
prod)
_tfdir=terraform/prod
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=prod/terraform.tfstate"
_stateKey="${TF_VAR_tf_state_key_prefix}/prod/terraform.tfstate"
;;
qa)
_tfdir=terraform/qa
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=qa/terraform.tfstate"
_stateKey="${TF_VAR_tf_state_key_prefix}/qa/terraform.tfstate"
;;
*)
_tfdir=terraform/dev
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=dev/${TF_VAR_pingone_environment_name}/terraform.tfstate"
_stateKey="${TF_VAR_tf_state_key_prefix}/dev/${_branch}/terraform.tfstate"
;;
esac
terraform -chdir=${_tfdir} init \
-backend-config="bucket=$TF_VAR_tf_state_bucket" \
-backend-config="region=$TF_VAR_tf_state_region" \
-backend-config="key=${_stateKey}"
echo "***Running terraform apply***"
terraform -chdir=${_tfdir} apply --auto-approve
terraform -chdir=${_tfdir} apply --auto-approve
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DEV_DIR:=./terraform/dev
DEV_DIR:=./terraform
default: devcheck

fmt:
Expand Down
Loading

0 comments on commit c1a206f

Please sign in to comment.