Skip to content
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

d/azurerm_kubernetes_cluster extended with kubelet_identity and identity #6527

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -231,6 +231,29 @@ func dataSourceArmKubernetesCluster() *schema.Resource {
Computed: true,
},

"identity": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
aristosvo marked this conversation as resolved.
Show resolved Hide resolved
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Computed: true,
},
"principal_id": {
Type: schema.TypeString,
Computed: true,
},
"tenant_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
},

"kubernetes_version": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -318,6 +341,27 @@ func dataSourceArmKubernetesCluster() *schema.Resource {
Sensitive: true,
},

"kubelet_identity": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"client_id": {
Type: schema.TypeString,
Computed: true,
},
"object_id": {
Type: schema.TypeString,
Computed: true,
},
"user_assigned_identity_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
},

"linux_profile": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -516,6 +560,11 @@ func dataSourceArmKubernetesClusterRead(d *schema.ResourceData, meta interface{}
return fmt.Errorf("Error setting `agent_pool_profile`: %+v", err)
}

kubeletIdentity := flattenKubernetesClusterIdentityProfile(props.IdentityProfile)
aristosvo marked this conversation as resolved.
Show resolved Hide resolved
if err := d.Set("kubelet_identity", kubeletIdentity); err != nil {
return fmt.Errorf("setting `kubelet_identity`: %+v", err)
}

linuxProfile := flattenKubernetesClusterDataSourceLinuxProfile(props.LinuxProfile)
if err := d.Set("linux_profile", linuxProfile); err != nil {
return fmt.Errorf("Error setting `linux_profile`: %+v", err)
Expand Down Expand Up @@ -559,6 +608,10 @@ func dataSourceArmKubernetesClusterRead(d *schema.ResourceData, meta interface{}
}
}

if err := d.Set("identity", flattenKubernetesClusterManagedClusterIdentity(resp.Identity)); err != nil {
aristosvo marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("setting `identity`: %+v", err)
}

kubeConfigRaw, kubeConfig := flattenKubernetesClusterDataSourceAccessProfile(profile)
d.Set("kube_config_raw", kubeConfigRaw)
if err := d.Set("kube_config", kubeConfig); err != nil {
Expand Down
Expand Up @@ -36,6 +36,12 @@ func testAccDataSourceAzureRMKubernetesCluster_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(data.ResourceName, "kube_config.0.password"),
resource.TestCheckResourceAttr(data.ResourceName, "kube_admin_config.#", "0"),
resource.TestCheckResourceAttr(data.ResourceName, "kube_admin_config_raw", ""),
resource.TestCheckResourceAttrSet(data.ResourceName, "kubelet_identity.0.object_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "kubelet_identity.0.client_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "kubelet_identity.0.user_assigned_identity_id"),
resource.TestCheckResourceAttr(data.ResourceName, "identity.0.type", "SystemAssigned"),
resource.TestCheckResourceAttrSet(data.ResourceName, "identity.0.principal_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "identity.0.tenant_id"),
),
},
},
Expand Down
24 changes: 24 additions & 0 deletions website/docs/d/kubernetes_cluster.html.markdown
Expand Up @@ -78,6 +78,10 @@ The following attributes are exported:

* `service_principal` - A `service_principal` block as documented below.

* `identity` - A `identity` block as documented below.

* `kubelet_identity` - A `kubelet_identity` block as documented below.

* `tags` - A mapping of tags assigned to this resource.

---
Expand Down Expand Up @@ -239,6 +243,26 @@ A `service_principal` block supports the following:

---

The `identity` block exports the following:

* `type` - The type of identity used for the managed cluster.

* `principal_id` - The principal id of the system assigned identity which is used by master components.

* `tenant_id` - The tenant id of the system assigned identity which is used by master components.

---

The `kubelet_identity` block exports the following:

* `client_id` - The Client ID of the user-defined Managed Identity assigned to the Kubelets.

* `object_id` - The Object ID of the user-defined Managed Identity assigned to the Kubelets.

* `user_assigned_identity_id` - The ID of the User Assigned Identity assigned to the Kubelets.

---

A `ssh_key` block exports the following:

* `key_data` - The Public SSH Key used to access the cluster.
Expand Down