AWS Emulator vs real AWS: 4 tests that passed only on AWS

I ran the same 31 tests on AWS Emulator and real AWS. The emulator passed 27, AWS passed all 31, and CREATE_COMPLETE hid both problems. Here is what local tests missed and the CI checks I use now.

The CloudFormation stack said  CREATE_COMPLETE . All five resources existed. But the S3 bucket had no CORS rules, even though the template set them.
That was on AWS Emulator. The same template on real AWS created the bucket with its CORS rules in place. If a pipeline only waits for  CREATE_COMPLETE , it can't tell the two apart.
I built one small Python app and one pytest suite, then ran them against AWS Emulator and real AWS. Here are my results:
31 tests, 3 runs on each side
Emulator 1.0.826
AWS,  us-west-2 
Passed
27 each time
31 each time
CORS rules from the template
Missing
Applied
Bad values for 3  AllowedPattern  rules
Accepted
Rejected
The observations recorded by the tests matched across all three runs on each side. The app, tests and template were the same in all six runs.
Both problems had already been reported on GitHub:  #678  for CORS and  #637  for  AllowedPattern . What I'm adding is the comparison with real AWS, along with checks you can use in your own pipeline.

The setup

The app stores a file in S3 and its metadata in DynamoDB. It claims the document ID with a conditional write, uploads the file, then marks the item  READY . If the upload fails, the item stays  PENDING  and the app won't return it.
One CloudFormation template creates everything: two S3 buckets, a bucket policy, a DynamoDB table and a CloudWatch alarm.
CloudFormation on AWS with all five resources at CREATE_COMPLETE

The stack on real AWS. The emulator reported  CREATE_COMPLETE  for all five resources too.
Tool
Version
AWS Emulator
1.0.826, Linux arm64
AWS CLI
2.42.5
Python
3.12.3
boto3 / botocore
1.44.13
pytest
9.2.0
AWS says it  checks the emulator against  us-west-2  , except for global services, so I used that Region for all the tests. I restarted the emulator with empty state before each run.
My two setups weren't identical. The emulator used its own generated credentials, a local CA certificate and  127.0.0.1 , with host-prefix injection turned off. For the AWS runs, I used a long-lived IAM user access key in an isolated test account. That's not what I'd recommend for a pipeline: use a dedicated test account, an assumed role with temporary credentials and a narrow policy, and check the account ID before deploying. The role policy in the repo is a draft I haven't tested yet, so treat it as a starting point. Nothing in the results points to these setup differences as the cause of the failures, but they're worth knowing if you repeat the tests.

Make sure local tests stay local

A missing endpoint setting can send a "local" test to your real AWS account. Before any tests run, my project checks the target, each client's endpoint and the account that answers:
account = clients["sts"].get_caller_identity()["Account"]
if (name == "emulator") != (account == EMULATOR_ACCOUNT):
raise RuntimeError(f"TARGET={name} does not match the account that answered")
The emulator's account is always  000000000000 . Real AWS runs also need  CONFIRM_REAL_AWS=yes  and the expected account ID.

The emulator results

I did one extra run for the screenshots. It isn't one of the three emulator runs in the table. It gave the same result, and its recorded observations matched those runs.
All 31 tests from the extra emulator run, with 4 failed

All 31 tests from the extra emulator run: 27 passed and 4 failed. The emulator ran on an arm64 Linux server.
Emulator summary with 27 passed and 4 failed, followed by the cleanup results

The end of the same run: 27 passed and 4 failed. Cleanup worked, and the leftover check found nothing.
All 13 tests for normal use and errors passed. They cover conditional writes, pagination, missing objects, checksum errors, oversized items and 8 parallel saves with the same ID, where only one can win. The error tests check the HTTP status and error code. The saved error messages also matched on both sides once names and IDs were removed. That covers these cases only, not all of S3 and DynamoDB.
The four failures were all in CloudFormation behavior.

Problem 1: the CORS rules were missing

This is the part of the template that matters:
CorsConfiguration:
CorsRules:
- AllowedMethods: [GET, PUT]
AllowedOrigins: ["http://localhost:3000"]
AllowedHeaders: ["*"]
The test reads the rules back from S3 instead of trusting the stack status:
def test_cors_from_template_is_applied(aws, out, observe):
got = cors_of(aws["s3"], out["BucketName"])
observe(cors=got)
assert isinstance(got, list) and {k: got[0].get(k) for k in RULES} == RULES
On the emulator, the stack completed but S3 had no CORS rules:
tests/test_4_infrastructure.py:43: in test_cors_from_template_is_applied
E AssertionError: assert (False)
E + where False = isinstance('NoSuchCORSConfiguration', list)
Is CORS itself broken on the emulator? To find out, I added a control test that sets the same rules on a second bucket through the S3 API, then reads them back. That test passed on both sides. The emulator could store the rules, but they weren't there after the CloudFormation deployment.
On AWS, the rules from the template were there:
CORS rules from the template on the real S3 bucket

