Warning: This code is provided as-is — it is not meant to be executed verbatim. No support is provided in any way.
This repository contains a reference architecture for deploying applications on AWS using OpenTofu and Kubernetes. It provides an example of how to set up a VPC with an EKS cluster and deploying a simple "Hello World" application to the cluster.
The file structure is organized as follows:
remote-state/: Contains the OpenTofu configuration for managing remote state.example-deployment/: Contains an example deployment of the infrastructure using the OpenTofu modules.kubernetes/: Contains Kubernetes manifests for deploying a simple "Hello World" application.
To get started you first have to install OpenTofu on your machine. Installation instructions for all platforms can be found here.
You also need to install Taskfile to run the tasks in this repository. Installation instructions can be found here.
It's also good to have kubectl installed on your machine to interact with Kubernetes clusters. You can find installation instructions here.
You also need to have the AWS CLI installed and configured with your AWS credentials. You can find installation instructions here.
Before you can start working with setting up environments using OpenTofu you have to set up everything needed for state management. This is a one time process for each new AWS account.
cd remote-state
task plan
task applyTo deploy the infrastructure, navigate to the example-deployment directory and run:
task plan
task applyIn the kubernetes directory, you will find the necessary YAML files to deploy a simple "Hello World" application using Kubernetes.
cd kubernetes
kubectl apply -f hello-world-deployment.ymlTo clean up the Kubernetes resources, you can run:
kubectl delete -f hello-world-deployment.ymlFor more information on this example deployment, refer to the kubernetes/README.md file.
To remove the deployed infrastructure, navigate to the example-deployment directory and run:
task destroy