无法让 terraform 和 localstack 成为 运行 一个简单的例子

Cant get terraform and localstack to run a simple example

我试图在一个简单的例子中获取 terraform 和本地堆栈 运行ning,但它似乎有点挂起..我在 TF 12 上,提供者“aws”(hashicorp/aws) 3.68.0...

这是我的 docker 文件

version: '3.8'
services:
  localstack:
    image: localstack/localstack:latest
    ports:
      - 8080:8080 # webui
      - 4569:4569 # dynamodb
      - 4574:4574 # lamba
    environment:
      - DATA_DIR=/tmp/localstack/data
      - DEBUG=1
      - DEFAULT_REGION=ap-southeast-2
      - DOCKER_HOST=unix:///var/run/docker.sock
      - LAMBDA_EXECUTOR=docker-reuse
      - PORT_WEB_UI=8080
      - SERVICES=lambda,dynamodb
      - LAMBDA_DOCKER_NETWORK=localstack-tutorial
   volumes:
      - /var/run/docker.sock:/var/run/docker.sock

这是我的 localstack tf 文件

provider "aws" {
  access_key                  = "mock_access_key"
  region                      = "us-east-1"
  s3_force_path_style         = true
  secret_key                  = "mock_secret_key"
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    dynamodb = "http://localhost:4569"
    lambda   = "http://localhost:4574"
  }
}

resource "aws_dynamodb_table" "table_1" {
  name           = "table_1"
  read_capacity  = "20"
  write_capacity = "20"
  hash_key       = "id"

  attribute {
    name = "id"
    type = "S"
  }
}

当我 运行 使用 terraform 计划时 运行 没问题,但是当我 运行 应用 --auto-approve..

$ terraform apply --auto-approve
aws_dynamodb_table.table_1: Creating...
aws_dynamodb_table.table_1: Still creating... [10s elapsed]
aws_dynamodb_table.table_1: Still creating... [20s elapsed]
aws_dynamodb_table.table_1: Still creating... [30s elapsed]
aws_dynamodb_table.table_1: Still creating... [40s elapsed]
aws_dynamodb_table.table_1: Still creating... [50s elapsed]
aws_dynamodb_table.table_1: Still creating... [1m0s elapsed]
aws_dynamodb_table.table_1: Still creating... [1m10s elapsed]
aws_dynamodb_table.table_1: Still creating... [1m20s elapsed]
aws_dynamodb_table.table_1: Still creating... [1m30s elapsed]
aws_dynamodb_table.table_1: Still creating... [1m40s elapsed]
aws_dynamodb_table.table_1: Still creating... [1m50s elapsed]
aws_dynamodb_table.table_1: Still creating... [2m0s elapsed]
aws_dynamodb_table.table_1: Still creating... [2m10s elapsed]
aws_dynamodb_table.table_1: Still creating... [2m20s elapsed]
aws_dynamodb_table.table_1: Still creating... [2m30s elapsed]
aws_dynamodb_table.table_1: Still creating... [2m40s elapsed]
aws_dynamodb_table.table_1: Still creating... [2m50s elapsed]
aws_dynamodb_table.table_1: Still creating... [3m0s elapsed]

我认为您的端口不正确。来自 docs:

A major (breaking) change has been merged in PR #2905 - starting with releases after v0.11.5, all services are now exposed via the edge service (port 4566) only! Please update your client configurations to use this new endpoint.