Skip to content

Commit a7b30ee

Browse files
authored
fix: Swap deprecated inline_policy block for aws_iam_role_policy (#63)
1 parent 7451536 commit a7b30ee

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

examples/complete/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ data "aws_iam_policy_document" "example" {
3131
statement {
3232
actions = ["s3:GetObject"]
3333
effect = "Allow"
34-
resources = ["dynamodb:CreateTable"]
34+
resources = ["arn:aws:s3:::amzn-s3-demo-bucket/*"]
3535
}
3636
}

examples/complete/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ variable "enabled" {
4040
}
4141

4242
variable "enterprise_slug" {
43-
default = false
43+
default = ""
4444
description = "Enterprise slug for GitHub Enterprise Cloud customers."
45-
type = bool
45+
type = string
4646
}
4747

4848
variable "force_detach_policies" {

main.tf

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ resource "aws_iam_role" "github" {
3232
permissions_boundary = var.iam_role_permissions_boundary
3333
tags = var.tags
3434

35-
dynamic "inline_policy" {
36-
for_each = var.iam_role_inline_policies
35+
}
3736

38-
content {
39-
name = inline_policy.key
40-
policy = inline_policy.value
41-
}
42-
}
37+
resource "aws_iam_role_policy" "inline_policies" {
38+
for_each = { for k, v in var.iam_role_inline_policies : k => v if var.enabled }
39+
name = each.key
40+
policy = each.value
41+
role = aws_iam_role.github[0].id
4342
}
4443

4544
resource "aws_iam_role_policy_attachment" "admin" {

0 commit comments

Comments
 (0)