How can I make a boto3 call to describe vpcs to return vpcs that have a Network Firewall attached?

0

I have been reading over the boto3 documentation and trying various solutions. So far I have the sample code below.

`    endpoint = ec2_client.describe_vpc_endpoints(
            Filters=[
                {"Name": "vpc-endpoint-type", "Values": "GatewayLoadBalancer"},
                {"Name": "vpc-id", "Values": vpc_id},
                {"Name": "tag", "Values": "AWSNetworkFirewallManaged"}
            ]
        )`

Issue I am running into (or maybe I'm missing something) is this returns the vpc endpoints even if it doesn't match the filter.

I want to make sure I am not missing anything and this is syntactically correct followin Boto3 standards for the Filter specified here in the documentation - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_vpc_endpoints

It does not seem to be working for me and I am not sure why.

Any guidence or suggestions will help.

1 Answer
0

This might not be the full answer but this line doesn't look quite right:

{"Name": "tag", "Values": "AWSNetworkFirewallManaged"}

The documentation you linked says the syntax for this is

{"Name": "tag:some-tag-name", "Values": "some-tag-value"}

Or if you just want to match presence of a specific key without caring about its value, then

{"Name": "tag-key", "Values": "some-tag-name"}

EXPERT
answered a year ago
  • So this would be the right syntax?

    {"Name": "tag:Key", "Values": "AWSNetworkFirewallManaged"}

    Is this only specific to the tags key?

  • If you just need to filter on the AWSNetworkFirewallManaged tag being present, then the right syntax is:

    {"Name": "tag-key", "Values": "AWSNetworkFirewallManaged"}

    If you need to filter on the AWSNetworkFirewallManaged tag having a specific value, e.g. AWSNetworkFirewallManaged=true, then the right syntax is:

    {"Name": "tag:AWSNetworkFirewallManaged", "Values": "true"}

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions