AWSLambdaVPCAccessExecutionRole managed policy

0

Why AWSLambdaVPCAccessExecutionRole managed policy has additional allowing statements for ec2:AssignPrivateIpAddresses and ec2:UnassignPrivateIpAddresses , however a documentation states that a Lambda function only needs ec2:CreateNetworkInterface , ec2:DescribeNetworkInterfaces and ec2:DeleteNetworkInterface to connect to a VPC.

What use-cases should ec2:AssignPrivateIpAddresses and ec2:UnassignPrivateIpAddresses being used for?

1개 답변
0

Hi there,

Managed policies make it faster and more convenient to assign the correct permissions to your resources to meet many common use cases. AWS managed policies don't grant least privilege permissions [1].

Depending on your use case a managed policy can contain more permissive permissions than what you require. If this is the case you can create a custom policy that is more restrictive or more permissive based on your requirements.

The permissions ec2:AssignPrivateIpAddresses and ec2:UnassignPrivateIpAddresses seen in the "AWSLambdaVPCAccessExecutionRole" policy gives the following permissions: AssignPrivateIpAddresses - Assigns one or more secondary private IP addresses to the specified network interface. UnassignPrivateIpAddresses - Unassigns one or more secondary private IP addresses, or IPv4 Prefix Delegation prefixes from a network interface.

At a minimum, your function needs access to Amazon CloudWatch Logs for log streaming. If your function calls other service APIs with the AWS SDK, you must include the necessary permissions in the execution role's policy [2].

When you associate a Lambda function with a VPC, an interface is created within the VPC where traffic from the Lambda function will egress towards other VPC resources. When all functions using this interface is deleted, the interface will also be deleted. When associating a lambda function with a VPC the following permissions are therefore required: ec2:CreateNetworkInterface ec2:DescribeNetworkInterfaces ec2:DeleteNetworkInterface Without these permissions on the Lambda execution role policy, the function cannot be associated with a VPC.

Associating the Lambda to the VPC does not require the following permissions which is included in the managed policy: ec2:AssignPrivateIpAddresses ec2:UnassignPrivateIpAddresses

Reference: [1] https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-getting-started-managed.html [2] https://docs.aws.amazon.com/lambda/latest/dg/lambda-permissions.html

AWS
답변함 10달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인