-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Explicitly assume with condition matching role arn #283
fix: Explicitly assume with condition matching role arn #283
Conversation
Signed-off-by: Fernando Miguel <github@FernandoMiguel.net>
if I understand the issue linked - this is still not valid, no? If a user uses |
@bryantbiggs there is no way to use I still think we should default |
Signed-off-by: Fernando Miguel <github@FernandoMiguel.net>
this is a sample of the plan output # module.base_system.module.argocd[0].module.argocd_iam_role_sa_cross_cluster.data.aws_iam_policy_document.this[0] will be read during apply
# (config refers to values not yet known)
<= data "aws_iam_policy_document" "this" {
+ id = (known after apply)
+ json = (known after apply)
+ statement {
+ actions = [
+ "sts:AssumeRole",
]
+ effect = "Allow"
+ sid = "ExplicitSelfRoleAssumption"
+ condition {
+ test = "ArnLike"
+ values = [
+ (known after apply),
]
+ variable = "aws:PrincipalArn"
}
+ principals {
+ identifiers = [
+ "*",
]
+ type = "AWS"
}
}
+ statement {
+ actions = [
+ "sts:AssumeRoleWithWebIdentity",
]
+ effect = "Allow"
+ condition {
+ test = "StringEquals"
+ values = [
+ "sts.amazonaws.com",
]
+ variable = "oidc.eks.us-east-1.amazonaws.com/id/XXXX:aud"
}
+ condition {
+ test = "StringEquals"
+ values = [
+ "system:serviceaccount:argocd-system:argocd-application-controller",
+ "system:serviceaccount:argocd-system:argocd-server",
]
+ variable = "oidc.eks.us-east-1.amazonaws.com/id/XXXX:sub"
}
+ principals {
+ identifiers = [
+ "arn:aws:iam::XXXX:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/XXXX",
]
+ type = "Federated"
}
}
} |
so a few things here:
|
Using a wildcard in the case of prefix might work, did not test that. I entirely agree with #2 |
Signed-off-by: Fernando Miguel <github@FernandoMiguel.net>
Signed-off-by: Fernando Miguel <github@FernandoMiguel.net>
@bryantbiggs I've tried to address your concerns |
HI team, Thanks in advance. |
condition { | ||
test = "ArnLike" | ||
variable = "aws:PrincipalArn" | ||
values = ["arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${var.role_name_condition}"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see the failed CI checks - these should all be a local
values = ["arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${var.role_name_condition}"] | |
values = ["arn:${local.partition}:iam::${local.account_id}:role${var.role_path}${local.role_name_condition}"] |
Signed-off-by: Fernando Miguel <github@FernandoMiguel.net>
Signed-off-by: Fernando Miguel <github@FernandoMiguel.net>
|
Signed-off-by: Fernando Miguel <github@FernandoMiguel.net>
I've added some code to handle 3 roles. |
Team, pls review. |
still have some pre-commit checks to fix but overall I think it looks good - @antonbabenko thoughts? |
@bryantbiggs |
Hello folks, |
@FernandoMiguel Thank you very much for this PR! |
### [5.5.2](v5.5.1...v5.5.2) (2022-10-13) ### Bug Fixes * Explicitly assume with condition matching role arn ([#283](#283)) ([470b6ff](470b6ff))
This PR is included in version 5.5.2 🎉 |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Signed-off-by: Fernando Miguel github@FernandoMiguel.net
Description
Fix the self assume role using a condition
Motivation and Context
The policy can not use the role arn in the principal field until the role already exists.
And since we can't create a role without a trust policy, we have chicken-egg problem.
Using a condition to match the role arn instead of using it in the principal, we are able to work around the problem.
Breaking Changes
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull requesttested this against one of our cluster, using my own fork branch
fixes: #282