EC2
Parity grade: A · SDK aws-sdk-go-v2/service/ec2@v1.338.4 · last audited 2026-10-11 (5cb6665a0) · protocol ec2-query (AWS query -> XML)
Category: Compute · View PARITY.md on GitHub · All Services
In-memory EC2 control plane covering instances, networking, storage, images, fleets, IPAM and more. By default instances are metadata records. With the Docker provider each instance is a real container.
Quick start
bash
export AWS_ENDPOINT_URL=http://localhost:8000
VPC=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16 --query Vpc.VpcId --output text)
SUBNET=$(aws ec2 create-subnet --vpc-id "$VPC" --cidr-block 10.0.1.0/24 \
--query Subnet.SubnetId --output text)
SG=$(aws ec2 create-security-group --group-name my-sg --description "My SG" \
--vpc-id "$VPC" --query GroupId --output text)
aws ec2 run-instances --image-id ami-12345678 --instance-type t3.micro \
--min-count 1 --max-count 1 --subnet-id "$SUBNET" --security-group-ids "$SG"
aws ec2 describe-instances
aws ec2 terminate-instances --instance-ids i-00000001Supported operations
The service handles several hundred EC2 operations. Areas:
| Area | Covers |
|---|---|
| Instances | run, describe, start, stop, reboot, terminate, attributes, instance types, status, scheduled instances, instance event windows |
| Images and key pairs | AMIs (register, copy, create, deregister, attributes), key pairs, VM import and export |
| Storage | EBS volumes, snapshots, volume attachment and modification |
| VPC | VPCs, subnets, route tables, internet and NAT gateways, network ACLs, DHCP options, prefix lists, VPC CIDR associations, flow logs, encryption control |
| Security | security groups and rules, network interfaces |
| Addresses | Elastic IPs, IP pools, BYOIP |
| Connectivity | VPC endpoints and endpoint services, VPC peering, VPN gateways and connections, Client VPN, Transit Gateway (attachments, peering, route tables, multicast), carrier and local gateways |
| Compute capacity | launch templates, EC2 Fleet, Spot Fleet, Spot requests, placement groups, capacity reservations, capacity blocks and Capacity Manager, reserved instances, dedicated and Mac hosts |
| Networking tools | Traffic Mirroring, Network Insights, Route Server, Verified Access, IPAM |
| Account | tags, account attributes, regions and availability zones |
Configuration
| Flag | Env | Default | Purpose |
|---|---|---|---|
--ec2-provider | EC2_PROVIDER | inmemory | inmemory for metadata only, docker to launch containers as instances |
--ec2-docker-image | EC2_DOCKER_IMAGE | amazonlinux:2 | Image the Docker provider launches instances from |
--ec2-docker-network | EC2_DOCKER_NETWORK | daemon default bridge | Docker network for instance containers |
--ec2-docker-flags | GOPHERSTACK_EC2_DOCKER_FLAGS | none | Extra docker run options: --privileged, -e, -v, --cap-add, --cap-drop, -m, --cpus, --network, -p. Others are rejected at startup |
--ec2-docker-ssh-host-ip | EC2_DOCKER_SSH_HOST_IP | 127.0.0.1 | Host IP that mapped SSH ports bind to. 0.0.0.0 exposes them externally |
--ec2-docker-ssh-port-min, --ec2-docker-ssh-port-max | EC2_DOCKER_SSH_PORT_MIN, EC2_DOCKER_SSH_PORT_MAX | 0 | Host port range for SSH. 0 lets Docker pick |
--ec2-docker-ebs-volumes | GOPHERSTACK_EC2_DOCKER_EBS_VOLUMES | false | Map EBS volumes to Docker volumes mounted at /mnt/ebs/<device> |
| none | EC2_JANITOR_INTERVAL | 1m | Janitor tick |
| none | EC2_TERMINATED_TTL | 1h | How long terminated instances stay listed |
| none | EC2_CANCELLED_SPOT_TTL | 6h | How long cancelled spot requests stay listed |
Differences from AWS
WARNING
With the default inmemory provider no compute runs. Security group rules never filter traffic between instances, even with the Docker provider.
- The in-memory provider accepts any well-formed
InstanceTypeand anyami-prefixedImageId. The Docker provider rejects an unknownImageIdwithInvalidAMIID.NotFound. - Docker provider: Windows and Bottlerocket AMIs run the default image. AMI
Architecturedoes not choose a platform-specific image. Deregistering an AMI does not remove its committed image.CreateImagecaptures the container filesystem only, not attached EBS volumes. - Docker EBS volumes: data attached to a running instance is copied in at attach and back at detach or terminate, because Docker cannot add a mount to a live container. The copy registry is lost on restart.
- Snapshot and AMI sharing is account-aware only for resources created by an explicit-account caller. Instances and volumes are not account-scoped.
DescribeApplicationStatusnever reports a real status or transition: instances have no application to health-check.
Parity & Coverage
| Metric | Value |
|---|---|
| Feature families | 22 (22 ok) |
| Known gaps | 4 |
| Structural gaps (can't be emulated) | 18 |
| Deferred items | 5 |
| Resource leaks | ok |
Known Gaps
- Snapshot and AMI sharing is caller-aware only for resources created or copied by an explicit-account caller (OwnerID = that account); resources owned by the backend account stay visible to every caller, and instances, volumes and other resources are not account-scoped (gopherstack-tnqy.6).
- RunInstances (in-memory provider) accepts any syntactically valid InstanceType and any ami-prefixed ImageId: the instance-type catalog is partial and many in-repo callers launch synthetic AMIs, so unknown-but-well-formed values are not rejected. The docker provider rejects an unknown ImageId with InvalidAMIID.NotFound.
- Docker provider AMI binding: Windows and Bottlerocket seeded AMIs have no Linux container equivalent and run the configured default image; AMI Architecture does not select a platform-specific image (the host platform decides); deregistering an AMI does not remove its committed docker image; CreateImage snapshots the container filesystem only, not attached non-root EBS volumes or EBS snapshots.
- Docker provider EBS volumes (opt-in): AttachVolume on a running instance copies data in and DetachVolume/terminate copy it back (Docker cannot add a mount to a live container), so runtime-attached data reaches the Docker volume at detach or terminate rather than continuously, the copy-sync registry is in memory (lost on restart), and a volume mounted at launch stays mounted after DetachVolume; the root volume has no Docker volume, so DeleteOnTermination=false on the root device does not retain it; Docker volumes of EBS volumes deleted by fleet or shutdown-behavior termination are reaped on the next Terminate or DeleteVolume call.
Structural Gaps
These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.
- DescribeInstanceStatus application-status.status filter and InstanceStatus.ApplicationStatus (2026-10-07): derived from live HTTP(S) health-check results; see the DescribeApplicationStatus entry below.
- DescribeApplicationStatusCheckAssociationsOutput.Tags (2026-10-07): the pinned deserializer reads only associationSet and nextToken, so the member can never reach an SDK client.
- "DescribeApplicationStatus's ApplicationStatus.StatusSince and ApplicationStatusDetail (the real per-check status-transition timestamp and breakdown list) are always zero/empty, and the aggregated status itself never reports 'ok'/'impaired'/ 'initializing' (see the application_status_checks family note). Real AWS derives all of this from actually executing HTTP(S) health checks against the target instance's application over real network traffic between the AWS control plane and the instance. This mock has no network path to an instance's application at all — instances here are metadata records, not running workloads — so there is no data source that could ever produce a genuine check result, timestamp, or transition here, in an emulator or not. Reporting anything but the explicitly-defined 'not-applicable'/'insufficient-data'/ 'suppressed' subset would be fabrication. (gopherstack-8pce, 2026-08-07)"
- "GetIpamDiscoveredRoutes/GetIpamRouteProtectionFindings (2026-09-19): no BGP route discovery or RPKI route-validation pipeline exists in this emulator -- both ops validate their real FK (IpamResourceDiscoveryId / IpamId, correct NotFound on an unknown one) but always return an empty, correctly-shaped result rather than fabricate routes or findings."
- "Request fields still unread (2026-10-05): DescribeNetworkInsightsAnalyses AnalysisStartTime/AnalysisEndTime (analysis items carry startDate only, no end date; the SDK does not say which bound each field compares), CreateNetworkInsightsPath FilterAtSource/FilterAtDestination (no path-analysis engine consumes them), ExportTransitGatewayRoutes Filters (shapes an S3 file this backend does not render)."
- DescribeNetworkInsightsAccessScopeAnalyses.AnalysisStartTimeBegin/AnalysisStartTimeEnd (2026-10-05): analyses now carry startDate and both bounds are inclusive per api_op_DescribeNetworkInsightsAccessScopeAnalyses.go:31-37 ("on or after"/"on or before").
- DescribeCapacityBlockOfferings.StartDateRange (2026-10-05): tool false positive, applied via the boundsCapacityBlockOfferings spec table in describe_post_specs.go and covered by a typed SDK test.
- GetCapacityManagerMetricData.FilterBy (2026-10-05): always-empty, no capacity-manager metric data is modeled to filter.
- GetCapacityManagerMetricDimensions.FilterBy (2026-10-05): always-empty, no capacity-manager metric data is modeled to filter.
- StartNetworkInsightsAnalysis.FilterInArns (2026-10-05): no path-analysis engine exists to consume it.
- StartNetworkInsightsAnalysis.FilterOutArns (2026-10-05): no path-analysis engine exists to consume it.
- AWS/EC2 utilisation metrics (2026-10-07): CPUUtilization/Network*/Disk* are emitted only when the Compute provider implements UsageReporter (DockerCompute does); instances without a runtime have no utilisation to report.
- Filter.N leftovers with no backing data: GetCoipPoolUsage (no per-address usage), DescribeOutpostLags service-link-VIF family (Outpost hardware), DescribeElasticGpus (retired, always empty); DescribeVpcEncryptionControls documents no filter names.
- Security-group traffic enforcement between docker-backed instances (2026-10-11, gopherstack-cefu7.29): filtering intra-VPC traffic per security group needs iptables/nftables or NET_ADMIN in the container or host root; Docker user-defined bridges offer no per-endpoint policy API. SG rules therefore only drive host port publishing, never packet filtering, and no enforcement flag exists.
- Republishing ports on a running docker instance (2026-10-11, gopherstack-cefu7.29): Docker cannot change port bindings of an existing container, so Authorize/RevokeSecurityGroupIngress affect only instances launched afterwards (stop/start keeps the original bindings).
- Recycle Bin (ListVolumes/Snapshots/ImagesInRecycleBin, Restore*FromRecycleBin): retention rules belong to the rbin service, which is not emulated, so deletes are always permanent.
- CancelImportTask: ImportImage/ImportSnapshot complete synchronously because no async import pipeline exists, so the happy path is unreachable.
- reqfielddiff remainder with nothing observable to read it: ModifyCapacityReservation.Accept, DescribeReservedInstancesOfferings.MaxInstanceCount, GetConsoleOutput.Latest, CreateImage.NoReboot, ImportImage/ImportSnapshot.RoleName, GetIpam* StartTime/EndTime/MaxResults, ProvisionByoipCidr.PubliclyAdvertisable, DescribeInstanceTypes.IncludeUnsupportedInRegion, StopInstances.Force/SkipOsShutdown, TerminateInstances.SkipOsShutdown, CreateDefaultSubnet.Ipv6Native (no VPC IPv6 blocks), ModifyInstanceAttribute.BlockDeviceMappings NoDevice/VirtualName, ProvisionIpamPoolCidr.VerificationMethod, CreateReplaceRootVolumeTask.VolumeInitializationRate, CreateMacSystemIntegrityProtectionModificationTask.MacCredentials, CreateSnapshot(s)/CreateImage Location. resolve:ssm: aliases resolve only parameters in the SSM backend (AWS public /aws/service/* parameters belong to ssm). Disassociate/UnassignPrivateNatGatewayAddress skip AWS's 350s default drain on purpose: Terraform waiters expect immediate release.
Deferred Items
- trunk_enclave.go's TrunkInterfaceAssociation.Tags: genuinely cannot migrate to the shared tag store — see tag_dual_storage note above (no TagSpecifications on the real create call, no ResourceType enum entry, so CreateTags could never target it even if registered). Left as the single remaining embedded-Tags field in the codebase, by design. RE-VERIFIED (gopherstack-8pce, 2026-07-31 pass): re-read AssociateTrunkInterfaceInput and the ResourceType enum in the installed SDK directly — the constraint still holds exactly as documented. This is NOT a reason to hold the grade at B: the reasoning is a genuine, unchanged real-API limitation (same treatment sql_ha.go's fabricated Tags field got — deleted, not migrated, in the prior pass), not an unaudited gap.
- DeleteQueuedReservedInstances: PurchaseReservedInstancesOffering has no future-dated purchase mode, so no Reserved Instance is ever created in the queued state and the success path is reachable only via direct state manipulation in tests.
- NAT gateway create-time PrivateIpAddress/SecondaryAllocationIds/SecondaryPrivateIpAddressCount/SecondaryPrivateIpAddresses — not modeled; private-connectivity mode is modeled (2026-10-11 note).
- VPC Endpoint Service / VPC Endpoint DnsEntries, security groups, IP prefixes, policy documents, PrivateLink-managed-service fields — not modeled, no backing data; see vpc_endpoints note.
- Snapshot.DataEncryptionKeyId and AMI-backing-snapshot InvalidSnapshot.InUse protection have no backing data; per-ENI security-group tracking is a larger separate feature; SearchTransitGatewayRoutes does not enforce its required Filters.
Audited Feature Families
| Feature Family | Status |
|---|---|
parity4_new_ops | ok |
tags | ok |
instance_attrs | ok |
instance_lifecycle | ok |
sg_rules | ok |
filters | ok |
storage_layer | ok |
vpc_lifecycle | ok |
nat_gateway_addr | ok |
tag_cleanup | ok |
tag_dual_storage | ok |
transit_gateway | ok |
ebs_snapshot_lineage | ok |
eni_attach_detach | ok |
pagination | ok |
nat_gateway | ok |
vpc_endpoints | ok |
key_pairs | ok |
tgw_policy_table_entries | ok |
application_status_checks | ok |
unrecorded_describe_ops_sweep41 | ok |
ipam_internet_registry_and_routing_policy | ok |
