Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Rule: Lambda functions should be in a VPC

Guideline specifying that Lambda functions must be within a VPC for enhanced security

RuleLambda functions should be in a VPC
FrameworkNIST 800-53 Revision 5
Severity
Low

Rule Description:

Lambda functions should be deployed within a Virtual Private Cloud (VPC) in accordance with the NIST 800-53 Revision 5 security guidelines. By running Lambda functions inside a VPC, you can enhance network security and control access to resources within your VPC.

Troubleshooting Steps:

If Lambda functions are not running within a VPC, follow the steps below for troubleshooting:

  1. 1.

    Check Lambda Function Configuration: Verify the configuration settings of the Lambda function to ensure it is not already configured to run within a VPC.

  2. 2.

    Confirm VPC Availability: Validate the availability of the intended VPC where the Lambda function needs to be deployed.

  3. 3.

    Check Subnet Configuration: Ensure that at least one subnet within the chosen VPC has been configured properly to support Lambda functions. The subnet should have subnets groups associated and correctly configured with necessary Route Tables, Internet Gateways (IGW), and Network Access Control Lists (NACLs).

  4. 4.

    Verify Security Group Rules: Validate that the Security Groups associated with the Lambda function allow the required inbound and outbound traffic. Ensure the necessary ports and protocols are open in the security group rules.

  5. 5.

    Check IAM Policies: Ensure that the IAM (Identity and Access Management) policies assigned to the Lambda function have the necessary permissions to access resources within the VPC.

  6. 6.

    Test Network Connectivity: Perform network connectivity tests to ensure the Lambda function can communicate with other resources within the VPC.

Necessary Code:

If you need to modify the Lambda function to run within a VPC, use the following code snippet as an example:

import boto3

def lambda_handler(event, context):
    # Add your existing Lambda function code here
    
    # Configure the VPC settings for the Lambda function
    client = boto3.client('lambda')
    response = client.update_function_configuration(
        FunctionName='your-lambda-function-name',
        VpcConfig={
            'SubnetIds': ['subnet-xxxxxxxx', 'subnet-yyyyyyyy'],
            'SecurityGroupIds': ['sg-xxxxxxxx']
        }
    )
    
    # Any additional Lambda function code goes here
    
    return {
        'statusCode': 200,
        'body': 'Function configured to run within a VPC'
    }

Ensure you replace

'your-lambda-function-name'
with the actual name of your Lambda function,
'subnet-xxxxxxxx', 'subnet-yyyyyyyy'
with the subnet IDs in your VPC, and
'sg-xxxxxxxx'
with the appropriate security group ID.

Step-by-Step Guide for Remediation:

Follow the steps outlined below to configure your Lambda function to run within a VPC:

  1. 1.

    Determine the VPC: Identify the Virtual Private Cloud (VPC) where the Lambda function should be deployed. Note down the VPC ID for further use.

  2. 2.

    Choose Subnets: Select at least one subnet within the identified VPC that the Lambda function will utilize. Record the subnet IDs for configuration.

  3. 3.

    Configure Security Group: Ensure that a Security Group exists within the chosen VPC, or create a new one specifically for the Lambda function if needed. Make sure the Security Group allows the required inbound and outbound traffic.

  4. 4.

    Access IAM Console: Access the AWS Management Console and navigate to the IAM service.

  5. 5.

    Lambda Function IAM Role: Locate and access the appropriate IAM role that is associated with the Lambda function.

  6. 6.

    Update IAM Role: Modify the IAM role's policy to grant necessary permissions for accessing resources within the VPC.

  7. 7.

    Update Lambda Function Configuration: Modify the Lambda function's configuration to run within the specified VPC.

  8. 8.

    Enter VPC Details: In the Lambda function configuration, enter the VPC ID and the subnet IDs associated with the chosen VPC.

  9. 9.

    Save Changes and Test: Save the updated Lambda function configuration and test its functionality to ensure it runs successfully within the VPC.

By following these steps, you can securely deploy and run Lambda functions within a VPC, aligning with the NIST 800-53 Revision 5 guidelines.

Is your System Free of Underlying Vulnerabilities?
Find Out Now