Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,22 @@ lint_docs:
1>&2 echo -e "\n\tmake lint_docs WATCH_DOCS=true"; \
1>&2 echo -e "\tmake lint_docs LINT_DOCS=./docs/README.md WATCH_DOCS=true"; \
fi; \
exit $${EXIT_CODE};
exit $${EXIT_CODE};

.PHONY: ephemeral_cluster
ephemeral_cluster:
@ if [[ -z "$${EPH_CLUSTER_ID}" ]] || [[ ! -v "EPH_CLUSTER_ID" ]]; then \
echo "Set the ephemeral cluster id with the EPH_CLUSTER_ID variable"; \
printf "\t make create_ephemeral_cluster EPH_CLUSTER_ID=\"eph-new-cluster\"\n"; \
exit 1; \
fi; \
cd terraform/deployments/ephemeral; \
terraform init; \
echo "Ephemeral cluster $${EPH_CLUSTER_ID} will be built by Terraform in Terraform Cloud."; \
echo "When the 'cluster_access' workspace is complete you should be able to access to the cluster"; \
printf "\t aws eks update-kubeconfig --name $${EPH_CLUSTER_ID}\n"; \
echo "Once all workspaces are complete, log into the cluster and run './validate.sh' to test the cluster is functioning"; \
open "https://app.terraform.io/app/govuk/projects"; \
echo "Press enter to continue"; \
read; \
terraform apply -var ephemeral_cluster_id="$${EPH_CLUSTER_ID}"; \
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ We set the constraints with minor version precision. However when using this Ter
We have some [recommended pre-commit hooks](.pre-commit-config.yaml). You need
to [install `pre-commit`](https://pre-commit.com/#install) for these to run.

## Starting and updating an ephemeral cluster

This repository supports creating ephemeral Kubernetes clusters for the purposes of short-lived tests. To
create a new cluster, or update the workspaces for an existing one, use the Make target:

```shell
make ephemeral_cluster EPH_CLUSTER_ID=eph-new-cluster
```

## Stopping an ephemeral cluster

To stop an existing ephemeral cluster, see the instructions in the readme in `terraform/deployments/ephemeral/`.

## Documentation

See the [`docs/` directory](docs/).
Expand Down
10 changes: 10 additions & 0 deletions terraform/deployments/ephemeral/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
variable "ephemeral_cluster_id" {
type = string

validation {
condition = length(var.ephemeral_cluster_id) <= 38
error_message = "ephemeral_cluster_id must be 38 characters or fewer"
}

validation {
condition = startswith(var.ephemeral_cluster_id, "eph-")
error_message = "ephemeral_cluster_id must begin with 'eph-'"
}
}

variable "organization" {
Expand Down
2 changes: 2 additions & 0 deletions terraform/deployments/ephemeral/ws/workspace.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ module "workspace" {
"common-ephemeral"
]

force_delete = true

tfvars = var.tfvars
}

Expand Down
Loading