Skip to content

Commit

Permalink
remove inline_policy argument (#42)
Browse files Browse the repository at this point in the history
* remove inline_policy argument

* fix role

* add tags
  • Loading branch information
bobsut authored Oct 13, 2024
1 parent f80fe93 commit dd2e99c
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,30 @@ data "aws_iam_policy_document" "main" {
}
}

resource "aws_iam_role" "main" {
name = var.name

assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "ec2.amazonaws.com"
}
}
]
})
resource "aws_iam_policy" "main" {
name = var.name
policy = data.aws_iam_policy_document.main.json
tags = var.tags
}

inline_policy {
name = "Main"
policy = data.aws_iam_policy_document.main.json
data "aws_iam_policy_document" "instance_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
effect = "Allow"
}
}

tags = var.tags
}
resource "aws_iam_role" "main" {
name = var.name
assume_role_policy = data.aws_iam_policy_document.instance_assume_role_policy.json
tags = var.tags
}

resource "aws_iam_role_policy_attachment" "main" {
role = aws_iam_role.main.name
policy_arn = aws_iam_policy.main.arn
}

0 comments on commit dd2e99c

Please sign in to comment.