Skip to content

Commit 8e42935

Browse files
authored
feat: switching from an inline policy (deprecated) to a aws_role_policy resource (#57)
1 parent f3147b4 commit 8e42935

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

modules/role/main.tf

+8-6
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,17 @@ resource "aws_iam_role" "rw" {
146146
## Provision the inline terraform policy for the rw role
147147
resource "aws_iam_role_policy" "tfstate_apply_rw" {
148148
name = "tfstate_apply"
149-
role = aws_iam_role.rw.id
150149
policy = data.aws_iam_policy_document.tfstate_apply.json
150+
role = aws_iam_role.rw.id
151151
}
152152

153153
## Provision the inline policies for the read write role
154154
resource "aws_iam_role_policy" "inline_policies_rw" {
155155
for_each = merge(var.read_write_inline_policies, var.default_inline_policies)
156156

157157
name = each.key
158-
role = aws_iam_role.rw.id
159158
policy = each.value
159+
role = aws_iam_role.rw.id
160160
}
161161

162162
## Attach the read write policies to the read write role
@@ -210,9 +210,11 @@ resource "aws_iam_role" "sr" {
210210
name = local.state_reader_role_name
211211
path = var.role_path
212212
tags = merge(var.tags, { Name = local.state_reader_role_name })
213+
}
213214

214-
inline_policy {
215-
name = "tfstate_remote"
216-
policy = data.aws_iam_policy_document.tfstate_remote.json
217-
}
215+
## Attach the state reader policies to the state reader role
216+
resource "aws_iam_role_policy" "sr" {
217+
name = "tfstate_remote"
218+
policy = data.aws_iam_policy_document.tfstate_remote.json
219+
role = aws_iam_role.sr.id
218220
}

0 commit comments

Comments
 (0)