This repository was archived by the owner on Jan 22, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemplate.yaml
More file actions
797 lines (745 loc) · 24.5 KB
/
Copy pathtemplate.yaml
File metadata and controls
797 lines (745 loc) · 24.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
SftpServerS3Bucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
SftpAccessPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
ManagedPolicyName: SftpAccessPolicy
Description: Sftp access policy
PolicyDocument:
Version: '2012-10-17'
Statement:
-
Effect: Allow
Action:
- 's3:PutObject'
- 's3:GetObject'
- 's3:DeleteObject'
- 's3:GetObjectVersion'
- 's3:DeleteObjectVersion'
Resource: !Sub "${SftpServerS3Bucket.Arn}/test/*"
-
Effect: Allow
Action:
- 's3:ListBucket'
- 's3:GetBucketLocation'
Resource: !GetAtt SftpServerS3Bucket.Arn
Condition:
StringLike:
's3:prefix': 'test/*'
SftpAccessRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Principal:
Service:
- 'transfer.amazonaws.com'
Action:
- 'sts:AssumeRole'
ManagedPolicyArns:
- !Ref SftpAccessPolicy
SftpServer:
Type: AWS::Transfer::Server
Properties:
EndpointType: PUBLIC
SftpUser:
Type: AWS::Transfer::User
Properties:
UserName: testuser
HomeDirectory: !Sub "/${SftpServerS3Bucket}/test"
Role: !GetAtt SftpAccessRole.Arn
ServerId: !GetAtt SftpServer.ServerId
SshPublicKeys:
- Ref: SshPublicKeyParameter
CloudTrailS3Bucket:
DeletionPolicy: Retain
Type: AWS::S3::Bucket
Properties: {}
CloudTrailS3BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: CloudTrailS3Bucket
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Sid: "AWSCloudTrailAclCheck"
Effect: "Allow"
Principal:
Service: "cloudtrail.amazonaws.com"
Action: "s3:GetBucketAcl"
Resource:
!Sub |-
arn:aws:s3:::${CloudTrailS3Bucket}
-
Sid: "AWSCloudTrailWrite"
Effect: "Allow"
Principal:
Service: "cloudtrail.amazonaws.com"
Action: "s3:PutObject"
Resource:
!Sub |-
arn:aws:s3:::${CloudTrailS3Bucket}/AWSLogs/${AWS::AccountId}/*
Condition:
StringEquals:
s3:x-amz-acl: "bucket-owner-full-control"
CloudTrailDataEventsTrail:
DependsOn:
- CloudTrailS3BucketPolicy
- SftpServerS3Bucket
Type: AWS::CloudTrail::Trail
Properties:
S3BucketName:
Ref: CloudTrailS3Bucket
IsLogging: true
IsMultiRegionTrail: false
EventSelectors:
- DataResources:
- Type: AWS::S3::Object
Values:
- !Sub "${SftpServerS3Bucket.Arn}/"
IncludeManagementEvents: No
ReadWriteType: All
EventBridgeCustomEventBus:
Type: AWS::Events::EventBus
Properties:
Name: "EventBridgeCustomEventBus"
EventBridgeSftpS3BucketEventRule:
DependsOn:
- PopulateQueueLambdaFunction
Type: AWS::Events::Rule
Properties:
Description: "EventBridgeSftpS3BucketEventRule"
EventPattern:
source:
- "aws.s3"
detail-type:
- "AWS API Call via CloudTrail"
detail:
eventSource:
- "s3.amazonaws.com"
eventName:
- "PutObject"
requestParameters:
bucketName:
- !Sub "${SftpServerS3Bucket}"
State: "ENABLED"
Targets:
-
Arn:
Fn::GetAtt:
- "PopulateQueueLambdaFunction"
- "Arn"
Id: "TargetFunctionV1"
PermissionForEventsToInvokeLambda:
DependsOn:
- PopulateQueueLambdaFunction
- EventBridgeSftpS3BucketEventRule
Type: AWS::Lambda::Permission
Properties:
FunctionName:
Ref: "PopulateQueueLambdaFunction"
Action: "lambda:InvokeFunction"
Principal: "events.amazonaws.com"
SourceArn:
Fn::GetAtt:
- "EventBridgeSftpS3BucketEventRule"
- "Arn"
PopulateQueueLambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
Policies:
- PolicyName: root
PolicyDocument:
Version: '2012-10-17'
Statement:
-
Sid: "LambdaAccessToCreateCWLogGroup"
Effect: Allow
Action: "logs:CreateLogGroup"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:*"
-
Sid: "LambdaAccessToCreateCWLogEvents"
Effect: Allow
Action:
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/PopulateQueueLambdaFunction:*"
-
Sid: "LambdaAccessToSftpServerS3Bucket"
Effect: Allow
Action: "s3:GetObject"
Resource: !Sub "arn:aws:s3:::${SftpServerS3Bucket}/*"
-
Sid: "LambdaAccessToSqsQueue"
Effect: Allow
Action:
- "sqs:GetQueueUrl"
- "sqs:ChangeMessageVisibility"
- "sqs:ListDeadLetterSourceQueues"
- "sqs:SendMessageBatch"
- "sqs:PurgeQueue"
- "sqs:ReceiveMessage"
- "sqs:SendMessage"
- "sqs:GetQueueAttributes"
- "sqs:CreateQueue"
- "sqs:ListQueueTags"
- "sqs:ChangeMessageVisibilityBatch"
- "sqs:SetQueueAttributes"
Resource:
Fn::GetAtt:
- "SqsQueue"
- "Arn"
SqsQueue:
Type: AWS::SQS::Queue
SingleQueueLambdaApiGatewayRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- apigateway.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
Policies:
- PolicyName: root
PolicyDocument:
Version: '2012-10-17'
Statement:
-
Sid: "LambdaAccess"
Effect: Allow
Action: lambda:InvokeFunction
Resource: !GetAtt 'SingleQueueUploadLambda.Arn'
-
Sid: "ApiGatewayAccessToCreateCWLogGroupAndPutEvents"
Effect: Allow
Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:*"
ApiGatewayInvokeLambdaPermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName:
Ref: "SingleQueueUploadLambda"
Action: lambda:InvokeFunction
Principal: apigateway.amazonaws.com
SourceArn: !Sub "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${SingleTransactionApiGateway}/*/*/*"
SingleQueueUploadLambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
Policies:
- PolicyName: root
PolicyDocument:
Version: '2012-10-17'
Statement:
-
Sid: "LambdaAccessToSqsQueue"
Effect: Allow
Action: sqs:SendMessage
Resource: !GetAtt 'SqsQueue.Arn'
-
Sid: "LambdaAccessToCreateCWLogGroup"
Effect: Allow
Action: "logs:CreateLogGroup"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:*"
-
Sid: "LambdaAccessToCreateCWLogEvents"
Effect: Allow
Action:
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/SingleQueueUploadLambda:*"
SingleTransactionApiGateway:
Type: AWS::ApiGateway::RestApi
Properties:
EndpointConfiguration:
Types:
- REGIONAL
Name: SingleTransactionApiGateway
SingleTransactionApiGatewayMethod:
Type: 'AWS::ApiGateway::Method'
Properties:
RestApiId: !Ref SingleTransactionApiGateway
ResourceId: !GetAtt SingleTransactionApiGateway.RootResourceId
HttpMethod: POST
AuthorizationType: NONE
RequestParameters:
method.request.querystring.transactionId: true
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
Uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${SingleQueueUploadLambda.Arn}/invocations'
MethodResponses:
- ResponseModels:
application/json: "Empty"
StatusCode: 200
SingleTransactionApiGatewayDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn:
- SingleTransactionApiGatewayMethod
Properties:
RestApiId: !Ref SingleTransactionApiGateway
StageName: test
SingleQueueUploadLambda:
DependsOn:
- SqsQueue
Type: AWS::Lambda::Function
Properties:
FunctionName: SingleQueueUploadLambda
Role: !GetAtt SingleQueueUploadLambdaRole.Arn
Runtime: python3.8
Handler: index.lambda_handler
Code:
ZipFile: |
import json
import os
import boto3
sqs_client = boto3.client('sqs')
queue_url = os.environ['sqsqueueurl']
def lambda_handler(event, context):
transactionId = event['queryStringParameters']['transactionId']
print(transactionId)
transactionMessage = event['queryStringParameters']['transactionMessage']
print(transactionMessage)
sqs_handler(transactionId, transactionMessage)
return {
'statusCode': 200,
'body': json.dumps('Great job!')
}
def sqs_handler(transactionId, transactionMessage):
response = sqs_client.send_message(
QueueUrl=queue_url,
DelaySeconds=0,
MessageAttributes={
'TransactionID': {
'DataType': 'Number',
'StringValue': transactionId
}
},
MessageBody=(
transactionMessage
)
)
print(response)
Environment:
Variables:
sqsqueueurl: !Ref SqsQueue
PopulateQueueLambdaFunction:
DependsOn:
- SqsQueue
Type: AWS::Lambda::Function
Properties:
FunctionName: PopulateQueueLambdaFunction
Role: !GetAtt PopulateQueueLambdaRole.Arn
Runtime: python3.8
Handler: index.lambda_handler
Code:
ZipFile: |
import json
import os
import boto3
from xml.dom import minidom
import xml.etree.ElementTree as ET
import re
s3_client = boto3.client('s3')
sqs_client = boto3.client('sqs')
queue_url = os.environ['sqsqueueurl']
def lambda_handler(event, context):
# Get only necessary data from Event JSON
detail = event['detail'] # Event JSON payload format: detail -> requestParameters -> bucketName and key
request_parameters = detail['requestParameters']
bucket_name = request_parameters['bucketName']
object_key = request_parameters['key']
# get object rather than download file to save Lambda memory
try:
input_object = s3_client.get_object(Bucket=bucket_name, Key=object_key)
except:
print("File does not exist in S3.")
return("500")
input_data = input_object['Body'].read()
# file data will be a binary stream; have to decode it
contents = input_data.decode('utf-8')
# print(contents)
# establish tree and parse through lines and strip
root = ET.fromstring(contents)
# strip away the ID and content inside each transaction to be send to lambda funcitons to transform them into JSON
for child in root.iter():
if child.tag == 'Transaction':
id = child.attrib['TransactionID']
print(id)
for child2 in child.iter():
notes = getattr(child2.find('Notes'), 'text', None)
if notes != None:
sqs_handler(id,notes)
print(notes)
def sqs_handler(transaction_id, note):
note_str = note
print(note_str)
response = sqs_client.send_message(
QueueUrl=queue_url,
DelaySeconds=0,
MessageAttributes={
'TransactionID': {
'DataType': 'Number',
'StringValue': transaction_id
}
},
MessageBody=(
note_str
)
)
print(response)
Environment:
Variables:
sqsqueueurl: !Ref SqsQueue
TransactionsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: transactions
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
DataEnrichmentApiGatewayMethod:
Type: 'AWS::ApiGateway::Method'
Properties:
RestApiId: !Ref DataEnrichmentApiGateway
ResourceId: !GetAtt DataEnrichmentApiGateway.RootResourceId
HttpMethod: GET
AuthorizationType: NONE
Integration:
Type: HTTP
IntegrationHttpMethod: GET
PassthroughBehavior: WHEN_NO_MATCH
IntegrationResponses:
- StatusCode: 200
Uri: https://hub.dummyapis.com/employee?noofRecords=1
MethodResponses:
- ResponseModels:
application/json: "Empty"
StatusCode: 200
DataEnrichmentApiGateway:
Type: AWS::ApiGateway::RestApi
Properties:
EndpointConfiguration:
Types:
- REGIONAL
Name: DataEnrichmentApiGateway
DataEnrichmentApiGatewayDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn:
- DataEnrichmentApiGatewayMethod
Properties:
RestApiId: !Ref DataEnrichmentApiGateway
StageName: test
IntakeSingleTransactionLambdaFunctionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
Policies:
- PolicyName: root
PolicyDocument:
Version: '2012-10-17'
Statement:
-
Sid: "LambdaAccessToCreateCWLogGroup"
Effect: Allow
Action: "logs:CreateLogGroup"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:*"
-
Sid: "LambdaAccessToCreateCWLogEvents"
Effect: Allow
Action:
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/IntakeSingleTransactionLambdaFunction:*"
IntakeSingleTransactionLambdaFunction:
Type: AWS::Lambda::Function
Properties:
FunctionName: IntakeSingleTransactionLambdaFunction
Role: !GetAtt IntakeSingleTransactionLambdaFunctionRole.Arn
Runtime: python3.8
Handler: index.lambda_handler
Code:
ZipFile: |
def lambda_handler(event, context):
print("hi i'm here")
print(event)
message_id = event['id']
transaction_message = event['transaction_message']
return {
'messageId': event['id'],
'transactionMessage': event['transaction_message']
}
StatesExecutionRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- !Sub states.${AWS::Region}.amazonaws.com
Action: "sts:AssumeRole"
Path: "/"
Policies:
- PolicyName: StatesExecutionPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Sid: "LambdaAccess"
Effect: Allow
Action:
- "lambda:InvokeFunction"
Resource: "*"
-
Sid: "CWLogDelivery"
Effect: Allow
Action:
- "logs:CreateLogGroup"
- "logs:CreateLogDelivery"
- "logs:GetLogDelivery"
- "logs:UpdateLogDelivery"
- "logs:DeleteLogDelivery"
- "logs:ListLogDeliveries"
- "logs:PutResourcePolicy"
- "logs:DescribeResourcePolicies"
- "logs:DescribeLogGroups"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:*"
-
Sid: "DynamoDBAccess"
Effect: Allow
Action:
- "dynamodb:PutItem"
Resource: !GetAtt TransactionsTable.Arn
SQSTriggerLambda:
Type: AWS::Lambda::EventSourceMapping
Properties:
Enabled: true
EventSourceArn:
Fn::GetAtt:
- "SqsQueue"
- Arn
FunctionName:
Ref: TriggerStepFunctionsLambdaFunction
TriggerStepFunctionsLambdaFunctionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
Policies:
- PolicyName: root
PolicyDocument:
Version: '2012-10-17'
Statement:
-
Sid: "LambdaAccessToCreateCWLogGroup"
Effect: Allow
Action: "logs:CreateLogGroup"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:*"
-
Sid: "LambdaAccessToCreateCWLogEvents"
Effect: Allow
Action:
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/TriggerStepFunctionsLambdaFunction:*"
-
Sid: "LambdaSQSPermissions"
Effect: Allow
Action:
- "sqs:ReceiveMessage"
- "sqs:DeleteMessage"
- "sqs:GetQueueAttributes"
Resource:
Fn::GetAtt:
- "SqsQueue"
- "Arn"
-
Sid: "LambdaStateMachinePermissions"
Effect: Allow
Action:
- "states:StartExecution"
Resource: !GetAtt StepFunctionsStateMachine.Arn
TriggerStepFunctionsLambdaFunction:
Type: AWS::Lambda::Function
Properties:
FunctionName: TriggerStepFunctionsLambdaFunction
Role: !GetAtt TriggerStepFunctionsLambdaFunctionRole.Arn
Runtime: python3.8
Handler: index.lambda_handler
Code:
ZipFile: |
import boto3
import random
import os
def lambda_handler(event, context):
print(event['Records'][0])
message_body = event['Records'][0]['body']
message_id = event['Records'][0]["messageAttributes"]["TransactionID"]["stringValue"]
print(message_body)
input_json = "{\"id\" : \""+message_id+"\", \"transaction_message\" : \""+message_body+"\"}"
unique_execution_string = str(random.randint(1, 1000000))
print(input_json)
#"input": "{\"first_name\" : \"test\"}"
client = boto3.client('stepfunctions')
response = client.start_execution(
stateMachineArn= os.environ['statemachinearn'],
input=str(input_json),
name="transaction-id-"+message_id+"-unique-execution-string-"+unique_execution_string
)
Environment:
Variables:
statemachinearn: !GetAtt StepFunctionsStateMachine.Arn
StepFunctionsStateMachine:
Type: AWS::StepFunctions::StateMachine
Properties:
StateMachineName: StepFunctionsStateMachine
DefinitionString:
!Sub
- |-
{
"StartAt": "Lambda Invoke",
"States": {
"Lambda Invoke": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
"FunctionName": "${lambdaArn}"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException"
],
"IntervalSeconds": 2,
"MaxAttempts": 6,
"BackoffRate": 2
}
],
"Next": "API Gateway Request"
},
"API Gateway Request": {
"Type": "Task",
"Resource": "arn:aws:states:::apigateway:invoke",
"Parameters": {
"ApiEndpoint": "${apiGatewayId}",
"Method": "GET",
"Stage": "test",
"Path": "/"
},
"ResultSelector": {
"email.$": "$.ResponseBody[0].email"
},
"ResultPath": "$.email",
"Next": "DynamoDB PutItem"
},
"DynamoDB PutItem": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "transactions",
"Item": {
"id": {
"S.$": "$.messageId"
},
"transaction_message": {
"S.$": "$.transactionMessage"
},
"email": {
"S.$": "$.email.email"
}
}
},
"End": true
}
}
}
- lambdaArn: !GetAtt IntakeSingleTransactionLambdaFunction.Arn
apiGatewayId: !Sub "${DataEnrichmentApiGateway}.execute-api.${AWS::Region}.amazonaws.com"
RoleArn: !GetAtt StatesExecutionRole.Arn
Parameters:
SshPublicKeyParameter:
Type: String
Description: Enter your SSH public key here
Outputs:
QueueURL:
Description: "URL of Amazon SQS Queue"
Value:
Ref: "SqsQueue"
TransferServerEndpoint:
Description: "Copy endpoint of Transfer server into Cyberduck connection details"
Value: !Join
- ''
- - !GetAtt 'SftpServer.ServerId'
- .server.transfer.
- !Ref 'AWS::Region'
- .amazonaws.com