1010)
1111from .types import (
1212 ConnectionModel ,
13+ DynamoDBConnectionModel ,
1314 GCSConnectionModel ,
1415 KafkaConnectionModel ,
1516 ResourceFile ,
3031 "S3_ACCESS_KEY" ,
3132 "S3_SECRET" ,
3233 "GCS_SERVICE_ACCOUNT_CREDENTIALS_JSON" ,
34+ "DYNAMODB_ARN" ,
35+ "DYNAMODB_REGION" ,
3336}
3437
3538
@@ -58,6 +61,9 @@ def parse_connection_file(resource: ResourceFile) -> ConnectionModel:
5861 access_secret : str | None = None
5962 service_account_credentials_json : str | None = None
6063
64+ dynamodb_arn : str | None = None
65+ dynamodb_region : str | None = None
66+
6167 i = 0
6268 while i < len (lines ):
6369 raw_line = lines [i ]
@@ -119,6 +125,10 @@ def parse_connection_file(resource: ResourceFile) -> ConnectionModel:
119125 access_secret = parse_quoted_value (value )
120126 elif name == "GCS_SERVICE_ACCOUNT_CREDENTIALS_JSON" :
121127 service_account_credentials_json = parse_quoted_value (value )
128+ elif name == "DYNAMODB_ARN" :
129+ dynamodb_arn = parse_quoted_value (value )
130+ elif name == "DYNAMODB_REGION" :
131+ dynamodb_region = parse_quoted_value (value )
122132 else :
123133 raise MigrationParseError (
124134 resource .file_path ,
@@ -135,12 +145,20 @@ def parse_connection_file(resource: ResourceFile) -> ConnectionModel:
135145 )
136146
137147 if connection_type == "kafka" :
138- if region or arn or access_key or access_secret or service_account_credentials_json :
148+ if (
149+ region
150+ or arn
151+ or access_key
152+ or access_secret
153+ or service_account_credentials_json
154+ or dynamodb_arn
155+ or dynamodb_region
156+ ):
139157 raise MigrationParseError (
140158 resource .file_path ,
141159 "connection" ,
142160 resource .name ,
143- "S3/GCS directives are not valid for kafka connections." ,
161+ "S3/GCS/DynamoDB directives are not valid for kafka connections." ,
144162 )
145163
146164 if not bootstrap_servers :
@@ -175,12 +193,14 @@ def parse_connection_file(resource: ResourceFile) -> ConnectionModel:
175193 or schema_registry_url
176194 or ssl_ca_pem
177195 or service_account_credentials_json
196+ or dynamodb_arn
197+ or dynamodb_region
178198 ):
179199 raise MigrationParseError (
180200 resource .file_path ,
181201 "connection" ,
182202 resource .name ,
183- "Kafka/GCS directives are not valid for s3 connections." ,
203+ "Kafka/GCS/DynamoDB directives are not valid for s3 connections." ,
184204 )
185205
186206 if not region :
@@ -231,12 +251,14 @@ def parse_connection_file(resource: ResourceFile) -> ConnectionModel:
231251 or arn
232252 or access_key
233253 or access_secret
254+ or dynamodb_arn
255+ or dynamodb_region
234256 ):
235257 raise MigrationParseError (
236258 resource .file_path ,
237259 "connection" ,
238260 resource .name ,
239- "Kafka/S3 directives are not valid for gcs connections." ,
261+ "Kafka/S3/DynamoDB directives are not valid for gcs connections." ,
240262 )
241263
242264 if not service_account_credentials_json :
@@ -255,6 +277,53 @@ def parse_connection_file(resource: ResourceFile) -> ConnectionModel:
255277 service_account_credentials_json = service_account_credentials_json ,
256278 )
257279
280+ if connection_type == "dynamodb" :
281+ if (
282+ bootstrap_servers
283+ or security_protocol
284+ or sasl_mechanism
285+ or key
286+ or secret
287+ or schema_registry_url
288+ or ssl_ca_pem
289+ or region
290+ or arn
291+ or access_key
292+ or access_secret
293+ or service_account_credentials_json
294+ ):
295+ raise MigrationParseError (
296+ resource .file_path ,
297+ "connection" ,
298+ resource .name ,
299+ "Kafka/S3/GCS directives are not valid for dynamodb connections." ,
300+ )
301+
302+ if not dynamodb_arn :
303+ raise MigrationParseError (
304+ resource .file_path ,
305+ "connection" ,
306+ resource .name ,
307+ "DYNAMODB_ARN is required for dynamodb connections." ,
308+ )
309+
310+ if not dynamodb_region :
311+ raise MigrationParseError (
312+ resource .file_path ,
313+ "connection" ,
314+ resource .name ,
315+ "DYNAMODB_REGION is required for dynamodb connections." ,
316+ )
317+
318+ return DynamoDBConnectionModel (
319+ kind = "connection" ,
320+ name = resource .name ,
321+ file_path = resource .file_path ,
322+ connection_type = "dynamodb" ,
323+ region = dynamodb_region ,
324+ arn = dynamodb_arn ,
325+ )
326+
258327 raise MigrationParseError (
259328 resource .file_path ,
260329 "connection" ,
0 commit comments