File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,19 @@ module "lambda" {
9090 # aws_iam_policy.inside[0].id, # This will result in an error message and is why we use local.policy_name_inside
9191 ]
9292
93+ inline_iam_policy = <<- JSON
94+ {
95+ "Version": "2012-10-17",
96+ "Statement": [
97+ {
98+ "Effect": "Deny",
99+ "Action": "ec2:DescribeInstanceTypes",
100+ "Resource": "*"
101+ }
102+ ]
103+ }
104+ JSON
105+
93106 context = module. this . context
94107
95108 depends_on = [aws_iam_policy . inside ]
Original file line number Diff line number Diff line change @@ -91,3 +91,10 @@ resource "aws_iam_role_policy_attachment" "custom" {
9191 role = aws_iam_role. this [0 ]. name
9292 policy_arn = each. value
9393}
94+
95+ resource "aws_iam_role_policy" "inline" {
96+ count = try ((local. enabled && var. inline_iam_policy != null ), false ) ? 1 : 0
97+
98+ role = aws_iam_role. this [0 ]. name
99+ policy = var. inline_iam_policy
100+ }
Original file line number Diff line number Diff line change @@ -233,3 +233,9 @@ variable "iam_policy_description" {
233233 description = " Description of the IAM policy for the Lambda IAM role"
234234 default = " Provides minimum SSM read permissions."
235235}
236+
237+ variable "inline_iam_policy" {
238+ type = string
239+ description = " Inline policy document (JSON) to attach to the lambda role"
240+ default = null
241+ }
You can’t perform that action at this time.
0 commit comments