So Im trying to deploy some terraform configuration into localstack. Im running it inside WSL so linux based, The problem is that for testing now the configuration in terraform creates an S3 bucket and a gateway. The S3 Bucket resource deploy fine but the gateway does not get deployed while terraform doesnt give any errors back. I have tried reinitalizing the localstack and terraform by delete the cache etc but that doesnt seem to help so Im kinda lost for words whats going wrong. Also localstack logs dont show any errors in deploying so im kinda lost where to look? has some ever incountered this before?
Important note I can manually deploy the gateway with the aws command line aws apigateway create-rest-api --name "test-api-cli" --endpoint-url http://localhost:4566
So im very confused where its going wrong?
main.ft
provider "aws" {
region = "eu-west-1"
access_key = "test"
secret_key = "test"
endpoints {
apigateway = "http://localhost:4566"
cloudwatch = "http://localhost:4566"
dynamodb = "http://localhost:4566"
ec2 = "http://localhost:4566"
events = "http://localhost:4566"
iam = "http://localhost:4566"
kms = "http://localhost:4566"
lambda = "http://localhost:4566"
logs = "http://localhost:4566"
s3 = "http://localhost:4566"
sns = "http://localhost:4566"
sts = "http://localhost:4566"
}
skip_credentials_validation = true
skip_metadata_api_check = true
skip_requesting_account_id = true
s3_use_path_style = true
}
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4"
}
}
required_version = ">= 1.1"
}
resource "aws_s3_bucket" "test" {
bucket = "my-test-bucket"
}
resource "aws_api_gateway_rest_api" "test_api" {
name = "test-api-only"
}
Plan results + showing s3 bucket beeing deployed in localstack and gateway is not:
And the dockerfile for localstack:
version: "3.8"
services:
localstack:
image: localstack/localstack-pro
container_name: localstack-pro
ports:
- "4566:4566"
- "4571:4571"
environment:
- LOCALSTACK_AUTH_TOKEN=[Is valid pro token]
- LOCALSTACK_EDITION=pro
- LOCALSTACK_SERVICES=apigateway,cloudwatch,logs,iam,kms,sts,lambda,s3,dynamodb,events,sns
- LOCALSTACK_DEBUG=1
volumes:
- ./localstack-data:/var/lib/localstack
- /var/run/docker.sock:/var/run/docker.sock
You are not specifying a region in your AWS CLI call. S3 is "global", so you will see your buckets in any region. However, you'll need to specify --region eu-west-1
, the same region you have deployed your REST API with Terraform, to be able to see it in your response.