-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
feat: Use inline instead of managed policies #615
base: master
Are you sure you want to change the base?
feat: Use inline instead of managed policies #615
Conversation
d042c7d
to
f86cdf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the first look at this PR, it looks pretty good, but why are only some policy attachments changed? Should we update vpc
, tracing
, etc also?
Happy to change those as well but I was not sure because it looks like it they are copied from AWS-managed policies:
Apparently, there was an issue with only creating an |
@antonbabenko, or did you mean using the policy from the "copy" data block in a # Copying AWS managed policy to be able to attach the same policy with multiple roles without overwrites by another function
data "aws_iam_policy" "vpc" {
count = local.create_role && var.attach_network_policy ? 1 : 0
arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/service-role/AWSLambdaENIManagementAccess"
}
resource "aws_iam_policy" "vpc" {
count = local.create_role && var.attach_network_policy ? 1 : 0
name = "${local.policy_name}-vpc"
path = var.policy_path
policy = data.aws_iam_policy.vpc[0].policy
tags = var.tags
}
resource "aws_iam_role_policy_attachment" "vpc" {
count = local.create_role && var.attach_network_policy ? 1 : 0
role = aws_iam_role.lambda[0].name
policy_arn = aws_iam_policy.vpc[0].arn
} to # Copying AWS managed policy to be able to attach the same policy with multiple roles without overwrites by another function
data "aws_iam_policy" "vpc" {
count = local.create_role && var.attach_network_policy ? 1 : 0
arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/service-role/AWSLambdaENIManagementAccess"
}
resource "aws_iam_role_policy" "vpc" {
count = local.create_role && var.attach_network_policy ? 1 : 0
name = "${local.policy_name}-vpc"
role = aws_iam_role.lambda[0].name
policy = data.aws_iam_policy.vpc[0].policy
} |
This PR has been automatically marked as stale because it has been open 30 days |
f86cdf4
to
a1d27a7
Compare
@antonbabenko, I updated I don't think there is anything left, or is there? |
a1d27a7
to
42a3fb6
Compare
* Remove unused variable `policy_path`
42a3fb6
to
d2f44e8
Compare
This PR has been automatically marked as stale because it has been open 30 days |
@antonbabenko Looking forward to your review 🙂 |
This PR has been automatically marked as stale because it has been open 30 days |
@antonbabenko ping 🙂 |
Description
This MR replaces customer-managed policies with inline policies becuase the policies are only used for the Lambda function. See also Managed policies and inline policies.
Motivation and Context
Fixes #607
Breaking Changes
If users have attached the customer-managed policies to other resources, this change is breaking (in theory) since the new policies will be inline. But it is very unlikely that users did this.
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectsI have tested this branch against on of my projects using this module. Below is the terraform plan output
Expand
I have executed
pre-commit run -a
on my pull request