|
8 | 8 | using Amazon.Lambda.TestTool.Models; |
9 | 9 | using Amazon.Lambda.TestTool.Processes; |
10 | 10 | using Amazon.Lambda.TestTool.Processes.SQSEventSource; |
| 11 | +using Amazon.Lambda.TestTool.Processes.DynamoDBStreamsEventSource; |
11 | 12 | using Amazon.Lambda.TestTool.Services; |
12 | 13 | using Amazon.Lambda.TestTool.Services.IO; |
13 | 14 | using Spectre.Console.Cli; |
@@ -39,10 +40,10 @@ public override async Task<int> ExecuteAsync(CommandContext context, RunCommandS |
39 | 40 | { |
40 | 41 | EvaluateEnvironmentVariables(settings); |
41 | 42 |
|
42 | | - if (!settings.LambdaEmulatorPort.HasValue && !settings.ApiGatewayEmulatorPort.HasValue && !settings.ApiGatewayEmulatorHttpsPort.HasValue && string.IsNullOrEmpty(settings.SQSEventSourceConfig)) |
| 43 | + if (!settings.LambdaEmulatorPort.HasValue && !settings.ApiGatewayEmulatorPort.HasValue && !settings.ApiGatewayEmulatorHttpsPort.HasValue && string.IsNullOrEmpty(settings.SQSEventSourceConfig) && string.IsNullOrEmpty(settings.DynamoDBStreamsEventSourceConfig)) |
43 | 44 | { |
44 | 45 | throw new ArgumentException("At least one of the following parameters must be set: " + |
45 | | - "--lambda-emulator-port, --api-gateway-emulator-port, --api-gateway-emulator-https-port or --sqs-eventsource-config"); |
| 46 | + "--lambda-emulator-port, --api-gateway-emulator-port, --api-gateway-emulator-https-port, --sqs-eventsource-config or --dynamodbstreams-eventsource-config"); |
46 | 47 | } |
47 | 48 |
|
48 | 49 | var tasks = new List<Task>(); |
@@ -87,6 +88,12 @@ public override async Task<int> ExecuteAsync(CommandContext context, RunCommandS |
87 | 88 | { |
88 | 89 | var sqsEventSourceProcess = SQSEventSourceProcess.Startup(settings, cancellationTokenSource.Token); |
89 | 90 | tasks.Add(sqsEventSourceProcess.RunningTask); |
| 91 | + } |
| 92 | + |
| 93 | + if (!string.IsNullOrEmpty(settings.DynamoDBStreamsEventSourceConfig)) |
| 94 | + { |
| 95 | + var dynamoDBStreamsProcess = DynamoDBStreamsEventSourceProcess.Startup(settings, cancellationTokenSource.Token); |
| 96 | + tasks.Add(dynamoDBStreamsProcess.RunningTask); |
90 | 97 | } |
91 | 98 |
|
92 | 99 | await Task.Run(() => Task.WaitAny(tasks.ToArray(), cancellationTokenSource.Token)); |
@@ -184,6 +191,16 @@ private void EvaluateEnvironmentVariables(RunCommandSettings settings) |
184 | 191 | throw new InvalidOperationException($"Environment variable {envVariable} for the SQS event source config was empty"); |
185 | 192 | } |
186 | 193 | settings.SQSEventSourceConfig = environmentVariables[envVariable]?.ToString(); |
| 194 | + } |
| 195 | + |
| 196 | + if (settings.DynamoDBStreamsEventSourceConfig != null && settings.DynamoDBStreamsEventSourceConfig.StartsWith(Constants.ArgumentEnvironmentVariablePrefix, StringComparison.CurrentCultureIgnoreCase)) |
| 197 | + { |
| 198 | + var envVariable = settings.DynamoDBStreamsEventSourceConfig.Substring(Constants.ArgumentEnvironmentVariablePrefix.Length); |
| 199 | + if (!environmentVariables.Contains(envVariable)) |
| 200 | + { |
| 201 | + throw new InvalidOperationException($"Environment variable {envVariable} for the DynamoDB Streams event source config was empty"); |
| 202 | + } |
| 203 | + settings.DynamoDBStreamsEventSourceConfig = environmentVariables[envVariable]?.ToString(); |
187 | 204 | } |
188 | 205 | } |
189 | 206 | } |
0 commit comments