milliHQ / terraform-aws-next-js

Terraform module for building and deploying Next.js apps to AWS. Supports SSR (Lambda), Static (S3) and API (Lambda) pages.
https://registry.terraform.io/modules/milliHQ/next-js/aws
Apache License 2.0
1.47k stars 151 forks source link

Is there a localstack sample available? #375

Open pablobuild opened 2 years ago

pablobuild commented 2 years ago

Is there a localstack sample available?

khuezy commented 2 years ago

Something like:

docker-compose.yml

  # Local Stack
  localstack:
    image: localstack/localstack:latest
    environment:
      - LAMBDA_EXECUTION_ROLE=docker-reuse
      - AWS_ACCESS_KEY_ID=test
      - AWS_SECRET_ACCESS_KEY=test
      - AWS_DEFAULT_REGION=us-west-2
      - DOCKER_HOST=unix:///var/run/docker.sock
      - SERVICES=lambda,cloudwatch,sqs,iam,events
    ports:
      - '4566-4583:4566-4583'

terraform/modules/localstack/main.tf

provider "aws" {
  region = "us-west-2"
  # access_key = "fake"
  # secret_key = "fake"
  skip_credentials_validation = false
  skip_metadata_api_check = true
  skip_requesting_account_id = false

  endpoints {
    lambda      = "http://localhost:4566"
    iam      = "http://localhost:4566"
    sqs         = "http://localhost:4566"
    cloudwatch  = "http://localhost:4566"
    cloudwatchlogs = "http://localhost:4566"
    events = "http://localhost:4566"
  }
}

# Modules
module "yourmodule" {
  source = "../modules/yourmodule"

  environment = "local"
  database_url = var.DATABASE_URL
}

Then cd to the localstack module and run terraform init then terraform apply to launch a localstack.