Files
floci/compatibility-tests/sdk-test-python
Brian Taylor 2bf9b57bd9 fix(lambda): omit Environment when no variables are set (#2838)
* fix(lambda): omit Environment when no variables are set

Real AWS omits the Environment member entirely from CreateFunction,
GetFunction, GetFunctionConfiguration and ListFunctions responses when a
function has no environment variables. Floci always emitted it, as an
empty object.

The Terraform provider reads a present-but-empty Environment back as an
environment {} block in state, so any function declared without variables
plans a removal on every run and never converges. On Lambda@Edge, where
environment variables are not permitted at all, the block can never
legitimately exist and each no-op apply also republishes the function.

Layers, KMSKeyArn, FileSystemConfigs and VpcConfig in the same response
builder already omit-when-empty; Environment was the outlier.

* test(compat): correct Environment assertions to match live AWS

Three assertions in the Python and Java SDK compatibility suites required
an Environment block that real AWS does not send:

  - test_get_function_configuration_environment_always_present
  - test_update_environment_variables_round_trip (the cleared case)
  - LambdaFunctionConfigTest.getFunctionConfigurationHasDefaults

Measured against the live service in both directions: a function created
without variables comes back with no Environment member, and clearing to an
empty Variables map removes it again. The tests encoded Floci's previous
behaviour rather than the API's, which is why they went green.

Also corrects the wording of the Java clear case. It sends an Environment
with no Variables member, which is 'leave unchanged', not 'clear' — live AWS
keeps the existing variables, as Floci already did. The assertion now pins
that instead of describing a clear that never happened.
2026-09-01 10:56:48 -04:00
..

sdk-test-python

Compatibility tests for Floci using boto3 (1.37.1).

Services Covered

Group Description
ssm Parameter Store — put, get, label, history, path, tags
sqs Queues, send/receive/delete, DLQ, visibility
sns Topics, subscriptions, publish, SQS delivery
s3 Buckets, objects, tagging, copy, batch delete
s3-cors CORS configuration
s3-notifications S3 → SQS event notifications
dynamodb Tables, CRUD, batch, TTL, tags
lambda Create/invoke/update/delete functions
iam Users, roles, policies, access keys
sts GetCallerIdentity, AssumeRole, GetSessionToken
secretsmanager Create/get/put/list/delete secrets, versioning, tags
kms Keys, aliases, encrypt/decrypt, data keys, sign/verify
kinesis Streams, shards, PutRecord/GetRecords
cloudwatch-metrics PutMetricData, ListMetrics, GetMetricStatistics, alarms
cloudformation-naming Auto physical name generation, explicit name precedence, cross-reference
cognito User pools, clients, AdminCreateUser, InitiateAuth, GetUser

Requirements

  • Python 3.9+
  • pip

Running

pip install -r requirements.txt

# All groups
pytest tests/ --junit-xml=test-results/junit.xml

# Specific tests
pytest tests/test_s3.py

# Via just (from compatibility-tests/)
just test-python

Configuration

Variable Default Description
FLOCI_ENDPOINT http://localhost:4566 Floci emulator endpoint

AWS credentials are always test / test / us-east-1.

Docker

docker build -t floci-sdk-python .
docker run --rm --network host floci-sdk-python

# Custom endpoint (macOS/Windows)
docker run --rm -e FLOCI_ENDPOINT=http://host.docker.internal:4566 floci-sdk-python