Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.
Python awsaws-emulatoraws-localaws-sdkdevtoolsdockerdynamodbec2emulatorlambdalocalstacklocalstack-alternativeministackmock-awsopen-sourcepythons3sqsterraform
fix(stepfunctions): name a snapshot's lifecycle State in aws-sdk:ec2 results (#2317)
Maximilian Bandle66ae4fe60df4
diff --git a/ministack/services/stepfunctions.py b/ministack/services/stepfunctions.pyindex 0e42583f..edfb1b15 100644--- a/ministack/services/stepfunctions.py+++ b/ministack/services/stepfunctions.py@@ -4222,12 +4222,14 @@ _EC2_FIELDS_BY_PARENT = {("ipPermissionsEgress", "groups"): "UserIdGroupPairs",("productCodes", "productCode"): "ProductCodeId",("productCodes", "type"): "ProductCodeType",+ ("snapshotSet", "status"): "State",("volumeSet", "status"): "State",}# EC2 reuses some names depending on action. Special case for flattening_EC2_FIELDS_BY_ACTION = {("AttachVolume", "status"): "State",+ ("CreateSnapshot", "status"): "State",("CreateVolume", "status"): "State",("DetachVolume", "status"): "State",("StartInstances", "instancesSet"): "StartingInstances",diff --git a/tests/test_stepfunctions.py b/tests/test_stepfunctions.pyindex 42ddf46f..c028de62 100644--- a/tests/test_stepfunctions.py+++ b/tests/test_stepfunctions.py@@ -2283,6 +2283,28 @@ def test_sfn_aws_sdk_ec2_describe_volumes_returns_sdk_shape(sfn_sync, ec2):ec2.delete_volume(VolumeId=volume_id)+def test_sfn_aws_sdk_ec2_snapshots_return_state(sfn_sync, ec2):+ """aws-sdk:ec2:createSnapshot and describeSnapshots return State, not Status."""+ suffix = _uuid_mod.uuid4().hex[:8]+ az = ec2.describe_availability_zones()["AvailabilityZones"][0]["ZoneName"]+ volume_id = ec2.create_volume(AvailabilityZone=az, Size=1)["VolumeId"]+ snapshot_id = None+ try:+ made = _run_sdk_task(sfn_sync, f"sdk-snap-new-{suffix}", "ec2:createSnapshot", {"VolumeId": volume_id})+ snapshot_id = made["SnapshotId"]+ assert made["State"] == "completed"+ assert "Status" not in made++ result = _run_sdk_task(sfn_sync, f"sdk-snap-{suffix}", "ec2:describeSnapshots", {"SnapshotIds": [snapshot_id]})+ snapshot = result["Snapshots"][0]+ assert snapshot["State"] == "completed"+ assert "Status" not in snapshot+ finally:+ if snapshot_id:+ ec2.delete_snapshot(SnapshotId=snapshot_id)+ ec2.delete_volume(VolumeId=volume_id)++def test_sfn_aws_sdk_ec2_instances_return_sdk_shape(sfn_sync, ec2):"""runInstances/describeInstances return Instances[0].State.Name, not InstanceState."""suffix = _uuid_mod.uuid4().hex[:8]