I have the following Lambda function set in AWS which have to return the params of AWS Network Firewall:
import boto3
import json
session = boto3.session.Session()
nf_client = session.client(
service_name = "network-firewall",
endpoint_url= "https://network-firewall.eu-west-2.amazonaws.com"
)
def lambda_handler(event, context):
response = nf_client.describe_firewall(
FirewallName="DemoFirewall2")
return 1
What I have checked
I have two subnets and 4 routing tables:
10.1.0.0/16 local
0.0.0.0/0 vpce-firewallEndpoint
10.1.0.0/16 local
0.0.0.0/0 igw-InternetGateway
10.1.0.0/16 local
10.1.2.0/24 vpce-firewallEndpoint
10.1.0.0/16 local
The traffic from the client subnet is routed to the firewall subnet and then routed to the IGW.
Guess I am missing something with the session configarion because the lambda probably don't know which firewall to describe.
Lambda functions in a VPC never get assigned a public IP address, so they can't use an Internet Gateway directly. A Lambda function in a VPC has to be deployed in a private subnet, with a route to a NAT Gateway, in order to access things outside the VPC.
If your Lambda function doesn't need to access any VPC resources then there is no benefit to deploying the function inside the VPC, it only causes issues such as the one you are encountering.