Skip to content

Adding VPC Access Policy when VpcConfig is present #1169

@spockNinja

Description

@spockNinja

Description:

We are building a modular service structure and have several lambda functions launching within a VPC. When tearing down the VPC, we encountered issues where the ENIs that were created for the lambda functions were left dangling.

We now know that one solution is to add the managed role for VPC access. What I would like to know, is if AWS SAM would be open to a PR that automatically checks for VPC config and adds the appropriate managed policy, much like it does for the basic lambda execution policy.

Steps to reproduce the issue:

  1. Create a function in a VPC, that does not have permissions to tear down an ENI
  2. Tear down the function.
  3. Attempt to tear down the VPC.

Observed result:
The VPC fails to delete because of dependencies on the dangling ENIs.

Expected result:
AWS SAM Transform adds the correct permissions automatically when VpcConfig is present.
The VPC deletes successfully.

Possible Solution:
Adding logic to https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/model/sam_resources.py#L189 much like the if self.Tracing block to add a managed policy that allows the lambda function to clean up ENIs when it is done with them.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions