What is LocalStack?
LocalStack is a tool that allows you to simulate AWS services in a local environment. You can test and develop resources like S3 and Lambda without using a cloud environment. This time, I'll demonstrate using CloudFormation to create an S3 bucket with LocalStack.
Running It Locally
Create a docker-compose.yml file with the following content:
version : ' 3.8'
services : localstack : image : localstack/localstack ports : - " 4566:4566" # LocalStack unified endpoint environment : - SERVICES=cloudformation,s3,dynamodb # Specify services to enable as comma-separated values - DEBUG=1 # Enable debug mode
Enter fullscreen mode
Exit fullscreen mode
Next, run the following command to start LocalStack:
$ docker-compose up -d
Enter fullscreen mode
Exit fullscreen mode
Deploying CloudFormation
Let me write a sample CloudFormation template:
AWSTemplateFormatVersion : ' 2010-09-09' Resources : MyBucket : Type : AWS::S3::Bucket Properties : BucketName : my-localstack-bucket
Enter…