Skip to content

EC2

CloudMock emulates Amazon EC2, providing comprehensive support for VPC networking, instances, security groups, Elastic IPs, network interfaces, NAT gateways, internet gateways, route tables, VPC endpoints, VPC peering, and network ACLs.

OperationStatusNotes
CreateVpcSupportedCreates a VPC
DescribeVpcsSupportedLists VPCs
DeleteVpcSupportedDeletes a VPC
ModifyVpcAttributeSupportedModifies VPC attributes
CreateSubnetSupportedCreates a subnet in a VPC
DescribeSubnetsSupportedLists subnets
DeleteSubnetSupportedDeletes a subnet
OperationStatusNotes
RunInstancesSupportedLaunches instances
DescribeInstancesSupportedLists instances
TerminateInstancesSupportedTerminates instances
StopInstancesSupportedStops instances
StartInstancesSupportedStarts stopped instances
DescribeInstanceStatusSupportedReturns instance status
OperationStatusNotes
CreateSecurityGroupSupportedCreates a security group
DescribeSecurityGroupsSupportedLists security groups
DeleteSecurityGroupSupportedDeletes a security group
AuthorizeSecurityGroupIngressSupportedAdds inbound rules
AuthorizeSecurityGroupEgressSupportedAdds outbound rules
RevokeSecurityGroupIngressSupportedRemoves inbound rules
RevokeSecurityGroupEgressSupportedRemoves outbound rules
OperationStatusNotes
AllocateAddressSupportedAllocates an Elastic IP
ReleaseAddressSupportedReleases an Elastic IP
AssociateAddressSupportedAssociates an EIP with an instance
DisassociateAddressSupportedDisassociates an EIP
DescribeAddressesSupportedLists Elastic IPs
CreateNetworkInterfaceSupportedCreates an ENI
DescribeNetworkInterfacesSupportedLists ENIs
DeleteNetworkInterfaceSupportedDeletes an ENI
CreateNetworkAclSupportedCreates a network ACL
DescribeNetworkAclsSupportedLists network ACLs
DeleteNetworkAclSupportedDeletes a network ACL
CreateNetworkAclEntrySupportedAdds a network ACL entry
DeleteNetworkAclEntrySupportedRemoves a network ACL entry
OperationStatusNotes
CreateInternetGatewaySupportedCreates an internet gateway
AttachInternetGatewaySupportedAttaches IGW to a VPC
DetachInternetGatewaySupportedDetaches IGW from a VPC
DeleteInternetGatewaySupportedDeletes an internet gateway
DescribeInternetGatewaysSupportedLists internet gateways
CreateNatGatewaySupportedCreates a NAT gateway
DescribeNatGatewaysSupportedLists NAT gateways
DeleteNatGatewaySupportedDeletes a NAT gateway
CreateRouteTableSupportedCreates a route table
DescribeRouteTablesSupportedLists route tables
DeleteRouteTableSupportedDeletes a route table
CreateRouteSupportedAdds a route
DeleteRouteSupportedRemoves a route
ReplaceRouteSupportedReplaces a route
AssociateRouteTableSupportedAssociates a route table with a subnet
DisassociateRouteTableSupportedDisassociates a route table
OperationStatusNotes
CreateVpcEndpointSupportedCreates a VPC endpoint
DescribeVpcEndpointsSupportedLists VPC endpoints
DeleteVpcEndpointsSupportedDeletes VPC endpoints
CreateVpcPeeringConnectionSupportedCreates a peering connection
AcceptVpcPeeringConnectionSupportedAccepts a peering connection
DeleteVpcPeeringConnectionSupportedDeletes a peering connection
OperationStatusNotes
CreateTagsSupportedAdds tags to resources
DeleteTagsSupportedRemoves tags from resources
DescribeTagsSupportedLists tags
import { EC2Client, RunInstancesCommand, CreateVpcCommand } from '@aws-sdk/client-ec2';
const client = new EC2Client({
endpoint: 'http://localhost:4566',
region: 'us-east-1',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
const vpc = await client.send(new CreateVpcCommand({ CidrBlock: '10.0.0.0/16' }));
console.log(vpc.Vpc.VpcId);
const instances = await client.send(new RunInstancesCommand({
ImageId: 'ami-12345678',
InstanceType: 't2.micro',
MinCount: 1,
MaxCount: 1,
}));
console.log(instances.Instances[0].InstanceId);
import boto3
client = boto3.client('ec2',
endpoint_url='http://localhost:4566',
region_name='us-east-1',
aws_access_key_id='test',
aws_secret_access_key='test')
vpc = client.create_vpc(CidrBlock='10.0.0.0/16')
print(vpc['Vpc']['VpcId'])
instances = client.run_instances(
ImageId='ami-12345678',
InstanceType='t2.micro',
MinCount=1, MaxCount=1)
print(instances['Instances'][0]['InstanceId'])
cloudmock.yml
services:
ec2:
enabled: true
  • Instances do not run actual compute workloads
  • AMI validation is not performed
  • Network traffic between resources is not simulated
  • CIDR range validation is performed but some edge cases may differ