The same template on real AWS.

Problem 2: CloudFormation accepted values it should reject

 AllowedPattern  should stop bad parameter values before CloudFormation creates anything. The value  has space!  doesn't match any of these patterns:
Pattern
Emulator
AWS
 ^\w{1,64}$ 
Accepted
Rejected
 ^\w\w$ 
Accepted
Rejected
 ^[a-z]{1,1000}$ 
Accepted
Rejected
For the first pattern, AWS returned:
Parameter 'Name' must match pattern ^\w{1,64}$
The emulator created the stack instead. But it didn't ignore every pattern. It correctly rejected the same value for  ^[a-z]{1,64}$ . The person who reported #637 suspects a regex size limit. My tests don't prove the cause.

My first version of this test was too loose

My first version counted any  ValidationError  containing the word "pattern" as a rejection. But my test stack's name also contained "pattern", so an unrelated error that mentioned the stack could have passed as a rejection.
A code review found this, and I confirmed it with a fake error. The test now looks for the exact problem:
if (e.response["Error"]["Code"] != "ValidationError"
or not re.search(r"Parameter '?Name'? must match pattern", message)):
raise
Each of the three patterns also has a test with a valid value, which must be accepted. The results in this article are from the stricter version. I hadn't saved the error messages from the earlier AWS runs, so I ran the full suite three more times on each side. For tests like this, save the error message as well as the pass or fail result.

Check the resources, then their settings

 scripts/verify_stack.py  gets the stack's resources from CloudFormation, then asks each service if they exist. These are its checks:
CHECKS = {
"AWS::S3::Bucket": lambda c, i: c["s3"].head_bucket(Bucket=i),
"AWS::S3::BucketPolicy": lambda c, i: c["s3"].get_bucket_policy(Bucket=i),
"AWS::DynamoDB::Table": lambda c, i: c["dynamodb"].describe_table(TableName=i),
"AWS::CloudWatch::Alarm":
lambda c, i: c["cloudwatch"].describe_alarms(AlarmNames=[i])["MetricAlarms"],
}
It fails if a resource is missing or if it doesn't know how to check that type. An access error stops the check, because it doesn't prove that the resource is missing.
To test it on the emulator, I deleted the alarm and bucket policy directly, without using CloudFormation. CloudFormation still showed  CREATE_COMPLETE , but the check found both missing. Here are those two lines and the exit code:
DocumentsBucketPolicy AWS::S3::BucketPolicy CREATE_COMPLETE MISSING
ThrottleAlarm AWS::CloudWatch::Alarm CREATE_COMPLETE MISSING
after exit=1
This check would not have caught the CORS problem. In my extra emulator run, it found all five resources. The CORS test in that run still failed:
The resource check found all five resources on the emulator

From my extra emulator run.  FOUND  means the bucket exists, not that its CORS rules do.
The bucket existed, but its CORS rules didn't. You need a separate test for each setting your app depends on.

An unexpected bucket-policy observation

The stack's bucket policy has two Deny rules. One blocks reads under  denied/ . The other blocks uploads under  encrypted/  unless the request includes the  AES256  encryption header.
Excerpt of the bucket policy with both Deny rules

An excerpt. The console cuts off the last brackets. The full policy is in  infra/template.yaml .
On AWS Emulator 1.0.826, my requests got  403 AccessDenied  in both scenarios I tested, including requests signed with the emulator's own key. I also tested the read rule on its own. When I deleted the policy, the read worked. When I pointed the rule at another prefix, reads were blocked there instead. When I restored the policy, the original read was blocked again.
That surprised me, because the  emulator's security page  says it doesn't evaluate S3 bucket policies the way AWS does, and tells you not to use it to test resource-based policies.
I don't take this as evidence that the emulator enforces bucket policies correctly. It's two scenarios on one version, and it says nothing about whether permissions are evaluated consistently or securely. The emulator's documentation is still the source of truth for its limits.
This isn't a new discovery about Deny rules.  Another report in the repo  already says the emulator reaches a bucket policy Deny, but doesn't enforce some prefix conditions. So I still run authorization and security tests against real AWS, and so should you.

What about the missing alarm?

 A DEV post  that tested emulator 1.0.322 found an alarm marked  CREATE_COMPLETE  that didn't appear in  describe-alarms . That didn't happen with my alarm on 1.0.826. The post doesn't include its alarm definition, so this doesn't prove that the problem is fixed.
The alarm from the template on real AWS

The alarm from my template, on real AWS.

Three layers of checks

The main lesson for me: a successful deployment isn't the same as a correct configuration. I now think about checks in three layers:
  1. Resources exist. CloudFormation says they were created, and each service's API can find them.
  1. Settings are right. CORS rules, encryption, billing mode and every other property the app depends on are actually configured.
  1. Security and behavior work. Permissions, access rules and the app's workflows behave correctly, tested on real AWS.
