Skip to content

Improve identity related variables and output.#197

Merged
lonegunmanb merged 2 commits intoAzure:masterfrom
lonegunmanb:identity
Jul 13, 2022
Merged

Improve identity related variables and output.#197
lonegunmanb merged 2 commits intoAzure:masterfrom
lonegunmanb:identity

Conversation

@lonegunmanb
Copy link
Copy Markdown
Member

Rename var.system_assigned_identity to cluster_identity, add validation and precondition for identity-related variables. Bump Terraform required version to 1.2.0 since we've used precondition. #196 related.

lonegunmanb and others added 2 commits July 8, 2022 10:09
…dation and precondition for identity-related variables. Bump Terraform required version to 1.2.0 since we've used precondition.
change `cluster_identity` type from list to object so the user won't need use index anymore.
Comment thread outputs.tf
output "system_assigned_identity" {
value = azurerm_kubernetes_cluster.main.identity
output "cluster_identity" {
value = try(azurerm_kubernetes_cluster.main.identity[0], null)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the try block ? Is there a condition when the cluster has null identity ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we output in the value only the first element, rather than making available the all list ?

If we export the all list the user of the module can use the output with a index and consume all the identities of the cluster in other resources.

This would be also consistent with how we export the kubelet identity, example:
https://github.com/zioproto/istio-aks-example/blob/main/registry.tf#L10

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, according to the resource schema and identity schema it referenced, the identity in aks resource is a list with maximum length 1. So in this case the identity list has three cases: null, an empty list and a list with exactly one item.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when you use SystemAssigned, UserAssigned ? Dont you have 2 cluster identities ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also patch the CHANGLOG.md to indicate that the output name changed, so folks using the module must update their code ?

Comment thread main.tf

lifecycle {
precondition {
condition = (var.client_id != "" && var.client_secret != "") || (var.identity_type != "")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identity_type should have nullable = false in the variable definition ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identity_type has a validation block, null won't pass the validation so I think it's ok for this case.

Comment thread variables.tf
@@ -328,9 +330,14 @@ variable "ingress_application_gateway_subnet_id" {
}

variable "identity_type" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also identity_type should be nullable = false to make sure the condition in main.tf L158 works all the times.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identity_type has a validation block, null won't pass the validation so I think it's ok for this case.

@lonegunmanb lonegunmanb requested a review from zioproto July 13, 2022 00:40
@lonegunmanb lonegunmanb merged commit cd80be0 into Azure:master Jul 13, 2022
@lonegunmanb lonegunmanb deleted the identity branch November 21, 2023 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants