Skip to content

lomasz/terraform-aws-localstack

Repository files navigation

terraform-aws-localstack

Good evening, everybody, and welcome to the terraform-aws-localstack repository where everything is more confusing than IKEA assembly instructions and the errors are treated like decorations. That's right, the infrastructure is like socks in a dryer - it just disappears for no reason!

Terraform + AWS / LocalStack

📝 Prerequisites

For 🍎 macOS users, you can use the Brewfile script to simplify the installation of all the necessary dependencies.

If you have Homebrew installed, follow these steps:

brew bundle

🚀 Getting Started

🏠 LocalStack

  • Install LocalStack AWS CLI (awslocal) and tflocal

  • Run LocalStack:

    • 🆓 Community:

      docker-compose -f localstack-compose.yml up
    • 💸 Pro:

      required, for example, for the EKS component. more info: LocalStack Coverage

      ⚠️ You need to provide LOCALSTACK_API_KEY value.

      # Set up the API Key
      export LOCALSTACK_API_KEY=<your-api-key>
      
      # Run LocalStack Pro
      docker-compose -f localstack-pro-compose.yml up
  • Initialize Terraform:

tflocal init
  • Generate Terraform plan:
tflocal plan
  • Apply Terraform configuration:
tflocal apply -auto-approve

☁️ AWS

  • Create S3 state bucket
aws s3api create-bucket --bucket tf-state
  • Initialize Terraform:
terraform init
  • Generate Terraform plan:
terraform plan
  • Apply Terraform configuration:
terraform apply -auto-approve

☸️ Helm

Use my another git repository spring-boot-template as example of Helm chart.

Connecting to EKS on LocalStack using kubectl

1. Update kubeconfig for EKS Cluster

First, you need to add the my-eks cluster information to your ~/.kube/config to enable kubectl to know where your cluster is and how to access it.

awslocal eks update-kubeconfig --name my-eks

2. Configure AWS CLI for LocalStack

Before interacting with LocalStack, configure the AWS CLI to use dummy credentials. Though LocalStack doesn't validate these credentials, it expects them to be set.

Run the configuration command:

aws configure

When the AWS CLI prompts you for the credentials, use dummy credentials:

AWS Access Key ID [None]: test
AWS Secret Access Key [None]: test

3. Set current k8s context

kubectx arn:aws:eks:us-east-1:000000000000:cluster/my-eks

4. Validate kubectl Configuration

List resources across all namespaces to validate the connection:

kubectl get all -A

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published