demo.mov
https://development.hcl-playground.com/
HCL Playground is an application designed to provide a playground/sandbox environment for evaluating HashiCorp Configuration Language (HCL) code on-demand. The aim of this project is avoid the toil/overhead required to simply evaluate some HCL-code where a user currently has to:
- Install terraform
- Setup a new project
- Write some HCL
terraform init
terraform console
- < test how setproduct() works on your current
locals
data > - "Oops I made a mistake!"
Ctrl+C
- edit
locals
block terraform console
- rinse and repeat
If you've been in the depths of attempting to get "creative" with cobbling together the terraform functions available to massage some complex inputs you may catch my drift
- Docker installed on your local machine
- Git (for cloning the repository)
-
Clone the repository:
git clone <repository-url> cd hcl-playground
-
Build the Docker image:
docker build -t hcl-playground .
-
Run the Docker container:
docker run -v /tmp:/scratch -it -p 8080:8080 hcl-playground
Access the application at
http://localhost:8080
.
The CI configuration is defined in .circleci/config.yml
. The key jobs in the pipeline include:
-
AWS Authentication (
aws-auth
): Obtains temporary AWS credentials via CircleCI's OIDC pattern for use in subsequent steps. This is necessary for actions like pushing Docker images to ECR and updating Kubernetes configurations. -
Push Docker Image (
push-image
): Builds the Docker image and pushes it to AWS ECR -
Deploy to EKS (
eks-deploy
):- Installs
kubectl
andhelm
. - Sets up Kubernetes configuration to be able to interact with the EKS cluster.
- Applies Kubernetes deployment, service, and ingress manifests to the EKS cluster.
- Verifies the deployment status.
- Installs
-
Run Tests (
test
): Pulls the Docker image built earlier in the pipeline from ECR and runs tests using Cypress. -
Setup Infrastructure (
setup-infra
): Uses Terraform to set up or update infrastructure as defined in the Terraform files located in the project.
The build-deploy-dev
workflow orchestrates the above jobs:
- We start by setting up any required backing infrastructure using Terraform.
- Then we build and push the Docker image to ECR, runs tests against the image we just built, and if successful finally deploys to our EKS cluster
- The workflow is configured to run on pull requests only, excluding the
main
branch as development efforts are still in progress to get to a production-ready state
$ docker build --build-arg INSTALL_DEV_DEPS=true -t hcl-playground .
$ docker run -v /tmp:/scratch -it hcl-playground python -m pytest -p no:cacheprovider
To run Cypress-based tests:
-
Ensure Cypress is Installed: If Cypress is not already installed, you can install it by running the following in the project root:
npm install
-
Run Cypress Tests: Execute the Cypress tests using the Cypress UI:
npx cypress open
Or for headless testing:
npx cypress run
In the CI pipeline, Cypress tests are run as part of the
test
job using the Cypress CircleCI orb.
The application is deployed to AWS EKS using Kubernetes manifests. The deployment process is automated through the CircleCI pipeline, which builds the Docker image, pushes it to ECR, and then updates the Kubernetes deployment on EKS.
- Scott Ouellette - Initial work - scottx611x
This project is licensed under the MIT License - see the LICENSE.md file for details