From 149fb674cc398242855281e68f240d00483dea83 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Fri, 6 Sep 2024 09:29:46 -0700 Subject: [PATCH] Ipv6Address count for NetworkInterface (#3656) --- scripts/update_schemas_manually.py | 14 +++++ scripts/update_snapshot_results.sh | 1 + .../all/aws_ec2_networkinterface/manual.json | 14 +++++ .../us_east_1/aws-ec2-networkinterface.json | 8 +++ .../integration/aws-ec2-networkinterface.json | 60 +++++++++++++++++++ .../integration/aws-ec2-networkinterface.yaml | 17 ++++++ .../integration/test_integration_templates.py | 9 +++ 7 files changed, 123 insertions(+) create mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_ec2_networkinterface/manual.json create mode 100644 test/fixtures/results/integration/aws-ec2-networkinterface.json create mode 100644 test/fixtures/templates/integration/aws-ec2-networkinterface.yaml diff --git a/scripts/update_schemas_manually.py b/scripts/update_schemas_manually.py index dde8809c82..ce557dadf7 100755 --- a/scripts/update_schemas_manually.py +++ b/scripts/update_schemas_manually.py @@ -727,6 +727,20 @@ ), ], ), + ResourcePatch( + resource_type="AWS::EC2::NetworkInterface", + patches=[ + Patch( + values={ + "dependentExcluded": { + "Ipv6AddressCount": ["Ipv6Addresses"], + "Ipv6Addresses": ["Ipv6AddressCount"], + }, + }, + path="/", + ), + ], + ), ResourcePatch( resource_type="AWS::EC2::SecurityGroup", patches=[ diff --git a/scripts/update_snapshot_results.sh b/scripts/update_snapshot_results.sh index efaf8c38f0..43836e6130 100755 --- a/scripts/update_snapshot_results.sh +++ b/scripts/update_snapshot_results.sh @@ -5,6 +5,7 @@ cfn-lint test/fixtures/templates/integration/dynamic-references.yaml -e -c I --f cfn-lint test/fixtures/templates/integration/resources-cloudformation-init.yaml -e -c I --format json > test/fixtures/results/integration/resources-cloudformation-init.json cfn-lint test/fixtures/templates/integration/ref-no-value.yaml -e -c I --format json > test/fixtures/results/integration/ref-no-value.json cfn-lint test/fixtures/templates/integration/availability-zones.yaml -e -c I --format json > test/fixtures/results/integration/availability-zones.json +cfn-lint test/fixtures/templates/integration/aws-ec2-networkinterface.yaml -e -c I --format json > test/fixtures/results/integration/aws-ec2-networkinterface.json # public/ cfn-lint test/fixtures/templates/public/lambda-poller.yaml -e -c I --format json > test/fixtures/results/public/lambda-poller.json diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_ec2_networkinterface/manual.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_ec2_networkinterface/manual.json new file mode 100644 index 0000000000..ed90e2d4d9 --- /dev/null +++ b/src/cfnlint/data/schemas/patches/extensions/all/aws_ec2_networkinterface/manual.json @@ -0,0 +1,14 @@ +[ + { + "op": "add", + "path": "/dependentExcluded", + "value": { + "Ipv6AddressCount": [ + "Ipv6Addresses" + ], + "Ipv6Addresses": [ + "Ipv6AddressCount" + ] + } + } +] diff --git a/src/cfnlint/data/schemas/providers/us_east_1/aws-ec2-networkinterface.json b/src/cfnlint/data/schemas/providers/us_east_1/aws-ec2-networkinterface.json index b6a4624034..14ebbc4259 100644 --- a/src/cfnlint/data/schemas/providers/us_east_1/aws-ec2-networkinterface.json +++ b/src/cfnlint/data/schemas/providers/us_east_1/aws-ec2-networkinterface.json @@ -96,6 +96,14 @@ "type": "object" } }, + "dependentExcluded": { + "Ipv6AddressCount": [ + "Ipv6Addresses" + ], + "Ipv6Addresses": [ + "Ipv6AddressCount" + ] + }, "primaryIdentifier": [ "/properties/Id" ], diff --git a/test/fixtures/results/integration/aws-ec2-networkinterface.json b/test/fixtures/results/integration/aws-ec2-networkinterface.json new file mode 100644 index 0000000000..6f72aa91e0 --- /dev/null +++ b/test/fixtures/results/integration/aws-ec2-networkinterface.json @@ -0,0 +1,60 @@ +[ + { + "Filename": "test/fixtures/templates/integration/aws-ec2-networkinterface.yaml", + "Id": "9d40fd01-0117-1816-b924-0b0c89ee7a5e", + "Level": "Error", + "Location": { + "End": { + "ColumnNumber": 20, + "LineNumber": 15 + }, + "Path": [ + "Resources", + "NetworkInterface", + "Properties", + "Ipv6Addresses" + ], + "Start": { + "ColumnNumber": 7, + "LineNumber": 15 + } + }, + "Message": "'Ipv6Addresses' should not be included with 'Ipv6AddressCount'", + "ParentId": null, + "Rule": { + "Description": "When certain properties are specified other properties should not be included", + "Id": "E3020", + "ShortDescription": "Validate that when a property is specified another property should be excluded", + "Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentexcluded" + } + }, + { + "Filename": "test/fixtures/templates/integration/aws-ec2-networkinterface.yaml", + "Id": "e26370d1-ed25-a14c-9a48-7cabc88945ec", + "Level": "Error", + "Location": { + "End": { + "ColumnNumber": 23, + "LineNumber": 17 + }, + "Path": [ + "Resources", + "NetworkInterface", + "Properties", + "Ipv6AddressCount" + ], + "Start": { + "ColumnNumber": 7, + "LineNumber": 17 + } + }, + "Message": "'Ipv6AddressCount' should not be included with 'Ipv6Addresses'", + "ParentId": null, + "Rule": { + "Description": "When certain properties are specified other properties should not be included", + "Id": "E3020", + "ShortDescription": "Validate that when a property is specified another property should be excluded", + "Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentexcluded" + } + } +] diff --git a/test/fixtures/templates/integration/aws-ec2-networkinterface.yaml b/test/fixtures/templates/integration/aws-ec2-networkinterface.yaml new file mode 100644 index 0000000000..c7f3faa3cb --- /dev/null +++ b/test/fixtures/templates/integration/aws-ec2-networkinterface.yaml @@ -0,0 +1,17 @@ +Parameters: + SubnetId: + Type: AWS::EC2::Subnet::Id + SecurityGroupId: + Type: AWS::EC2::SecurityGroup::Id +Resources: + NetworkInterface: + Type: AWS::EC2::NetworkInterface + Properties: + Description: "a network interface" + GroupSet: + - !Ref SecurityGroupId + SourceDestCheck: false + SubnetId: !Ref SubnetId + Ipv6Addresses: + - Ipv6Address: abc + Ipv6AddressCount: 1 diff --git a/test/integration/test_integration_templates.py b/test/integration/test_integration_templates.py index 8daf33905e..0ee00f4e55 100644 --- a/test/integration/test_integration_templates.py +++ b/test/integration/test_integration_templates.py @@ -47,6 +47,15 @@ class TestQuickStartTemplates(BaseCliTestCase): ), "exit_code": 2, }, + { + "filename": ( + "test/fixtures/templates/integration/aws-ec2-networkinterface.yaml" + ), + "results_filename": ( + "test/fixtures/results/integration/aws-ec2-networkinterface.json" + ), + "exit_code": 2, + }, ] def test_templates(self):