@@ -208,6 +208,14 @@ func resourceArmSpringCloudService() *schema.Resource {
208
208
},
209
209
},
210
210
211
+ "outbound_public_ip_addresses" : {
212
+ Type : schema .TypeList ,
213
+ Computed : true ,
214
+ Elem : & schema.Schema {
215
+ Type : schema .TypeString ,
216
+ },
217
+ },
218
+
211
219
"tags" : tags .Schema (),
212
220
},
213
221
}
@@ -372,19 +380,20 @@ func resourceArmSpringCloudServiceRead(d *schema.ResourceData, meta interface{})
372
380
if resp .Sku != nil {
373
381
d .Set ("sku_name" , resp .Sku .Name )
374
382
}
375
- if resp .Properties != nil {
376
- if err := d .Set ("trace" , flattenArmSpringCloudTrace (resp . Properties .Trace )); err != nil {
383
+ if props := resp .Properties ; props != nil {
384
+ if err := d .Set ("trace" , flattenArmSpringCloudTrace (props .Trace )); err != nil {
377
385
return fmt .Errorf ("failure setting `trace`: %+v" , err )
378
386
}
379
- if err := d .Set ("network" , flattenArmSpringCloudNetwork (resp . Properties .NetworkProfile )); err != nil {
387
+ if err := d .Set ("network" , flattenArmSpringCloudNetwork (props .NetworkProfile )); err != nil {
380
388
return fmt .Errorf ("setting `network`: %+v" , err )
381
389
}
382
- if resp .Properties .ConfigServerProperties != nil && resp .Properties .ConfigServerProperties .ConfigServer != nil {
383
- if props := resp .Properties .ConfigServerProperties .ConfigServer .GitProperty ; props != nil {
384
- if err := d .Set ("config_server_git_setting" , flattenArmSpringCloudConfigServerGitProperty (props , d )); err != nil {
385
- return fmt .Errorf ("failure setting AzureRM Spring Cloud Service error: %+v" , err )
386
- }
387
- }
390
+
391
+ outboundPublicIPAddresses := flattenOutboundPublicIPAddresses (props .NetworkProfile )
392
+ if err := d .Set ("outbound_public_ip_addresses" , outboundPublicIPAddresses ); err != nil {
393
+ return fmt .Errorf ("setting `outbound_public_ip_addresses`: %+v" , err )
394
+ }
395
+ if err := d .Set ("config_server_git_setting" , flattenArmSpringCloudConfigServerGitProperty (props .ConfigServerProperties , d )); err != nil {
396
+ return fmt .Errorf ("setting `config_server_git_setting`: %+v" , err )
388
397
}
389
398
}
390
399
@@ -551,31 +560,33 @@ func expandArmSpringCloudTrace(input []interface{}) *appplatform.TraceProperties
551
560
}
552
561
}
553
562
554
- func flattenArmSpringCloudConfigServerGitProperty (input * appplatform.ConfigServerGitProperty , d * schema.ResourceData ) []interface {} {
555
- if input == nil {
563
+ func flattenArmSpringCloudConfigServerGitProperty (input * appplatform.ConfigServerProperties , d * schema.ResourceData ) []interface {} {
564
+ if input == nil || input . ConfigServer == nil || input . ConfigServer . GitProperty == nil {
556
565
return []interface {}{}
557
566
}
558
567
568
+ gitProperty := input .ConfigServer .GitProperty
569
+
559
570
// prepare old state to find sensitive props not returned by API.
560
571
oldGitSetting := make (map [string ]interface {})
561
572
if oldGitSettings := d .Get ("config_server_git_setting" ).([]interface {}); len (oldGitSettings ) > 0 {
562
573
oldGitSetting = oldGitSettings [0 ].(map [string ]interface {})
563
574
}
564
575
565
576
uri := ""
566
- if input .URI != nil {
567
- uri = * input .URI
577
+ if gitProperty .URI != nil {
578
+ uri = * gitProperty .URI
568
579
}
569
580
570
581
label := ""
571
- if input .Label != nil {
572
- label = * input .Label
582
+ if gitProperty .Label != nil {
583
+ label = * gitProperty .Label
573
584
}
574
585
575
- searchPaths := utils .FlattenStringSlice (input .SearchPaths )
586
+ searchPaths := utils .FlattenStringSlice (gitProperty .SearchPaths )
576
587
577
- httpBasicAuth := []interface {}{}
578
- if input .Username != nil && input .Password != nil {
588
+ httpBasicAuth := make ( []interface {}, 0 )
589
+ if gitProperty .Username != nil && gitProperty .Password != nil {
579
590
// username and password returned by API are *
580
591
// to avoid state diff, we get the props from old state
581
592
username := ""
@@ -598,7 +609,7 @@ func flattenArmSpringCloudConfigServerGitProperty(input *appplatform.ConfigServe
598
609
}
599
610
600
611
sshAuth := []interface {}{}
601
- if input .PrivateKey != nil {
612
+ if gitProperty .PrivateKey != nil {
602
613
// private_key, host_key and host_key_algorithm returned by API are *
603
614
// to avoid state diff, we get the props from old state
604
615
privateKey := ""
@@ -615,8 +626,8 @@ func flattenArmSpringCloudConfigServerGitProperty(input *appplatform.ConfigServe
615
626
}
616
627
617
628
strictHostKeyChecking := false
618
- if input .StrictHostKeyChecking != nil {
619
- strictHostKeyChecking = * input .StrictHostKeyChecking
629
+ if gitProperty .StrictHostKeyChecking != nil {
630
+ strictHostKeyChecking = * gitProperty .StrictHostKeyChecking
620
631
}
621
632
622
633
sshAuth = []interface {}{
@@ -636,7 +647,7 @@ func flattenArmSpringCloudConfigServerGitProperty(input *appplatform.ConfigServe
636
647
"search_paths" : searchPaths ,
637
648
"http_basic_auth" : httpBasicAuth ,
638
649
"ssh_auth" : sshAuth ,
639
- "repository" : flattenArmSpringCloudGitPatternRepository (input .Repositories , d ),
650
+ "repository" : flattenArmSpringCloudGitPatternRepository (gitProperty .Repositories , d ),
640
651
},
641
652
}
642
653
}
@@ -797,6 +808,10 @@ func flattenArmSpringCloudNetwork(input *appplatform.NetworkProfile) []interface
797
808
appNetworkResourceGroup = * input .AppNetworkResourceGroup
798
809
}
799
810
811
+ if serviceRuntimeSubnetID == "" && appSubnetID == "" && serviceRuntimeNetworkResourceGroup == "" && appNetworkResourceGroup == "" && len (cidrRanges ) == 0 {
812
+ return []interface {}{}
813
+ }
814
+
800
815
return []interface {}{
801
816
map [string ]interface {}{
802
817
"app_subnet_id" : appSubnetID ,
@@ -807,3 +822,11 @@ func flattenArmSpringCloudNetwork(input *appplatform.NetworkProfile) []interface
807
822
},
808
823
}
809
824
}
825
+
826
+ func flattenOutboundPublicIPAddresses (input * appplatform.NetworkProfile ) []interface {} {
827
+ if input == nil || input .OutboundIPs == nil {
828
+ return []interface {}{}
829
+ }
830
+
831
+ return utils .FlattenStringSlice (input .OutboundIPs .PublicIPs )
832
+ }
0 commit comments