-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add the OIDC provider ARN to outputs #653
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
Add the OIDC provider ARN to outputs #653
Conversation
5f592ec to
864ceec
Compare
|
hi. did you see this ? #651 I personally like your usage of what do you think about naming the output |
outputs.tf
Outdated
|
|
||
| output "oidc_provider_arn" { | ||
| description = "The ARN of the OIDC Provider if `enable_irsa = true`." | ||
| value = var.enable_irsa ? aws_iam_openid_connect_provider.oidc_provider : null |
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.
This isn't returning just the ARN. It's returning a list of aws_iam_openid_connect_provider outputs.
For example:
oidc = [
{
"arn" = "arn:aws:iam::111111111111:oidc-provider/oidc.eks.us-west-2.amazonaws.com/id/518F3C3FCEEB9B22064F6EE41A9BDC39"
"client_id_list" = [
"sts.amazonaws.com",
]
"id" = "arn:aws:iam::111111111111:oidc-provider/oidc.eks.us-west-2.amazonaws.com/id/518F3C3FCEEB9B22064F6EE41A9BDC39"
"thumbprint_list" = [
"9e99a48a9960b14926bb7f3b02e22da2b0ab7280",
]
"url" = "oidc.eks.us-west-2.amazonaws.com/id/518F3C3FCEEB9B22064F6EE41A9BDC39"
},
]
| value = var.enable_irsa ? aws_iam_openid_connect_provider.oidc_provider : null | |
| value = var.enable_irsa ? aws_iam_openid_connect_provider.oidc_provider[0].arn : null |
Tried with 0.12.9 and 0.12.18. Appears to work correctly. Having indexes in outputs scare me a little due to historical issues but it seems the lazy evaluation of the ternary operator is working now. Also tried manually deleting the resource, and running destroy on an empty state with enable_irsa = true.
Setting an output to null causes it to not be listed in the state's output. This may cause issues for people using the terraform_remote_state data source to chain configs together.
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.
Good catch and suggested change, I'll push an update. I'm also not a fan of how using the ternary operator plus count forces you to refer to an index and have been pondering whether switching to a for_each makes more sense, however the place to make that switch is where the resource is being created. Do you think that is the smarter way to do it?
Setting up terraform_remote_state will work regardless of whether enable_irsa is true or false, however anything referencing this output will fail when it is set to false. I believe that this is desirable behavior since an early Terraform error message is preferable to a resource being created with bad data downstream. Say for example that we use the empty string when enable_irsa = false and the user attempts to deploy a Kubernetes manifest with this value. The user would likely see no errors in Terraform and end up wasting a bunch of time trying to debug it as a Kubernetes problem.
@ jonathancolby-olx Apparently I missed it. I'm OK closing my PR as well. Let me know which you'd prefer.
I've been pondering the same thing. The issue is that nearly every output starting with
|
@eytanhanig - Let's go with yours. Your case for using conditional with
@eytanhanig - after thinking about this, I also tend to agree that the |
a2a1c6d to
a762bf6
Compare
max-rocket-internet
left a comment
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.
NICE. Thanks @eytanhanig
|
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. |
PR o'clock
Description
Please explain the changes you made here and link to any relevant issues.
This PR adds the OICD Provider ARN to outputs when
enable_irsa = true. This needed when creating IAM policy documents/roles for Service Accounts, an example of which can be seen here.Note: The output is conditionally generated only when
enable_irsa = true. Whenenable_irsa = falseno output will be given, which is preferable to it returning a bad value, such as the empty string, which could then lead to misconfigured downstream resources.Checklist