How to integrate terraform with atlassian/localstack?
amazon-web-services, localstack, terraform
Solution
Terraform does not officially support "AWS-workalike" systems, since they often have subtle quirks and differences relative to AWS itself. However, it is supported on a best-effort basis and may work if localstack is able to provide a sufficiently realistic impression of S3 for Terraform's purposes.
According to the localstack docs, by default the S3 API is exposed at `http://localhost:4572` , so setting the custom endpoint this way may work:
provider "aws" {
endpoints {
s3 = "http://localhost:4572"
}
}
Depending on the capabilities of localstack, you may need to set some other settings:
- `s3_force_path_style` to use a path-based addressing scheme for buckets and objects.
- `skip_credentials_validation`, since localstack seems to lack an implementation of the AWS token service.
- `skip_metadata_api_check` if IAM-style credentials will not be used, to prevent Terraform from trying to get credentials from the EC2 metadata API.
Problem
Terraform can be configured with custom S3 endpoints and it seems that localstack can create local stacks for S3, SES, Cloudformation and few others services. The question is what to write in Terraform configuration to use localstack's S3 endpoint?