01 Run list-functions command (OSX/Linux/UNIX) to list the name of each Amazon Lambda function available in the selected AWS cloud region:
aws lambda list-functions
--region us-east-1
--output table
--query 'Functions[*].FunctionName'
02 The command output should return a table with the requested function name(s):
----------------------------
| ListFunctions |
+--------------------------+
| cc-app-worker-function |
| cc-s3-logging-function |
+--------------------------+
03 Run get-function command (OSX/Linux/UNIX) using the name of the Amazon Lambda function that you want to examine as the identifier parameter and custom query filters to describe the IDs of the VPC subnets configured for the selected function:
aws lambda get-function
--region us-east-1
--function-name cc-app-worker-function
--query 'Configuration.VpcConfig.SubnetIds'
04 The command output should return the identifier (ID) of each VPC subnet associated with the selected function:
[
"subnet-01234abcd1234abcd",
"subnet-0abcd1234abcd1234"
]
05 Run describe-route-tables command (OSX/Linux/UNIX) using the ID of the VPC subnet that you want to examine as the identifier parameter and custom filters to describe the routes configured for the route table associated with the selected subnet:
aws ec2 describe-route-tables
--region us-east-1
--filters "Name=association.subnet-id,Values=subnet-01234abcd1234abcd"
--query 'RouteTables[*].Routes[]'
06 The command output should return the configuration information available for each defined route:
[
{
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": "igw-0abcd1234abcd1234",
"Origin": "CreateRoute",
"State": "active"
},
{
"DestinationCidrBlock": "10.0.0.0/16",
"GatewayId": "local",
"Origin": "CreateRouteTable",
"State": "active"
}
]
Check the
"DestinationCidrBlock",
"GatewayId", and
"State" attributes for each configured route. If the
"DestinationCidrBlock" attribute is set to
"0.0.0.0/0",
"GatewayId" is pointing to an Internet Gateway (e.g. igw-0abcd1234abcd1234), and the
"State" is set to
"active", the selected subnet is public, therefore your Amazon Lambda function is not configured to use only private VPC subnets.
07 Repeat step no. 3 - 6 for each Lambda function available in the selected AWS region.
08 Change the AWS region by updating the --region command parameter value and repeat steps no. 1 – 7 to perform the Audit process for other AWS regions.