From 71daf79ffdb63e49ba6621c9ace5165caa52cc0d Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sat, 25 Dec 2021 15:44:38 -0100 Subject: [PATCH] EC2 - Verify NIC can be created without SG (#4720) --- .../test_elastic_network_interfaces.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_ec2/test_elastic_network_interfaces.py b/tests/test_ec2/test_elastic_network_interfaces.py index 7da7b0598..0eebe17c2 100644 --- a/tests/test_ec2/test_elastic_network_interfaces.py +++ b/tests/test_ec2/test_elastic_network_interfaces.py @@ -231,6 +231,25 @@ def test_elastic_network_interfaces_with_groups_boto3(): ) +@mock_ec2 +def test_elastic_network_interfaces_without_group(): + # ENI should use the default SecurityGroup if not provided + ec2 = boto3.resource("ec2", region_name="us-east-1") + client = boto3.client("ec2", "us-east-1") + + vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16") + subnet = ec2.create_subnet(VpcId=vpc.id, CidrBlock="10.0.0.0/18") + + my_eni = subnet.create_network_interface() + + all_enis = client.describe_network_interfaces()["NetworkInterfaces"] + [eni["NetworkInterfaceId"] for eni in all_enis].should.contain(my_eni.id) + + my_eni = [eni for eni in all_enis if eni["NetworkInterfaceId"] == my_eni.id][0] + my_eni["Groups"].should.have.length_of(1) + my_eni["Groups"][0]["GroupName"].should.equal("default") + + # Has boto3 equivalent @requires_boto_gte("2.12.0") @mock_ec2_deprecated