Created
August 29, 2024 17:18
-
-
Save helton/38965193a35defb434894bb4610fb051 to your computer and use it in GitHub Desktop.
Localstack + Terraform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
localstack: | |
image: localstack/localstack:latest | |
container_name: localstack | |
ports: | |
- "4566:4566" | |
- "4571:4571" # SQS | |
- "4575:4575" # SNS | |
environment: | |
- DEBUG=1 # Enable debug mode for more detailed logs | |
volumes: | |
- "./localstack/data:/var/lib/localstack" | |
- "/var/run/docker.sock:/var/run/docker.sock" | |
healthcheck: | |
test: ["CMD-SHELL", "curl -s http://localhost:4566/_localstack/health"] | |
interval: 5s | |
timeout: 2s | |
retries: 10 | |
start_period: 5s | |
networks: | |
- localstack_network | |
terraform: | |
image: hashicorp/terraform:latest | |
container_name: terraform | |
depends_on: | |
localstack: | |
condition: service_healthy | |
environment: | |
- AWS_ACCESS_KEY_ID=localstack | |
- AWS_SECRET_ACCESS_KEY=localstack | |
- AWS_REGION=sa-east-1 | |
volumes: | |
- "./terraform/data:/terraform" | |
- "./terraform/main.tf:/tmp/main.tf" | |
working_dir: /terraform | |
entrypoint: ["/bin/sh", "-c"] | |
command: | | |
cp /tmp/main.tf /terraform/main.tf && \ | |
terraform init && \ | |
terraform apply -auto-approve | |
networks: | |
- localstack_network | |
networks: | |
localstack_network: | |
driver: bridge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "aws" { | |
access_key = "test" | |
secret_key = "test" | |
region = "us-east-1" | |
skip_credentials_validation = true | |
skip_metadata_api_check = true | |
skip_requesting_account_id = true | |
skip_region_validation = true | |
endpoints { | |
sqs = "http://localstack:4566" | |
} | |
} | |
resource "aws_sqs_queue" "queue1" { | |
name = "queue1" | |
} | |
resource "aws_sqs_queue" "queue2" { | |
name = "queue2" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment