Enhancement: implement EC2 instance filtering by subnet-id
(#3694)
Co-authored-by: Tony Greising-Murschel <tony@platform.sh>
This commit is contained in:
parent
def46b5130
commit
9feabf5479
@ -379,6 +379,7 @@ filter_dict_attribute_mapping = {
|
|||||||
"network-interface.private-dns-name": "private_dns",
|
"network-interface.private-dns-name": "private_dns",
|
||||||
"private-dns-name": "private_dns",
|
"private-dns-name": "private_dns",
|
||||||
"owner-id": "owner_id",
|
"owner-id": "owner_id",
|
||||||
|
"subnet-id": "subnet_id",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -606,6 +606,29 @@ def test_get_instances_filtering_by_instance_group_id():
|
|||||||
reservations[0]["Instances"].should.have.length_of(1)
|
reservations[0]["Instances"].should.have.length_of(1)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_ec2
|
||||||
|
def test_get_instances_filtering_by_subnet_id():
|
||||||
|
client = boto3.client("ec2", region_name="us-east-1")
|
||||||
|
|
||||||
|
vpc_cidr = ipaddress.ip_network("192.168.42.0/24")
|
||||||
|
subnet_cidr = ipaddress.ip_network("192.168.42.0/25")
|
||||||
|
|
||||||
|
resp = client.create_vpc(CidrBlock=str(vpc_cidr),)
|
||||||
|
vpc_id = resp["Vpc"]["VpcId"]
|
||||||
|
|
||||||
|
resp = client.create_subnet(CidrBlock=str(subnet_cidr), VpcId=vpc_id)
|
||||||
|
subnet_id = resp["Subnet"]["SubnetId"]
|
||||||
|
|
||||||
|
client.run_instances(
|
||||||
|
ImageId=EXAMPLE_AMI_ID, MaxCount=1, MinCount=1, SubnetId=subnet_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
reservations = client.describe_instances(
|
||||||
|
Filters=[{"Name": "subnet-id", "Values": [subnet_id]}]
|
||||||
|
)["Reservations"]
|
||||||
|
reservations.should.have.length_of(1)
|
||||||
|
|
||||||
|
|
||||||
@mock_ec2_deprecated
|
@mock_ec2_deprecated
|
||||||
def test_get_instances_filtering_by_tag():
|
def test_get_instances_filtering_by_tag():
|
||||||
conn = boto.connect_ec2()
|
conn = boto.connect_ec2()
|
||||||
|
Loading…
Reference in New Issue
Block a user