11AWSTemplateFormatVersion : ' 2010-09-09'
2- Transform : AWS::Serverless-2016-10-31
3- Description : AWS SAM template for serverless application with nested stacks
42
53Parameters :
64 Environment :
75 Type : String
8- Description : Environment on which we are working
6+ Description : deployment environment
97 Region :
108 Type : String
11- Description : Region in which we are setting up
9+ Description : AWS region
10+ ECRRepositoryTag :
11+ Type : String
12+ Description : ECR repository URI
13+
1214
1315Resources :
14- KinesisStreamStack :
15- Type : AWS::CloudFormation::Stack
16- Properties :
17- TemplateURL : resources/kinesis-stream-stack.yaml
18- Parameters :
19- Environment : !Ref Environment
20- Region : !Ref Region
21-
22- S3Stack :
23- Type : AWS::CloudFormation::Stack
16+ KinesisStream :
17+ Type : AWS::Kinesis::Stream
2418 Properties :
25- TemplateURL : resources/s3-stack.yaml
26- Parameters :
27- Environment : !Ref Environment
28- Region : !Ref Region
29-
30- LambdaStack :
31- Type : AWS::CloudFormation::Stack
32- Properties :
33- TemplateURL : resources/lambda-stack.yaml
34- Parameters :
35- Environment : !Ref Environment
36- Region : !Ref Region
37- KinesisStreamArn : !GetAtt KinesisStreamStack.Outputs.KinesisStreamArn
19+ Name : !Sub "${AWS::AccountId}-kinesis-stream"
20+ ShardCount : 1
3821
39- IAMStack :
40- Type : AWS::CloudFormation::Stack
22+ LambdaExecutionRole :
23+ Type : AWS::IAM::Role
4124 Properties :
42- TemplateURL : resources/iam-stack.yaml
43- Parameters :
44- KinesisStreamArn : !GetAtt KinesisStreamStack.Outputs.KinesisStreamArn
25+ AssumeRolePolicyDocument :
26+ Version : ' 2012-10-17'
27+ Statement :
28+ - Effect : Allow
29+ Principal :
30+ Service : lambda.amazonaws.com
31+ Action : sts:AssumeRole
32+ Policies :
33+ - PolicyName : execution-role-policy
34+ PolicyDocument :
35+ Version : ' 2012-10-17'
36+ Statement :
37+ - Effect : Allow
38+ Action :
39+ - logs:CreateLogGroup
40+ - logs:CreateLogStream
41+ - logs:PutLogEvents
42+ Resource : arn:aws:logs:*:*:*
43+ - Effect : Allow
44+ Action :
45+ - s3:PutObject
46+ Resource : !Sub "arn:aws:s3:::${Region}-${Environment}-fraud-detection-data/processed/*"
4547
46- # Outputs:
47- # KinesisStreamName:
48- # Value: !GetAtt KinesisStream.Outputs.KinesisStreamName
49- # Description: Name of the Kinesis stream
48+ LambdaFunction :
49+ Type : AWS::Lambda::Function
50+ Properties :
51+ Role : !GetAtt LambdaExecutionRole.Arn
52+ Code :
53+ ImageUri : !Sub "294331937131.dkr.ecr.ca-central-1.amazonaws.com/fraud-detection/validation-lambda:${ECRRepositoryTag}"
54+ PackageType : Image
5055
51- # ValidationLambdaArn:
52- # Value: !GetAtt LambdaStack.Outputs.ValidationLambdaArn
53- # Description: ARN of the validation Lambda function
56+ LambdaPermission :
57+ Type : AWS::Lambda::Permission
58+ Properties :
59+ FunctionName : !Ref LambdaFunction
60+ Action : lambda:InvokeFunction
61+ Principal : kinesis.amazonaws.com
5462
55- # RawDataLambdaArn:
56- # Value: !GetAtt LambdaStack.Outputs.RawDataLambdaArn
57- # Description: ARN of the raw data Lambda function
63+ Outputs :
64+ KinesisStreamName :
65+ Value : !Ref KinesisStream
66+ Description : Name of the Kinesis stream created
0 commit comments