File tree Expand file tree Collapse file tree
terraform/deployments/ephemeral Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,4 +30,31 @@ lint_docs:
3030 1>&2 echo -e "\n\tmake lint_docs WATCH_DOCS=true"; \
3131 1>&2 echo -e "\tmake lint_docs LINT_DOCS=./docs/README.md WATCH_DOCS=true"; \
3232 fi; \
33- exit $${EXIT_CODE};
33+ exit $${EXIT_CODE};
34+
35+ .PHONY : ephemeral_cluster
36+ ephemeral_cluster :
37+ @ if [[ -z " $$ {EPH_CLUSTER_ID}" ]] || [[ ! -v " EPH_CLUSTER_ID" ]]; then \
38+ echo " Set the ephemeral cluster id with the EPH_CLUSTER_ID variable" ; \
39+ printf " \t make create_ephemeral_cluster EPH_CLUSTER_ID=\" eph-new-cluster\" \n" ; \
40+ exit 1; \
41+ fi; \
42+ cd terraform/deployments/ephemeral; \
43+ terraform init; \
44+ terraform apply -var ephemeral_cluster_id="$${EPH_CLUSTER_ID}"; \
45+ echo "Ephemeral cluster $${EPH_CLUSTER_ID} is being built by Terraform in Terraform Cloud."; \
46+ echo "When the 'cluster_access' workspace is complete you should be able to access to the cluster"; \
47+ printf "\t aws eks update-kubeconfig --name $${EPH_CLUSTER_ID}\n"; \
48+ echo "Once all workspaces are complete, log into the cluster and run './validate.sh' to test the cluster is functioning"; \
49+ open "https://app.terraform.io/app/govuk/projects";
50+
51+ .PHONY : destroy_ephemeral_cluster
52+ destroy_ephemeral_cluster :
53+ @ if [[ -z " $$ {EPH_CLUSTER_ID}" ]] || [[ ! -v " EPH_CLUSTER_ID" ]]; then \
54+ echo " Set the ephemeral cluster id with the EPH_CLUSTER_ID variable" ; \
55+ printf " \t make create_ephemeral_cluster EPH_CLUSTER_ID=\" eph-new-cluster\" \n" ; \
56+ exit 1; \
57+ fi; \
58+ cd terraform/deployments/ephemeral; \
59+ terraform init; \
60+ gds aws govuk-test-platformengineer -- "$${SHELL}" -c "./shutdown.sh \"$${EPH_CLUSTER_ID}\"; terraform apply -var ephemeral_cluster_id=\"$${EPH_CLUSTER_ID}\" -destroy;"
Original file line number Diff line number Diff line change @@ -39,6 +39,23 @@ We set the constraints with minor version precision. However when using this Ter
3939We have some [ recommended pre-commit hooks] ( .pre-commit-config.yaml ) . You need
4040to [ install ` pre-commit ` ] ( https://pre-commit.com/#install ) for these to run.
4141
42+ ## Starting and updating an ephemeral cluster
43+
44+ This repository supports creating ephemeral Kubernetes clusters for the purposes of short-lived tests. To
45+ create a new cluster, or update the workspaces for an existing one, use the Make target:
46+
47+ ``` shell
48+ make ephemeral_cluster EPH_CLUSTER_ID=eph-new-cluster
49+ ```
50+
51+ ## Stopping an ephemeral cluster
52+
53+ To stop an existing ephemeral cluster, use the Make test:
54+
55+ ``` shell
56+ make destroy_ephemeral_cluster=eph-new-cluster
57+ ```
58+
4259## Documentation
4360
4461See the [ ` docs/ ` directory] ( docs/ ) .
Original file line number Diff line number Diff line change 11variable "ephemeral_cluster_id" {
22 type = string
3+
4+ validation {
5+ condition = length (var. ephemeral_cluster_id ) <= 38
6+ error_message = " ephemeral_cluster_id must be 38 characters or fewer"
7+ }
8+
9+ validation {
10+ condition = startswith (var. ephemeral_cluster_id , " eph-" )
11+ error_message = " ephemeral_cluster_id must begin with 'eph-'"
12+ }
313}
414
515variable "organization" {
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ module "workspace" {
3030 " common-ephemeral"
3131 ]
3232
33+ force_delete = true
34+
3335 tfvars = var. tfvars
3436}
3537
You can’t perform that action at this time.
0 commit comments