In this experiment, the emulator handled resource existence checks and most of the configuration and application tests. Authorization and security checks still belong on real AWS.

How to use this in your pipeline

  1. On every change: start a clean emulator, deploy the stack, run the resource check, then run your app and settings tests.
  1. Before release: run the same tests in a separate AWS test account. Include your permission tests.
  1. After every run: delete the test resources, then check that they're gone. A failed cleanup should fail the job. An early version of my AWS script could report success after a failed cleanup. The code review found that too, and I fixed it.
  1. Pin the emulator version: rerun the tests when you upgrade, because the results can change.
  1. Make known failures expire: mark each one as a strict expected failure and link its issue. The job stays green while the problem exists, then fails when that test starts passing. That's your reminder to remove the exception, and any workaround you no longer need.
I list the four known failures by test name:
KNOWN_FAILURES = {
"test_cors_from_template_is_applied": ISSUES + "678",
"test_allowed_pattern_rejects_bad_value[w64]": ISSUES + "637",
"test_allowed_pattern_rejects_bad_value[ww]": ISSUES + "637",
"test_allowed_pattern_rejects_bad_value[az1000]": ISSUES + "637",
}
A small pytest hook marks those tests, but only for emulator runs in CI:
def pytest_collection_modifyitems(items):
if os.environ.get("EXPECT_KNOWN_FAILURES") != "1" or os.environ.get("TARGET") != "emulator":
return
for item in items:
if item.name in KNOWN_FAILURES:
item.add_marker(pytest.mark.xfail(
strict=True, raises=AssertionError, reason=KNOWN_FAILURES[item.name]))
 strict=True  fails the job if a known problem starts passing.  raises=AssertionError  means other errors, such as a lost connection, still fail the job. On real AWS, the hook does nothing.
The workflow in  .github/workflows/emulator-tests.yml  is set up to run on pull requests and pushes to  main . It checks the pinned emulator's hash, signature and signing key before installing it. Then  run-local.sh  waits for the emulator's health check, runs everything and cleans up. The emulator version is pinned, so a fix will show up when you upgrade it, not on the day it's released.
The workflow passed on GitHub Actions (Ubuntu runner, the x86_64 package) in about a minute, and the same CI mode passed locally on arm64:
27 passed, 4 xfailed
stack_up=0 verify_stack=0 pytest=0 stack_down=0 leftovers=0
You can see  the run on GitHub .
The emulator-tests job on GitHub Actions with every step passing

The  emulator-tests  workflow on GitHub Actions. The suite step ran the 31 tests against the pinned emulator.
By default,  run-local.sh  doesn't allow any failures. On 1.0.826, that means the four failures above make it exit with an error.

Try it yourself

The full code, tests, results and cleanup steps are on GitHub:  MuhammadAbraiz/aws-emulator-vs-real-aws  (tag  v1.0.1 ).
You need Linux, Python 3.12, AWS CLI v2 and  AWS Emulator . The README has the full steps.
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
cp emulator-env.example.sh my-env.sh # then set the two paths
EMULATOR_ENV="$PWD/my-env.sh" OWNER_TAG=me scripts/run-local.sh my-run
The emulator doesn't isolate the code it runs from your machine, so only run code you trust. This project doesn't use Lambda.
AWS runs create real resources that can cost money.  AWS.md  lists the resources and cleanup steps. My estimate for three runs was under $1, but that isn't a measured bill, so check the prices for your Region. The included IAM policy is a draft that I haven't tested. After my last AWS run, I checked for this project's stacks, buckets, tables and alarms, and found none left.

What my tests don't show

  • They cover one emulator version, one AWS Region, one small app and 31 tests.
  • They don't compare speed. Local calls and calls to AWS use different network paths.
  • They don't compare full API responses.
  • The GitHub issues may have changed since I ran these tests on November 29, 2026.

Additional implementation notes

Physical IDs. In an early version of the resource check, I used the bucket policy's physical ID as its bucket name. On the emulator, that made it report an existing policy as missing. There, the ID looked like  <stack>-<logical ID>-<suffix> . In all six of my AWS runs (three with the earlier suite), it was the bucket name.  A report in the emulator repo  says AWS uses the generated format too, so this may not be an emulator bug. I don't know the reason, and I didn't test  Ref . The check no longer relies on this ID. You tell it which bucket resource to use:
python -m scripts.verify_stack emu-vs-aws-docs DocumentsBucketPolicy=DocumentsBucket

Takeaway

The emulator handled my app's normal use and error cases well, so it's useful for quick feedback. But  CREATE_COMPLETE  didn't prove that the settings were right. Check that your resources exist, test the settings your app needs, then run the same tests on AWS before you release.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article