Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Lambda should depend on policy attachments #327

Conversation

x539
Copy link
Contributor

@x539 x539 commented Jul 8, 2022

Description

Added all policy-attachments to the deponds_on of the 'aws_lambda_function'

Motivation and Context

When the lambda is created the execution-role with all its
policies should be in place.

Some policies like VPC are a hard requirement for lambda creation
which fill fail if they are not already in place.

Fixes #326

Breaking Changes

May introduce circular dependencies, where policies some how depend on the lambda.
Those policies could created / attached outside of this module.

How Has This Been Tested?

  • I have tested and validated these changes using the provided examples/with-vpc
  • I have executed pre-commit run -a on my pull request

@x539 x539 changed the title fix: lambda should depend on policy-attachments (fixes #326) Fix: lambda should depend on policy-attachments (fixes #326) Jul 8, 2022
@x539 x539 changed the title Fix: lambda should depend on policy-attachments (fixes #326) fix: Lambda should depend on policy-attachments (fixes #326) Jul 8, 2022
When the lambda is created the execution-role with all its
policies should be in place.

Some policies like VPC are a hard requirement for lambda creation
which fill fail if they are not already in place.
@x539 x539 force-pushed the fix-lambda-creation-dependencies branch from 47cd415 to 01cfe9c Compare July 14, 2022 09:43
@billylaing
Copy link

Appreciate the fix. I am having the same issue.

@basschipper
Copy link

The same applies if you destroy the stack. First, the policies are then removed, which means that the Lambda no longer has rights to remove the ENIs and Terraform therefore cannot remove the security group because it is still "in-use" by these ENIs.

@antonbabenko antonbabenko changed the title fix: Lambda should depend on policy-attachments (fixes #326) fix: Lambda should depend on policy attachments Sep 1, 2022
@antonbabenko
Copy link
Member

@x539 Thanks a lot for opening this issue and providing a complete and reproducible code snippet in #326! It saved me some time while testing this.

@antonbabenko antonbabenko merged commit b4eef74 into terraform-aws-modules:master Sep 1, 2022
antonbabenko pushed a commit that referenced this pull request Sep 1, 2022
### [4.0.1](v4.0.0...v4.0.1) (2022-09-01)

### Bug Fixes

* Lambda should depend on policy attachments ([#327](#327)) ([b4eef74](b4eef74))
@antonbabenko
Copy link
Member

This PR is included in version 4.0.1 🎉

@github-actions
Copy link

github-actions bot commented Nov 8, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Lambda within VPC fails due to missing policy
5 participants