AWS Emulator is a free LocalStack alternative for CI

2026-11-29来源 dev.toEnglish

On 11 November 2026 AWS released AWS Emulator, a local emulator of its APIs that runs on your laptop or in a CI job. It needs no AWS account, and the product page says AWS charges no additional fee for it. If you pay for LocalStack licences only so that CI tests can reach S3, SQS or DynamoDB, try the emulator as a LocalStack alternative: move those tests to it in a separate branch. IAM permission tests stay on real AWS, because the emulator doesn't check them the way AWS does.

Free LocalStack has been non-commercial only since March

LocalStack ended support for its Community edition on 23 March 2026. The new distribution requires an auth token, so a pipeline that pulls localstack/localstack:latest needs one.

According to the LocalStack pricing page, the free Hobby plan is for hobbyists and non-commercial use. Base costs USD 39 per licence per month, billed annually, and licences are assigned to people. Every plan includes CI under fair use, but LocalStack asks companies that use it mainly in automated environments to talk to sales.

What the emulator covers and where it runs

According to AWS, the emulator covers more than 200 services, but an operation it doesn't support yet returns HTTP 501 NotImplemented.

Resources live in memory and disappear when the emulator stops. The emulator runs natively only on Linux. On macOS and Windows you build a Docker image yourself from the AWS Dockerfile, since AWS doesn't publish a prebuilt one. Telemetry is on by default, and you can turn it off by setting EMULATOR_TELEMETRY=off.

What you can't test on the emulator

The emulator doesn't evaluate IAM policies or resource-based policies the way AWS does, and its security page warns that a request AWS would deny may go through. AWS says not to use it for security testing or production.

How closely the emulator matches AWS varies by service. AWS publishes a fidelity score for each service with every release on the releases page. Its guide to checking a project shows how to find the tests for the operations your code calls. For an operation with no test, run your own test on the emulator and on AWS and compare.

Running CI tests on the emulator with one script

If the shell running your tests has no AWS_ENDPOINT_URL, your code sends requests to real AWS with whatever keys it finds. That is why the documentation says to set the variables in the same script that runs the tests and to keep real keys out of the test job. The script also unsets variables holding real keys, because they take precedence over the credentials file.

The chart for this part is in the original post.
Add these lines to a bash script before your test command, on a Linux runner with AWS CLI v2 and the emulator installed:

n=0; aws-emulator --idle-timeout 600 & unset AWS_ACCESS_KEY_ID AWS_PROFILE \ AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN D=~/.aws/emulator/9297; set -a AWS_ENDPOINT_URL=https://127.0.0.1:9297 AWS_SHARED_CREDENTIALS_FILE=\ $D/emulator_credentials AWS_CONFIG_FILE=$D/config AWS_CA_BUNDLE=$D/ca.pem AWS_EC2_METADATA_DISABLED=true AWS_DISABLE_HOST_PREFIX_INJECTION=true AWS_REGION=us-east-1 AWS_DEFAULT_REGION=us-east-1 until aws sts get-caller-identity \ --query Account --output text \ | grep -x 000000000000 do ((++n < 30)) || exit 1; sleep 1; done kill -0 $! || exit 1; set +a 

The variables come from the AWS documentation. I added the loop myself: it waits until aws sts get-caller-identity returns account 000000000000. After 30 failed attempts the script exits with an error, and it also stops when an emulator from an earlier job still holds the port. The check only proves that AWS CLI v2 in this shell reaches the emulator, so run the tests from the same script, with an SDK that reads AWS_ENDPOINT_URL. The JavaScript v2, Java 1.x and Go v1 SDKs don't.

The --idle-timeout 600 option shuts the emulator down after 10 minutes with no calls. The address is 127.0.0.1, not localhost, because with localhost the JavaScript, Java and Go SDKs put the S3 bucket name into the host name. Node.js also needs NODE_EXTRA_CA_CERTS set to ca.pem.

In CI, pin a specific version and upgrade it regularly, as security fixes only go into the latest release.

Test permissions on a cheap separate AWS account

According to AWS pricing on 18 November 2026, a million standard SQS requests in Frankfurt, eu-central-1, cost USD 0.40, and a million DynamoDB on-demand writes USD 0.76. Even if your whole test suite ran against AWS, a thousand runs a month, each sending 10,000 requests to SQS and making 10,000 writes of 1 KB to DynamoDB, would come to under USD 12. Five LocalStack Base licences cost USD 195 a month, billed annually.

Someone has to set up and maintain the account, and CI needs access without long-lived keys. Tests against AWS run slower and leave resources to clean up. One forgotten resource billed by the hour can eat into that saving: a NAT gateway in Frankfurt is about USD 42 a month, so put a budget alert on the account before you connect it to CI. Stay with LocalStack if your team relies on its IAM policy enforcement, persistent state, Cloud Pods or graphical interface, or if the emulator's fidelity scores for your services are too low.

What it means for a small team

If LocalStack only runs your S3, SQS and DynamoDB tests in CI, run them on the emulator in a separate branch this week and check the fidelity scores for those services on the releases page. Cancel the licences after several green runs in a row.

Move CI tests that run against a real account today to the emulator, except the permission tests, which stay on a separate account with a budget alert.

Originally published on codelevel.pl. Prices are net, for businesses. AWS, Hetzner and OVH are trademarks of their owners; CODELEVEL is not a partner, reseller or representative of any of them.

原文:https://www.a8q9.cn/en/article/aws-emulator-is-a-free-localstack-alternative-for-ci-4acff2.html

相关文章