Skip to content

Commit b4342ff

Browse files
committed
tidy up SAM templates so insights work
1 parent c5d50d3 commit b4342ff

2 files changed

Lines changed: 55 additions & 39 deletions

File tree

SAMtemplates/lambda_resources.yaml

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,17 @@ Resources:
6868
Principal:
6969
Service: "lambda.amazonaws.com"
7070
Action: "sts:AssumeRole"
71-
LambdaPolicy:
72-
Type: "AWS::IAM::ManagedPolicy"
71+
ManagedPolicyArns:
72+
- !ImportValue lambda-resources:LambdaInsightsLogGroupPolicy
73+
- !ImportValue account-resources:LambdaEncryptCloudwatchKMSPolicy
74+
75+
LambdaManagedPolicy:
76+
Type: AWS::IAM::ManagedPolicy
7377
Properties:
74-
Description: "allow access to logs for lambda role"
78+
Roles:
79+
- !Ref LambdaRole
7580
PolicyDocument:
76-
Version: "2012-10-17"
81+
Version: 2012-10-17
7782
Statement:
7883
- Effect: Allow
7984
Action:
@@ -82,45 +87,14 @@ Resources:
8287
Resource:
8388
- !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:${LambdaLogGroup}"
8489
- !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:${LambdaLogGroup}:log-stream:*"
85-
Roles:
86-
- !Ref LambdaRole
87-
LambdaKMSPolicy:
88-
Type: "AWS::IAM::ManagedPolicy"
89-
Properties:
90-
Description: "allow access to cloudwatch KMS key for lambda role"
91-
PolicyDocument:
92-
Version: "2012-10-17"
93-
Statement:
94-
- Effect: Allow
95-
Action:
96-
- kms:DescribeKey
97-
- kms:GenerateDataKey*
98-
- kms:Encrypt
99-
- kms:ReEncrypt*
100-
Resource:
101-
- !Ref CloudWatchKMSKey
102-
Roles:
103-
- !Ref LambdaRole
104-
LambdaSecretsKMSPolicy:
105-
Type: "AWS::IAM::ManagedPolicy"
106-
Properties:
107-
Description: "allow access to secrets KMS key for lambda role"
108-
PolicyDocument:
109-
Version: "2012-10-17"
110-
Statement:
111-
- Effect: Allow
112-
Action:
113-
- kms:Decrypt
114-
Resource:
115-
- !ImportValue account-resources:SecretsKMSKey
116-
Roles:
117-
- !Ref LambdaRole
90+
11891
LambdaLogGroup:
11992
Type: "AWS::Logs::LogGroup"
12093
Properties:
12194
LogGroupName: !Sub "/aws/lambda/${LambdaName}"
12295
RetentionInDays: !Ref LogRetentionDays
12396
KmsKeyId: !Ref CloudWatchKMSKey
97+
12498
LambdaSplunkSubscriptionFilter:
12599
Condition: ShouldUseSplunk
126100
Type: AWS::Logs::SubscriptionFilter

SAMtemplates/main_template.yaml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,49 @@ Transform: AWS::Serverless-2016-10-31
33
Description: >
44
FHIR validator lambda
55
6+
Parameters:
7+
VersionNumber:
8+
Type: String
9+
Description: Current release version
10+
Default: "xxx"
11+
CommitId:
12+
Type: String
13+
Description: Most recent commit hash
14+
Default: "xxx"
15+
LogLevel:
16+
Type: String
17+
Description: The log level to set in the lambda
18+
Default: "INFO"
19+
LogRetentionDays:
20+
Type: Number
21+
Description: How long to keep logs for
22+
Default: 30
23+
AllowedValues:
24+
[
25+
1,
26+
3,
27+
5,
28+
7,
29+
14,
30+
30,
31+
60,
32+
90,
33+
120,
34+
150,
35+
180,
36+
365,
37+
400,
38+
545,
39+
731,
40+
1096,
41+
1827,
42+
2192,
43+
2557,
44+
2922,
45+
3288,
46+
3653,
47+
]
48+
649
Resources:
750
FHIRValidatorResources:
851
Type: AWS::Serverless::Application
@@ -14,7 +57,7 @@ Resources:
1457
SplunkDeliveryStream: !ImportValue lambda-resources:SplunkDeliveryStream
1558
EnableSplunk: "true"
1659
LambdaName: !Sub "${AWS::StackName}-FHIRValidator"
17-
LogRetentionDays: "30"
60+
LogRetentionDays: !Ref LogRetentionDays
1861

1962
FHIRValidator:
2063
Type: AWS::Serverless::Function
@@ -34,7 +77,6 @@ Resources:
3477
Layers:
3578
- !Sub "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:38"
3679

37-
3880
Outputs:
3981
FHIRValidatorLambdaName:
4082
Description: Name of the FHIR validator lambda

0 commit comments

Comments
 (0)