-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PLAT-6822: Node pool,cluster, infra isolation (#113) * PLAT-6823: Node pool,cluster, infra segregation * [DOM-49677] Initial commit submodule (#126) * PLAT-7142: CDK to TF migration support. --------- Co-authored-by: Luis De Bello <[email protected]>
- Loading branch information
1 parent
6ff5ab2
commit 42d64b4
Showing
168 changed files
with
4,687 additions
and
1,913 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
version: 2.1 | ||
|
||
parameters: | ||
workspace: | ||
type: string | ||
default: circleci-<< pipeline.number >> | ||
helm_version: | ||
type: string | ||
default: "v3.11.2" | ||
terraform_version: | ||
type: string | ||
default: "1.4.4" | ||
hcledit_version: | ||
type: string | ||
default: "0.2.9" | ||
GHA_Actor: | ||
type: string | ||
default: "" | ||
|
@@ -26,14 +26,6 @@ orbs: | |
envsubst: sawadashota/[email protected] | ||
|
||
commands: | ||
set_tf_vars: | ||
description: "Sets Terraform variables" | ||
steps: | ||
- run: | ||
name: Configure terraform vars | ||
working_directory: tests | ||
command: | | ||
envsubst < ci.tfvars.tftpl | tee terraform.tfvars | ||
install_tf: | ||
description: "Install Terraform" | ||
parameters: | ||
|
@@ -42,6 +34,45 @@ commands: | |
steps: | ||
- terraform/install: | ||
terraform_version: << parameters.terraform_version >> | ||
install_hcledit: | ||
description: "Install HCL edit" | ||
parameters: | ||
hcledit_version: | ||
type: string | ||
default: "0.2.9" | ||
steps: | ||
- run: | ||
name: Install HCL edit | ||
working_directory: tests/deploy | ||
environment: | ||
HCLEDIT_VERSION: << parameters.hcledit_version >> | ||
command: bash ci-deploy.sh install_hcledit | ||
set_current_mod_source: | ||
description: "Set up module source to current branch." | ||
steps: | ||
- run: | ||
name: "Set module source to current branch" | ||
working_directory: tests/deploy | ||
command: bash ci-deploy.sh set_mod_src_circle_branch | ||
set_aws_creds: | ||
description: "Sets short-lived creds" | ||
steps: | ||
- aws-cli/setup: | ||
role-arn: "${AWS_IAM_ROLE}" | ||
session-duration: "900" | ||
set_tf_vars: | ||
description: "Sets Terraform variables" | ||
steps: | ||
- envsubst/install | ||
- install_hcledit | ||
- set_aws_creds | ||
- run: | ||
name: Bootstrap terraform module/vars. | ||
working_directory: tests/deploy | ||
command: | | ||
bash ci-deploy.sh setup_modules | ||
bash ci-deploy.sh set_tf_vars | ||
- set_current_mod_source | ||
install_helm: | ||
description: "Install Helm" | ||
parameters: | ||
|
@@ -50,71 +81,67 @@ commands: | |
steps: | ||
- run: | ||
name: Install Helm | ||
working_directory: tests/deploy | ||
environment: | ||
HELM_VERSION: << parameters.helm_version >> | ||
command: | | ||
if [ -z "$HELM_VERSION" ]; then | ||
echo "HELM_VERSION environment variable not set, exiting." | ||
exit 1 | ||
fi | ||
echo "Installing Helm version: ${HELM_VERSION}" | ||
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | ||
chmod +x get_helm.sh | ||
./get_helm.sh --version "${HELM_VERSION}" | ||
rm ./get_helm.sh | ||
helm version --short | ||
gen_pvt_key: | ||
description: "Generates ssh key" | ||
steps: | ||
- run: | ||
name: Generate pvt key | ||
command: ssh-keygen -q -P '' -t rsa -b 4096 -m PEM -f tests/domino.pem | ||
command: bash ci-deploy.sh install_helm | ||
tf_init_apply: | ||
description: "Terraform init" | ||
steps: | ||
- aws-cli/setup: | ||
role-arn: "${AWS_IAM_ROLE}" | ||
session-duration: "43200" | ||
- run: | ||
name: Terraform init/validate/apply | ||
working_directory: tests | ||
working_directory: tests/deploy | ||
command: | | ||
echo "Current dir: $(pwd)" | ||
terraform init | ||
terraform validate | ||
terraform workspace new ${WORKSPACE} | ||
terraform apply -auto-approve | ||
## Most of this verbiage will go away after release. | ||
set -e | ||
echo "Current dir: $PWD" | ||
if [ -f "migrated.txt" ]; then | ||
echo "This legacy deployment has been migrated" | ||
bash ci-deploy.sh deploy | ||
elif [ -n "$MAJOR_MOD_VERSION" ] && (( $MAJOR_MOD_VERSION < 3 )) ; then | ||
source "${PWD}/meta.sh" | ||
echo "CI determined this is a legacy deploy." | ||
echo "Generating Deployment pvt key." | ||
export LEGACY_PVT_KEY="${LEGACY_DIR}/domino.pem" | ||
envsubst < "${LEGACY_DIR}/ci.tfvars.tftpl" | tee "${LEGACY_DIR}/terraform.tfvars" | ||
ssh-keygen -q -P '' -t rsa -b 4096 -m PEM -f "$LEGACY_PVT_KEY" | ||
echo "Running legacy monolithic deploy" | ||
terraform -chdir="$LEGACY_DIR" init | ||
terraform -chdir="$LEGACY_DIR" validate | ||
terraform -chdir="$LEGACY_DIR" apply --auto-approve --input=false | ||
echo "Running state migration on CI." | ||
bash -xp ../../bin/state-migration/migrate-states.sh | ||
else | ||
echo "Running ci-deploy.sh deploy" | ||
bash ci-deploy.sh deploy | ||
fi | ||
tf_deploy: | ||
description: "Terraform deploy" | ||
steps: | ||
- aws-cli/setup: | ||
role-arn: "${AWS_IAM_ROLE}" | ||
session-duration: "43200" | ||
- tf_init_apply | ||
tf_destroy: | ||
description: "Terraform destroy" | ||
steps: | ||
- run: | ||
name: Terraform destroy | ||
working_directory: tests | ||
command: | | ||
echo "Current dir: $(pwd)" | ||
terraform destroy --auto-approve || terraform destroy --auto-approve --refresh=false | ||
when: always | ||
tf_ws_delete: | ||
description: "Terraform workspace delete" | ||
steps: | ||
- run: | ||
name: Terraform workspace delete | ||
working_directory: tests | ||
command: | | ||
echo "Current dir: $(pwd)" | ||
terraform workspace select default | ||
terraform workspace delete ${WORKSPACE} | ||
working_directory: tests/deploy | ||
command: bash ci-deploy.sh destroy | ||
when: always | ||
tf_plan_test: | ||
steps: | ||
- aws-cli/setup: | ||
role-arn: "${AWS_IAM_ROLE}" | ||
session-duration: "900" | ||
- set_aws_creds | ||
- run: | ||
name: Terraform plan test | ||
working_directory: examples | ||
command: | | ||
bash tf-plan-test.sh | ||
working_directory: tests/plan | ||
command: bash tf-plan-test.sh | ||
jobs: | ||
tf-plan-test: | ||
docker: | ||
|
@@ -131,93 +158,68 @@ jobs: | |
docker: | ||
- image: cimg/aws:2023.04.1 | ||
parameters: | ||
workspace: | ||
type: string | ||
terraform_version: | ||
type: string | ||
helm_version: | ||
type: string | ||
environment: | ||
WORKSPACE: << parameters.workspace >> | ||
steps: | ||
- checkout | ||
- install_tf: | ||
terraform_version: << parameters.terraform_version >> | ||
- install_helm: | ||
helm_version: << parameters.helm_version >> | ||
- envsubst/install | ||
- set_tf_vars | ||
- gen_pvt_key | ||
- tf_init_apply | ||
- tf_deploy | ||
- tf_destroy | ||
- tf_ws_delete | ||
test-upgrade: | ||
docker: | ||
- image: cimg/aws:2023.04.1 | ||
parameters: | ||
workspace: | ||
type: string | ||
terraform_version: | ||
type: string | ||
helm_version: | ||
type: string | ||
environment: | ||
WORKSPACE: << parameters.workspace >> | ||
hcledit_version: | ||
type: string | ||
steps: | ||
- checkout | ||
- install_tf: | ||
terraform_version: << parameters.terraform_version >> | ||
- install_helm: | ||
helm_version: << parameters.helm_version >> | ||
- envsubst/install | ||
- install_hcledit | ||
- set_tf_vars | ||
- gen_pvt_key | ||
- run: | ||
name: "Set module source to latest published release" | ||
working_directory: tests | ||
command: | | ||
latest_release_tag=$(jq -r '.tag_name' <(curl -sSfL -H "X-GitHub-Api-Version: 2022-11-28" -H "Accept: application/vnd.github+json" https://api.github.com/repos/dominodatalab/terraform-aws-eks/releases/latest)) | ||
export MOD_SOURCE="github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git?ref=${latest_release_tag}" | ||
echo "Latest published release tag is: ${latest_release_tag}" | ||
echo "Setting module source to: ${MOD_SOURCE}" | ||
cat \<<< $(jq --arg mod_source "${MOD_SOURCE}" '.module[0].domino_eks.source = $mod_source' main.tf.json) >main.tf.json | ||
working_directory: tests/deploy | ||
command: bash ci-deploy.sh set_mod_src_latest_rel | ||
- tf_deploy | ||
- set_current_mod_source | ||
- tf_init_apply | ||
- run: | ||
name: "Upgrade module by applying this commit" | ||
working_directory: tests | ||
command: | | ||
echo "Testing terraform module upgrade" | ||
export MOD_SOURCE="./.." | ||
echo "Setting module source to local ref: ${MOD_SOURCE}" | ||
cat \<<< $(jq --arg mod_source "${MOD_SOURCE}" '.module[0].domino_eks.source = $mod_source' main.tf.json) >main.tf.json | ||
terraform init --reconfigure --upgrade | ||
terraform validate | ||
terraform apply --auto-approve | ||
- tf_destroy | ||
- tf_ws_delete | ||
|
||
workflows: | ||
test-deploy-workflow: | ||
when: | ||
equal: ["test-deploy-workflow", << pipeline.parameters.GHA_Action >> ] | ||
equal: ["test-deploy-workflow", << pipeline.parameters.GHA_Action >>] | ||
jobs: | ||
- test-deploy: | ||
context: aws-oidc | ||
terraform_version: << pipeline.parameters.terraform_version >> | ||
helm_version: << pipeline.parameters.helm_version >> | ||
workspace: << pipeline.parameters.workspace >> | ||
test-upgrade-workflow: | ||
when: | ||
equal: ["test-upgrade-workflow", << pipeline.parameters.GHA_Action >> ] | ||
equal: ["test-upgrade-workflow", << pipeline.parameters.GHA_Action >>] | ||
jobs: | ||
- test-upgrade: | ||
context: aws-oidc | ||
terraform_version: << pipeline.parameters.terraform_version >> | ||
helm_version: << pipeline.parameters.helm_version >> | ||
workspace: << pipeline.parameters.workspace >> | ||
hcledit_version: << pipeline.parameters.hcledit_version >> | ||
examples-plan-test-workflow: | ||
when: | ||
equal: ["examples-plan-test-workflow", << pipeline.parameters.GHA_Action >> ] | ||
equal: | ||
["examples-plan-test-workflow", << pipeline.parameters.GHA_Action >>] | ||
jobs: | ||
- tf-plan-test: | ||
context: aws-oidc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.