##Terraform Kubernetes Solution
This repository contains Terraform code to deploy a Kubernetes-based Test application on AWS. The Terraform state is stored in an S3 bucket, and the state lock is managed using a DynamoDB table. Both the S3 bucket and the DynamoDB table are created using AWS CloudFormation.
- Terraform installed (version >= 0.13)
- AWS CLI installed and configured with appropriate credentials
- kubectl installed (optional, to interact with the deployed Kubernetes cluster)
- Clone this repository:
git clone https://github.com/yourusername/<this-repo>.git
cd <this-repo>
- Create the required S3 bucket and DynamoDB table using CloudFormation:
aws cloudformation create-stack --stack-name my-stack --template-body file://s3-dynamodb.yml --parameters ParameterKey=S3BucketName,ParameterValue=my-s3-bucket ParameterKey=DynamoDBName,ParameterValue=my-lock-table
- Update
backend.tf
with the S3 bucket and DynamoDB table names you provided as parameters when creating the CloudFormation stack:
terraform {
backend "s3" {
bucket = "my-s3-bucket"
key = "terraform.tfstate"
region = "us-west-2"
dynamodb_table = "my-lock-table"
}
}
- Initialize Terraform:
terraform init
- Review the Terraform plan and apply:
terraform plan
terraform apply
- (Optional) To interact with the deployed Kubernetes cluster, configure
kubectl
:
aws eks update-kubeconfig --region us-west-2 --name my-cluster-name
- To destroy the deployed infrastructure, run:
terraform destroy
Contributions are welcome! Please feel free to submit a pull request or open an issue.