Install Localstack:
$ pip install localstack
Start Localstack:
$ export SERVICES=s3,lambda,dynamodb
$ export DEFAULT_REGION=eu-west-1
$ localstack start
the provider.tf
file:
provider "aws" {
region = "eu-west-1"
endpoints {
dynamodb = "http://localhost:4569"
}
}
the main.tf
file:
resource "aws_dynamodb_table" "mytable" {
name = "mytable"
read_capacity = 5
write_capacity = 5
hash_key = "Id"
range_key = "Timestamp"
attribute {
name = "Id"
type = "S"
}
attribute {
name = "Timestamp"
type = "S"
}
}
Run terraform:
$ terraform init
$ terraform plan
$ terraform apply