@@ -117,6 +117,7 @@ func ResourceRecord() *schema.Resource {
117
117
ConflictsWith : []string {
118
118
"failover_routing_policy" ,
119
119
"geolocation_routing_policy" ,
120
+ "geoproximity_routing_policy" ,
120
121
"latency_routing_policy" ,
121
122
"multivalue_answer_routing_policy" ,
122
123
"weighted_routing_policy" ,
@@ -139,6 +140,7 @@ func ResourceRecord() *schema.Resource {
139
140
ConflictsWith : []string {
140
141
"cidr_routing_policy" ,
141
142
"geolocation_routing_policy" ,
143
+ "geoproximity_routing_policy" ,
142
144
"latency_routing_policy" ,
143
145
"multivalue_answer_routing_policy" ,
144
146
"weighted_routing_policy" ,
@@ -172,6 +174,54 @@ func ResourceRecord() *schema.Resource {
172
174
ConflictsWith : []string {
173
175
"cidr_routing_policy" ,
174
176
"failover_routing_policy" ,
177
+ "geoproximity_routing_policy" ,
178
+ "latency_routing_policy" ,
179
+ "multivalue_answer_routing_policy" ,
180
+ "weighted_routing_policy" ,
181
+ },
182
+ RequiredWith : []string {"set_identifier" },
183
+ },
184
+ "geoproximity_routing_policy" : {
185
+ Type : schema .TypeList ,
186
+ MaxItems : 1 ,
187
+ Optional : true ,
188
+ Elem : & schema.Resource {
189
+ Schema : map [string ]* schema.Schema {
190
+ "aws_region" : {
191
+ Type : schema .TypeString ,
192
+ Optional : true ,
193
+ },
194
+ "bias" : {
195
+ Type : schema .TypeInt ,
196
+ Optional : true ,
197
+ ValidateFunc : validation .IntBetween (- 99 , 99 ),
198
+ },
199
+ "coordinates" : {
200
+ Type : schema .TypeSet ,
201
+ Elem : & schema.Resource {
202
+ Schema : map [string ]* schema.Schema {
203
+ "latitude" : {
204
+ Type : schema .TypeString ,
205
+ Required : true ,
206
+ },
207
+ "longitude" : {
208
+ Type : schema .TypeString ,
209
+ Required : true ,
210
+ },
211
+ },
212
+ },
213
+ Optional : true ,
214
+ },
215
+ "local_zone_group" : {
216
+ Type : schema .TypeString ,
217
+ Optional : true ,
218
+ },
219
+ },
220
+ },
221
+ ConflictsWith : []string {
222
+ "cidr_routing_policy" ,
223
+ "failover_routing_policy" ,
224
+ "geolocation_routing_policy" ,
175
225
"latency_routing_policy" ,
176
226
"multivalue_answer_routing_policy" ,
177
227
"weighted_routing_policy" ,
@@ -198,6 +248,7 @@ func ResourceRecord() *schema.Resource {
198
248
"cidr_routing_policy" ,
199
249
"failover_routing_policy" ,
200
250
"geolocation_routing_policy" ,
251
+ "geoproximity_routing_policy" ,
201
252
"multivalue_answer_routing_policy" ,
202
253
"weighted_routing_policy" ,
203
254
},
@@ -210,6 +261,7 @@ func ResourceRecord() *schema.Resource {
210
261
"cidr_routing_policy" ,
211
262
"failover_routing_policy" ,
212
263
"geolocation_routing_policy" ,
264
+ "geoproximity_routing_policy" ,
213
265
"latency_routing_policy" ,
214
266
"weighted_routing_policy" ,
215
267
},
@@ -264,6 +316,7 @@ func ResourceRecord() *schema.Resource {
264
316
"cidr_routing_policy" ,
265
317
"failover_routing_policy" ,
266
318
"geolocation_routing_policy" ,
319
+ "geoproximity_routing_policy" ,
267
320
"latency_routing_policy" ,
268
321
"multivalue_answer_routing_policy" ,
269
322
},
@@ -411,6 +464,18 @@ func resourceRecordRead(ctx context.Context, d *schema.ResourceData, meta interf
411
464
}
412
465
}
413
466
467
+ if record .GeoProximityLocation != nil {
468
+ v := []map [string ]interface {}{{
469
+ "aws_region" : aws .StringValue (record .GeoProximityLocation .AWSRegion ),
470
+ "bias" : aws .Int64Value ((record .GeoProximityLocation .Bias )),
471
+ "coordinates" : flattenCoordinate (record .GeoProximityLocation .Coordinates ),
472
+ "local_zone_group" : aws .StringValue (record .GeoProximityLocation .LocalZoneGroup ),
473
+ }}
474
+ if err := d .Set ("geoproximity_routing_policy" , v ); err != nil {
475
+ return sdkdiag .AppendErrorf (diags , "setting geoproximity_routing_policy: %s" , err )
476
+ }
477
+ }
478
+
414
479
if record .Region != nil {
415
480
v := []map [string ]interface {}{{
416
481
"region" : aws .StringValue (record .Region ),
@@ -518,6 +583,21 @@ func resourceRecordUpdate(ctx context.Context, d *schema.ResourceData, meta inte
518
583
}
519
584
}
520
585
586
+ if v , _ := d .GetChange ("geoproximity_routing_policy" ); v != nil {
587
+ if o , ok := v .([]interface {}); ok {
588
+ if len (o ) == 1 {
589
+ if v , ok := o [0 ].(map [string ]interface {}); ok {
590
+ oldRec .GeoProximityLocation = & route53.GeoProximityLocation {
591
+ AWSRegion : nilString (v ["aws_region" ].(string )),
592
+ Bias : aws .Int64 (int64 (v ["bias" ].(int ))),
593
+ Coordinates : ExpandCoordinatesValue (v ["coordinates" ].(* schema.Set ).List ()),
594
+ LocalZoneGroup : nilString (v ["local_zone_group" ].(string )),
595
+ }
596
+ }
597
+ }
598
+ }
599
+ }
600
+
521
601
if v , _ := d .GetChange ("latency_routing_policy" ); v != nil {
522
602
if o , ok := v .([]interface {}); ok {
523
603
if len (o ) == 1 {
@@ -852,6 +932,18 @@ func expandResourceRecordSet(d *schema.ResourceData, zoneName string) *route53.R
852
932
}
853
933
}
854
934
935
+ if v , ok := d .GetOk ("geoproximity_routing_policy" ); ok {
936
+ geoproximityvalues := v .([]interface {})
937
+ geoproximity := geoproximityvalues [0 ].(map [string ]interface {})
938
+
939
+ rec .GeoProximityLocation = & route53.GeoProximityLocation {
940
+ AWSRegion : nilString (geoproximity ["aws_region" ].(string )),
941
+ Bias : aws .Int64 (int64 (geoproximity ["bias" ].(int ))),
942
+ Coordinates : ExpandCoordinatesValue (geoproximity ["coordinates" ].(* schema.Set ).List ()),
943
+ LocalZoneGroup : nilString (geoproximity ["local_zone_group" ].(string )),
944
+ }
945
+ }
946
+
855
947
if v , ok := d .GetOk ("health_check_id" ); ok {
856
948
rec .HealthCheckId = aws .String (v .(string ))
857
949
}
@@ -918,6 +1010,22 @@ func ExpandRecordName(name, zone string) string {
918
1010
return rn
919
1011
}
920
1012
1013
+ func ExpandCoordinatesValue (tfList []interface {}) * route53.Coordinates {
1014
+ if len (tfList ) == 0 {
1015
+ return nil
1016
+ }
1017
+ coordinatesvalue := & route53.Coordinates {}
1018
+ for _ , tfMapRaw := range tfList {
1019
+ tfMap , ok := tfMapRaw .(map [string ]interface {})
1020
+ if ! ok {
1021
+ continue
1022
+ }
1023
+ coordinatesvalue .Latitude = aws .String (tfMap ["latitude" ].(string ))
1024
+ coordinatesvalue .Longitude = aws .String (tfMap ["longitude" ].(string ))
1025
+ }
1026
+ return coordinatesvalue
1027
+ }
1028
+
921
1029
// nilString takes a string as an argument and returns a string
922
1030
// pointer. The returned pointer is nil if the string argument is
923
1031
// empty. Otherwise, it is a pointer to a copy of the string.
@@ -957,6 +1065,26 @@ func ParseRecordID(id string) [4]string {
957
1065
return [4 ]string {recZone , recName , recType , recSet }
958
1066
}
959
1067
1068
+ func flattenCoordinate (coordinates * route53.Coordinates ) []interface {} {
1069
+ if coordinates == nil {
1070
+ return nil
1071
+ }
1072
+ var tfList []interface {}
1073
+ tfMap := map [string ]interface {}{}
1074
+
1075
+ if v := coordinates .Latitude ; v != nil {
1076
+ tfMap ["latitude" ] = aws .StringValue (v )
1077
+ }
1078
+
1079
+ if v := coordinates .Longitude ; v != nil {
1080
+ tfMap ["longitude" ] = aws .StringValue (v )
1081
+ }
1082
+
1083
+ tfList = append (tfList , tfMap )
1084
+
1085
+ return tfList
1086
+ }
1087
+
960
1088
func validRecordType (s string ) bool {
961
1089
for _ , v := range route53 .RRType_Values () {
962
1090
if v == s {
0 commit comments