@@ -33,6 +33,25 @@ func ResourceEventSourceMapping() *schema.Resource {
33
33
},
34
34
35
35
Schema : map [string ]* schema.Schema {
36
+ "amazon_managed_kafka_event_source_config" : {
37
+ Type : schema .TypeList ,
38
+ Optional : true ,
39
+ Computed : true ,
40
+ ForceNew : true ,
41
+ MaxItems : 1 ,
42
+ ConflictsWith : []string {"self_managed_event_source" , "self_managed_kafka_event_source_config" },
43
+ Elem : & schema.Resource {
44
+ Schema : map [string ]* schema.Schema {
45
+ "consumer_group_id" : {
46
+ Type : schema .TypeString ,
47
+ Optional : true ,
48
+ Computed : true ,
49
+ ForceNew : true ,
50
+ ValidateFunc : validation .StringLenBetween (1 , 200 ),
51
+ },
52
+ },
53
+ },
54
+ },
36
55
"batch_size" : {
37
56
Type : schema .TypeInt ,
38
57
Optional : true ,
@@ -68,12 +87,10 @@ func ResourceEventSourceMapping() *schema.Resource {
68
87
return old == new
69
88
},
70
89
},
71
-
72
90
"bisect_batch_on_function_error" : {
73
91
Type : schema .TypeBool ,
74
92
Optional : true ,
75
93
},
76
-
77
94
"destination_config" : {
78
95
Type : schema .TypeList ,
79
96
Optional : true ,
@@ -98,20 +115,17 @@ func ResourceEventSourceMapping() *schema.Resource {
98
115
},
99
116
DiffSuppressFunc : verify .SuppressMissingOptionalConfigurationBlock ,
100
117
},
101
-
102
118
"enabled" : {
103
119
Type : schema .TypeBool ,
104
120
Optional : true ,
105
121
Default : true ,
106
122
},
107
-
108
123
"event_source_arn" : {
109
124
Type : schema .TypeString ,
110
125
Optional : true ,
111
126
ForceNew : true ,
112
127
ExactlyOneOf : []string {"event_source_arn" , "self_managed_event_source" },
113
128
},
114
-
115
129
"filter_criteria" : {
116
130
Type : schema .TypeList ,
117
131
Optional : true ,
@@ -135,12 +149,10 @@ func ResourceEventSourceMapping() *schema.Resource {
135
149
},
136
150
},
137
151
},
138
-
139
152
"function_arn" : {
140
153
Type : schema .TypeString ,
141
154
Computed : true ,
142
155
},
143
-
144
156
"function_name" : {
145
157
Type : schema .TypeString ,
146
158
Required : true ,
@@ -152,7 +164,6 @@ func ResourceEventSourceMapping() *schema.Resource {
152
164
return (oldFunctionName == new && oldFunctionNameErr == nil ) || (newFunctionName == old && newFunctionNameErr == nil )
153
165
},
154
166
},
155
-
156
167
"function_response_types" : {
157
168
Type : schema .TypeSet ,
158
169
Optional : true ,
@@ -161,22 +172,18 @@ func ResourceEventSourceMapping() *schema.Resource {
161
172
ValidateFunc : validation .StringInSlice (lambda .FunctionResponseType_Values (), false ),
162
173
},
163
174
},
164
-
165
175
"last_modified" : {
166
176
Type : schema .TypeString ,
167
177
Computed : true ,
168
178
},
169
-
170
179
"last_processing_result" : {
171
180
Type : schema .TypeString ,
172
181
Computed : true ,
173
182
},
174
-
175
183
"maximum_batching_window_in_seconds" : {
176
184
Type : schema .TypeInt ,
177
185
Optional : true ,
178
186
},
179
-
180
187
"maximum_record_age_in_seconds" : {
181
188
Type : schema .TypeInt ,
182
189
Optional : true ,
@@ -186,21 +193,18 @@ func ResourceEventSourceMapping() *schema.Resource {
186
193
validation .IntBetween (60 , 604_800 ),
187
194
),
188
195
},
189
-
190
196
"maximum_retry_attempts" : {
191
197
Type : schema .TypeInt ,
192
198
Optional : true ,
193
199
Computed : true ,
194
200
ValidateFunc : validation .IntBetween (- 1 , 10_000 ),
195
201
},
196
-
197
202
"parallelization_factor" : {
198
203
Type : schema .TypeInt ,
199
204
Optional : true ,
200
205
ValidateFunc : validation .IntBetween (1 , 10 ),
201
206
Computed : true ,
202
207
},
203
-
204
208
"queues" : {
205
209
Type : schema .TypeSet ,
206
210
Optional : true ,
@@ -210,7 +214,6 @@ func ResourceEventSourceMapping() *schema.Resource {
210
214
ValidateFunc : validation .StringLenBetween (1 , 1000 ),
211
215
},
212
216
},
213
-
214
217
"self_managed_event_source" : {
215
218
Type : schema .TypeList ,
216
219
Optional : true ,
@@ -241,7 +244,25 @@ func ResourceEventSourceMapping() *schema.Resource {
241
244
},
242
245
ExactlyOneOf : []string {"event_source_arn" , "self_managed_event_source" },
243
246
},
244
-
247
+ "self_managed_kafka_event_source_config" : {
248
+ Type : schema .TypeList ,
249
+ Optional : true ,
250
+ Computed : true ,
251
+ ForceNew : true ,
252
+ MaxItems : 1 ,
253
+ ConflictsWith : []string {"event_source_arn" , "amazon_managed_kafka_event_source_config" },
254
+ Elem : & schema.Resource {
255
+ Schema : map [string ]* schema.Schema {
256
+ "consumer_group_id" : {
257
+ Type : schema .TypeString ,
258
+ Optional : true ,
259
+ Computed : true ,
260
+ ForceNew : true ,
261
+ ValidateFunc : validation .StringLenBetween (1 , 200 ),
262
+ },
263
+ },
264
+ },
265
+ },
245
266
"source_access_configuration" : {
246
267
Type : schema .TypeSet ,
247
268
Optional : true ,
@@ -260,31 +281,26 @@ func ResourceEventSourceMapping() *schema.Resource {
260
281
},
261
282
},
262
283
},
263
-
264
284
"starting_position" : {
265
285
Type : schema .TypeString ,
266
286
Optional : true ,
267
287
ForceNew : true ,
268
288
ValidateFunc : validation .StringInSlice (lambda .EventSourcePosition_Values (), false ),
269
289
},
270
-
271
290
"starting_position_timestamp" : {
272
291
Type : schema .TypeString ,
273
292
Optional : true ,
274
293
ForceNew : true ,
275
294
ValidateFunc : validation .IsRFC3339Time ,
276
295
},
277
-
278
296
"state" : {
279
297
Type : schema .TypeString ,
280
298
Computed : true ,
281
299
},
282
-
283
300
"state_transition_reason" : {
284
301
Type : schema .TypeString ,
285
302
Computed : true ,
286
303
},
287
-
288
304
"topics" : {
289
305
Type : schema .TypeSet ,
290
306
Optional : true ,
@@ -294,13 +310,11 @@ func ResourceEventSourceMapping() *schema.Resource {
294
310
ValidateFunc : validation .StringLenBetween (1 , 249 ),
295
311
},
296
312
},
297
-
298
313
"tumbling_window_in_seconds" : {
299
314
Type : schema .TypeInt ,
300
315
Optional : true ,
301
316
ValidateFunc : validation .IntBetween (0 , 900 ),
302
317
},
303
-
304
318
"uuid" : {
305
319
Type : schema .TypeString ,
306
320
Computed : true ,
@@ -320,6 +334,10 @@ func resourceEventSourceMappingCreate(d *schema.ResourceData, meta interface{})
320
334
321
335
var target string
322
336
337
+ if v , ok := d .GetOk ("amazon_managed_kafka_event_source_config" ); ok && len (v .([]interface {})) > 0 && v .([]interface {})[0 ] != nil {
338
+ input .AmazonManagedKafkaEventSourceConfig = expandAmazonManagedKafkaEventSourceConfig (v .([]interface {})[0 ].(map [string ]interface {}))
339
+ }
340
+
323
341
if v , ok := d .GetOk ("batch_size" ); ok {
324
342
input .BatchSize = aws .Int64 (int64 (v .(int )))
325
343
}
@@ -373,6 +391,10 @@ func resourceEventSourceMappingCreate(d *schema.ResourceData, meta interface{})
373
391
target = "Self-Managed Apache Kafka"
374
392
}
375
393
394
+ if v , ok := d .GetOk ("self_managed_kafka_event_source_config" ); ok && len (v .([]interface {})) > 0 && v .([]interface {})[0 ] != nil {
395
+ input .SelfManagedKafkaEventSourceConfig = expandSelfManagedKafkaEventSourceConfig (v .([]interface {})[0 ].(map [string ]interface {}))
396
+ }
397
+
376
398
if v , ok := d .GetOk ("source_access_configuration" ); ok && v .(* schema.Set ).Len () > 0 {
377
399
input .SourceAccessConfigurations = expandSourceAccessConfigurations (v .(* schema.Set ).List ())
378
400
}
@@ -460,6 +482,13 @@ func resourceEventSourceMappingRead(d *schema.ResourceData, meta interface{}) er
460
482
return fmt .Errorf ("error reading Lambda Event Source Mapping (%s): %w" , d .Id (), err )
461
483
}
462
484
485
+ if eventSourceMappingConfiguration .AmazonManagedKafkaEventSourceConfig != nil {
486
+ if err := d .Set ("amazon_managed_kafka_event_source_config" , []interface {}{flattenAmazonManagedKafkaEventSourceConfig (eventSourceMappingConfiguration .AmazonManagedKafkaEventSourceConfig )}); err != nil {
487
+ return fmt .Errorf ("error setting amazon_managed_kafka_event_source_config: %w" , err )
488
+ }
489
+ } else {
490
+ d .Set ("amazon_managed_kafka_event_source_config" , nil )
491
+ }
463
492
d .Set ("batch_size" , eventSourceMappingConfiguration .BatchSize )
464
493
d .Set ("bisect_batch_on_function_error" , eventSourceMappingConfiguration .BisectBatchOnFunctionError )
465
494
if eventSourceMappingConfiguration .DestinationConfig != nil {
@@ -498,6 +527,13 @@ func resourceEventSourceMappingRead(d *schema.ResourceData, meta interface{}) er
498
527
} else {
499
528
d .Set ("self_managed_event_source" , nil )
500
529
}
530
+ if eventSourceMappingConfiguration .SelfManagedKafkaEventSourceConfig != nil {
531
+ if err := d .Set ("self_managed_kafka_event_source_config" , []interface {}{flattenSelfManagedKafkaEventSourceConfig (eventSourceMappingConfiguration .SelfManagedKafkaEventSourceConfig )}); err != nil {
532
+ return fmt .Errorf ("error setting self_managed_kafka_event_source_config: %w" , err )
533
+ }
534
+ } else {
535
+ d .Set ("self_managed_kafka_event_source_config" , nil )
536
+ }
501
537
if err := d .Set ("source_access_configuration" , flattenSourceAccessConfigurations (eventSourceMappingConfiguration .SourceAccessConfigurations )); err != nil {
502
538
return fmt .Errorf ("error setting source_access_configuration: %w" , err )
503
539
}
@@ -763,6 +799,62 @@ func flattenSelfManagedEventSource(apiObject *lambda.SelfManagedEventSource) map
763
799
return tfMap
764
800
}
765
801
802
+ func expandAmazonManagedKafkaEventSourceConfig (tfMap map [string ]interface {}) * lambda.AmazonManagedKafkaEventSourceConfig {
803
+ if tfMap == nil {
804
+ return nil
805
+ }
806
+
807
+ apiObject := & lambda.AmazonManagedKafkaEventSourceConfig {}
808
+
809
+ if v , ok := tfMap ["consumer_group_id" ].(string ); ok && v != "" {
810
+ apiObject .ConsumerGroupId = aws .String (v )
811
+ }
812
+
813
+ return apiObject
814
+ }
815
+
816
+ func flattenAmazonManagedKafkaEventSourceConfig (apiObject * lambda.AmazonManagedKafkaEventSourceConfig ) map [string ]interface {} {
817
+ if apiObject == nil {
818
+ return nil
819
+ }
820
+
821
+ tfMap := map [string ]interface {}{}
822
+
823
+ if v := apiObject .ConsumerGroupId ; v != nil {
824
+ tfMap ["consumer_group_id" ] = aws .StringValue (v )
825
+ }
826
+
827
+ return tfMap
828
+ }
829
+
830
+ func expandSelfManagedKafkaEventSourceConfig (tfMap map [string ]interface {}) * lambda.SelfManagedKafkaEventSourceConfig {
831
+ if tfMap == nil {
832
+ return nil
833
+ }
834
+
835
+ apiObject := & lambda.SelfManagedKafkaEventSourceConfig {}
836
+
837
+ if v , ok := tfMap ["consumer_group_id" ].(string ); ok && v != "" {
838
+ apiObject .ConsumerGroupId = aws .String (v )
839
+ }
840
+
841
+ return apiObject
842
+ }
843
+
844
+ func flattenSelfManagedKafkaEventSourceConfig (apiObject * lambda.SelfManagedKafkaEventSourceConfig ) map [string ]interface {} {
845
+ if apiObject == nil {
846
+ return nil
847
+ }
848
+
849
+ tfMap := map [string ]interface {}{}
850
+
851
+ if v := apiObject .ConsumerGroupId ; v != nil {
852
+ tfMap ["consumer_group_id" ] = aws .StringValue (v )
853
+ }
854
+
855
+ return tfMap
856
+ }
857
+
766
858
func expandSourceAccessConfiguration (tfMap map [string ]interface {}) * lambda.SourceAccessConfiguration {
767
859
if tfMap == nil {
768
860
return nil
0 commit comments