@@ -251,6 +251,27 @@ func dataSourceArmKubernetesCluster() *schema.Resource {
251
251
Computed : true ,
252
252
},
253
253
254
+ "identity" : {
255
+ Type : schema .TypeList ,
256
+ Computed : true ,
257
+ Elem : & schema.Resource {
258
+ Schema : map [string ]* schema.Schema {
259
+ "type" : {
260
+ Type : schema .TypeString ,
261
+ Computed : true ,
262
+ },
263
+ "principal_id" : {
264
+ Type : schema .TypeString ,
265
+ Computed : true ,
266
+ },
267
+ "tenant_id" : {
268
+ Type : schema .TypeString ,
269
+ Computed : true ,
270
+ },
271
+ },
272
+ },
273
+ },
274
+
254
275
"kubernetes_version" : {
255
276
Type : schema .TypeString ,
256
277
Computed : true ,
@@ -338,6 +359,27 @@ func dataSourceArmKubernetesCluster() *schema.Resource {
338
359
Sensitive : true ,
339
360
},
340
361
362
+ "kubelet_identity" : {
363
+ Type : schema .TypeList ,
364
+ Computed : true ,
365
+ Elem : & schema.Resource {
366
+ Schema : map [string ]* schema.Schema {
367
+ "client_id" : {
368
+ Type : schema .TypeString ,
369
+ Computed : true ,
370
+ },
371
+ "object_id" : {
372
+ Type : schema .TypeString ,
373
+ Computed : true ,
374
+ },
375
+ "user_assigned_identity_id" : {
376
+ Type : schema .TypeString ,
377
+ Computed : true ,
378
+ },
379
+ },
380
+ },
381
+ },
382
+
341
383
"linux_profile" : {
342
384
Type : schema .TypeList ,
343
385
Computed : true ,
@@ -536,6 +578,11 @@ func dataSourceArmKubernetesClusterRead(d *schema.ResourceData, meta interface{}
536
578
return fmt .Errorf ("Error setting `agent_pool_profile`: %+v" , err )
537
579
}
538
580
581
+ kubeletIdentity := flattenKubernetesClusterDataSourceIdentityProfile (props .IdentityProfile )
582
+ if err := d .Set ("kubelet_identity" , kubeletIdentity ); err != nil {
583
+ return fmt .Errorf ("setting `kubelet_identity`: %+v" , err )
584
+ }
585
+
539
586
linuxProfile := flattenKubernetesClusterDataSourceLinuxProfile (props .LinuxProfile )
540
587
if err := d .Set ("linux_profile" , linuxProfile ); err != nil {
541
588
return fmt .Errorf ("Error setting `linux_profile`: %+v" , err )
@@ -579,6 +626,10 @@ func dataSourceArmKubernetesClusterRead(d *schema.ResourceData, meta interface{}
579
626
}
580
627
}
581
628
629
+ if err := d .Set ("identity" , flattenKubernetesClusterDataSourceManagedClusterIdentity (resp .Identity )); err != nil {
630
+ return fmt .Errorf ("setting `identity`: %+v" , err )
631
+ }
632
+
582
633
kubeConfigRaw , kubeConfig := flattenKubernetesClusterDataSourceAccessProfile (profile )
583
634
d .Set ("kube_config_raw" , kubeConfigRaw )
584
635
if err := d .Set ("kube_config" , kubeConfig ); err != nil {
@@ -839,6 +890,38 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi
839
890
return agentPoolProfiles
840
891
}
841
892
893
+ func flattenKubernetesClusterDataSourceIdentityProfile (profile map [string ]* containerservice.ManagedClusterPropertiesIdentityProfileValue ) []interface {} {
894
+ if profile == nil {
895
+ return []interface {}{}
896
+ }
897
+
898
+ kubeletIdentity := make ([]interface {}, 0 )
899
+ if kubeletidentity := profile ["kubeletidentity" ]; kubeletidentity != nil {
900
+ clientId := ""
901
+ if clientid := kubeletidentity .ClientID ; clientid != nil {
902
+ clientId = * clientid
903
+ }
904
+
905
+ objectId := ""
906
+ if objectid := kubeletidentity .ObjectID ; objectid != nil {
907
+ objectId = * objectid
908
+ }
909
+
910
+ userAssignedIdentityId := ""
911
+ if resourceid := kubeletidentity .ResourceID ; resourceid != nil {
912
+ userAssignedIdentityId = * resourceid
913
+ }
914
+
915
+ kubeletIdentity = append (kubeletIdentity , map [string ]interface {}{
916
+ "client_id" : clientId ,
917
+ "object_id" : objectId ,
918
+ "user_assigned_identity_id" : userAssignedIdentityId ,
919
+ })
920
+ }
921
+
922
+ return kubeletIdentity
923
+ }
924
+
842
925
func flattenKubernetesClusterDataSourceLinuxProfile (input * containerservice.LinuxProfile ) []interface {} {
843
926
values := make (map [string ]interface {})
844
927
sshKeys := make ([]interface {}, 0 )
@@ -959,3 +1042,26 @@ func flattenKubernetesClusterDataSourceKubeConfigAAD(config kubernetes.KubeConfi
959
1042
960
1043
return []interface {}{values }
961
1044
}
1045
+
1046
+ func flattenKubernetesClusterDataSourceManagedClusterIdentity (input * containerservice.ManagedClusterIdentity ) []interface {} {
1047
+ // if it's none, omit the block
1048
+ if input == nil || input .Type == containerservice .None {
1049
+ return []interface {}{}
1050
+ }
1051
+
1052
+ identity := make (map [string ]interface {})
1053
+
1054
+ identity ["principal_id" ] = ""
1055
+ if input .PrincipalID != nil {
1056
+ identity ["principal_id" ] = * input .PrincipalID
1057
+ }
1058
+
1059
+ identity ["tenant_id" ] = ""
1060
+ if input .TenantID != nil {
1061
+ identity ["tenant_id" ] = * input .TenantID
1062
+ }
1063
+
1064
+ identity ["type" ] = string (input .Type )
1065
+
1066
+ return []interface {}{identity }
1067
+ }
0 commit comments