Test your terraform code using terratest and localstack
LocalStack is a cloud service emulator that runs in a single container on your laptop or in your CI environment. With LocalStack, you can run your AWS applications or Lambdas entirely on your local machine without connecting to a remote cloud provider!
Whether you are testing complex CDK applications or Terraform configurations, or just beginning to learn about AWS services, LocalStack helps speed up and simplify your testing and development workflow.
LocalStack supports a growing number of AWS services, like AWS Lambda, S3, DynamoDB, Kinesis, SQS, SNS, and more! LocalStack Pro supports additional APIs and advanced features to make your cloud development experience a breeze! ou can find a comprehensive list of supported APIs on our Feature Coverage page. https://docs.localstack.cloud/user-guide/aws/feature-coverage/
On macos:
docker pull localstack/localstack
docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack
Learn more: https://hub.docker.com/r/localstack/localstack
- cli 'SERVICES=s3,sts localstack start'
- docker-compose
cd docker && docker-compose up
ordocker-compose -f docker/docker-compose.yml up
run the command curl --silent --output /dev/null --write-out "%{http_code}" http://localhost:4566
and ths status should 200, that means the localstack is running
cd test/terratest
go mod tidy
go test -v