π‘οΈ AWS Lambda Function is not in a VPCπ’
- Contextual name: π‘οΈ Function is not in a VPCπ’
- ID:
/ce/ca/aws/lambda/function-in-vpc - Tags:
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
- Policy Type:
COMPLIANCE_POLICY - Policy Categories:
SECURITY
Logicβ
- π§ prod.logic.yamlπ’
Similar Policiesβ
- AWS Security Hub: [Lambda.3] Lambda functions should be in a VPC
Descriptionβ
Descriptionβ
This policy identifies AWS Lambda functions that are not configured to run within a Virtual Private Cloud (VPC). By default, Lambda functions run in a managed AWS environment and do not have access to private resources within your VPC.
Lambda@Edge functions do not support VPC configuration and therefore cannot be attached to a VPC.
Rationaleβ
Running Lambda functions within a VPC enables secure access to private resources such as Amazon RDS, Amazon ElastiCache, and internal APIs. It also allows the use of security groups and network ACLs, and enables outbound traffic to be routed through a NAT Gateway for IP-based allowlisting.
Auditβ
This policy flags an AWS Lambda Function as
INCOMPLIANTwhen theVPC IDfield is empty.Lambda@Edge functions are marked as
INAPPLICABLE, as VPC attachment is not supported for Lambda@Edge.
Remediationβ
Remediationβ
Attach a Lambda Function to a VPCβ
Configure the Lambda function to run within a Virtual Private Cloud (VPC) by associating it with the appropriate subnets and security groups. Ensure the selected subnets have network connectivity to the required resources.
From Command Lineβ
Use the
update-function-configurationcommand with the--vpc-configparameter:aws lambda update-function-configuration \
--function-name {{function-name}} \
--vpc-config SubnetIds=subnet-id1,subnet-id2,SecurityGroupIds=sg-idNotesβ
- Select private subnets that provide access to required resources such as Amazon RDS, ElastiCache, or internal services.
- Ensure the associated security group allows the necessary inbound and outbound traffic.
- If the function requires outbound internet access, configure a NAT Gateway in the VPC.