Skip to content

Commit

Permalink
Add trusted relations for AWS roles (#128)
Browse files Browse the repository at this point in the history
* add trusted relations

Signed-off-by: Jorge Turrado <[email protected]>

* fix resources

Signed-off-by: Jorge Turrado <[email protected]>

---------

Signed-off-by: Jorge Turrado <[email protected]>
  • Loading branch information
JorTurFer committed Oct 10, 2023
1 parent 89b582c commit 4e1b9ba
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions terraform/modules/aws/iam/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@

locals {
workload_role_name = "keda-workload-1"
workload_trust_relations = jsonencode(
[for role in aws_iam_role.roles :
{
Sid : "",
Effect : "Allow"
Action : "sts:AssumeRole",
Principal : {
"AWS" : role.arn
}
}]
)
}

resource "aws_iam_user" "e2e_test" {
Expand Down Expand Up @@ -141,7 +152,7 @@ resource "aws_iam_policy" "policy" {
{
"Effect": "Deny",
"Action": "sqs:*",
"Resource": "arn:aws:sqs:asume-role-queue-*:589761922677:*"
"Resource": "arn:aws:sqs:*:589761922677:asume-role-queue-*"
},
{
"Effect": "Allow",
Expand Down Expand Up @@ -179,16 +190,7 @@ resource "aws_iam_role" "workload_role" {
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
"Statement": ${local.workload_trust_relations}
}
EOF
}
Expand All @@ -210,7 +212,7 @@ resource "aws_iam_policy" "workload_role_policy" {
{
"Effect": "Allow",
"Action": "sqs:*",
"Resource": "arn:aws:sqs:asume-role-queue-*:589761922677:*"
"Resource": "arn:aws:sqs:*:589761922677:asume-role-queue-*"
}
]
}
Expand Down

0 comments on commit 4e1b9ba

Please sign in to comment.