AWS Integration Tests
This directory documents the AWS-focused integration test area used by the repo.
Main Uses
- FakeCloud-backed development and CI testing
- optional real-AWS validation
- phased execution and circular-dependency scenarios
- Terraform-oriented and hybrid execution comparisons where useful
- runtime-function Terraform integration tests that depend on the custom Go
netherframe/runtimeprovider
Common Prerequisites
nf generate providers hashicorp/aws
For runtime Terraform integration tests, also see Runtime Provider Test Notes.
For FakeCloud-based runs, give pytest --nf-use-fakecloud (on by default for
libs/netherframe.core/tests/integration):
uv run pytest --nf-use-fakecloud backends/netherframe.backends.aws/tests
Typical Commands
uv run poe test-core
Targeted examples:
uv run pytest libs/netherframe.core/tests/integration/aws/test_fakecloud_integration.py -v
uv run pytest libs/netherframe.core/tests/integration/aws/test_iam_s3_deployment.py -v
FakeCloud Tests
AWS integration tests run against FakeCloud, a local
AWS emulator. Every suite that uses it (libs/netherframe.core/tests/integration,
backends/netherframe.backends.aws/tests, the AWS discovery FakeCloud tests) shares one
container, and each test runs in its own AWS account in it.
cd libs/netherframe.core && uv run pytest tests/integration -n 4 # on by default here
cd backends/netherframe.backends.aws && uv run pytest tests --nf-use-fakecloud
uv run poe test-discovery-aws-fakecloud
Docker is the only prerequisite. netherframe.testing.fakecloud defines the container
(docker run of ghcr.io/faiscadev/fakecloud:0.51.0 on port 4566, with the Docker socket
mounted for Lambda) and starts it when a test first needs it. Test processes register under a
lock in the system temp directory, so xdist workers and test runs started at the same time share
the container, and the last one to finish stops it. A container you start yourself is never
stopped by tests:
uv run python -m netherframe.testing.fakecloud start # also: stop, status
One account per test
FakeCloud resolves the account of each request from its access key. The fakecloud_account
fixture (from the netherframe-fakecloud pytest plugin that netherframe.core registers, so every
suite has it) creates an account with a random 12-digit id and an admin access key, and resets
the account's state after the test:
def test_bucket(fakecloud_account):
app = App(nf_id="app")
with Stack(nf_scope=app, nf_id="stack") as stack:
provider = AwsProvider(nf_scope=stack, nf_id="aws", **fakecloud_account.provider_config())
S3Bucket(nf_scope=stack, nf_id="bucket", bucket=fakecloud_account.unique_name("nf-test"), nf_provider=provider)
...
assert fakecloud_account.client("s3").list_buckets()["Buckets"]
client(service)/boto_config(): boto3 clients in the accountprovider_config():AwsProviderarguments with every service endpoint pointed at FakeCloudarn(service, resource, region=...): ARNs with the account's idunique_name(prefix):<prefix>-<account id>; S3 bucket names are unique across accounts, as in AWS
Because tests do not share state, use fixed readable names, skip cleanup, and let the tests run
in parallel. Regional graph-ownership tests require FakeCloud 0.51.0 or newer: 0.45.1
keeps SSM state per account rather than per account and region. The provider config
disables automatic account-id discovery for compatibility with its S3 calls; graph
ownership reads the configured provider's aws_caller_identity data source explicitly.
Options and environment
Netherframe's own test-run knobs are pytest options (pytest --help lists them under
"Netherframe test runs"); FakeCloud's container keeps its own variables.
| Option or variable | Default | Effect |
|---|---|---|
--nf-use-fakecloud / --no-nf-use-fakecloud |
on for nf.core integration, off elsewhere | run FakeCloud tests (skipped otherwise) |
--nf-fakecloud-autostart / --no-nf-fakecloud-autostart |
on | start the container when FakeCloud is down; off skips instead |
FAKECLOUD_ENDPOINT |
http://localhost:4566 |
where FakeCloud listens (its port is published there) |
FAKECLOUD_CONTAINER_NAME |
nf-fakecloud |
container name |
FAKECLOUD_IMAGE |
ghcr.io/faiscadev/fakecloud:0.51.0 |
image to run |
FAKECLOUD_REGION, FAKECLOUD_ACCOUNT_ID, FAKECLOUD_LOG |
us-east-1, FakeCloud's, info |
passed to the container |
Real AWS Notes
- use a dedicated profile or sandbox account
- keep tests cost-aware
- clean up failed resources promptly