Skip to content

Commit

Permalink
deploy lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-nhs committed Apr 8, 2024
1 parent 1014799 commit 270de5a
Showing 1 changed file with 48 additions and 9 deletions.
57 changes: 48 additions & 9 deletions SAMtemplates/functions/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AWSTemplateFormatVersion: '2010-09-09'
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: |
PSU lambda functions and related resources
Expand All @@ -12,25 +12,25 @@ Globals:
Runtime: nodejs20.x
Environment:
Variables:
NODE_OPTIONS: '--enable-source-maps'
NODE_OPTIONS: "--enable-source-maps"
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:49

Parameters:
StackName:
Type: String
Default: none

PrescriptionStatusUpdatesTableName:
Type: String
Default: none

LogLevel:
Type: String

LogRetentionInDays:
Type: Number

EnableSplunk:
Type: String

Expand All @@ -55,7 +55,7 @@ Resources:
tsconfig: updatePrescriptionStatus/tsconfig.json
EntryPoints:
- updatePrescriptionStatus/src/updatePrescriptionStatus.ts

UpdatePrescriptionStatusResources:
Type: AWS::Serverless::Application
Properties:
Expand All @@ -66,19 +66,58 @@ Resources:
LambdaArn: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackName}-UpdatePrescriptionStatus
IncludeAdditionalPolicies: true
AdditionalPolicies: !Join
- ','
- ","
- - Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionStatusUpdatesTableName}:TableWritePolicyArn
LogRetentionInDays: !Ref LogRetentionInDays
CloudWatchKMSKeyId: !ImportValue account-resources:CloudwatchLogsKmsKeyArn
EnableSplunk: !Ref EnableSplunk
SplunkSubscriptionFilterRole: !ImportValue lambda-resources:SplunkSubscriptionFilterRole
SplunkDeliveryStreamArn: !ImportValue lambda-resources:SplunkDeliveryStream

GUSL:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${StackName}-GetStatusUpdates
CodeUri: ../../packages
Handler: getStatusUpdates.handler
Role: !GetAtt GSULResources.Outputs.LambdaRoleArn
Environment:
Variables:
TABLE_NAME: !Ref PrescriptionStatusUpdatesTableName
LOG_LEVEL: !Ref LogLevel
Metadata:
BuildMethod: esbuild
BuildProperties:
Minify: true
Target: es2020
Sourcemap: true
tsconfig: gsul/tsconfig.json
EntryPoints:
- gsul/src/getStatusUpdates.ts

GSULResources:
Type: AWS::Serverless::Application
Properties:
Location: lambda_resources.yaml
Parameters:
StackName: !Ref StackName
LambdaName: !Sub ${StackName}-GetStatusUpdates
LambdaArn: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackName}-GetStatusUpdates
IncludeAdditionalPolicies: true
AdditionalPolicies: !Join
- ","
- - Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionStatusUpdatesTableName}:TableReadPolicyArn
LogRetentionInDays: !Ref LogRetentionInDays
CloudWatchKMSKeyId: !ImportValue account-resources:CloudwatchLogsKmsKeyArn
EnableSplunk: !Ref EnableSplunk
SplunkSubscriptionFilterRole: !ImportValue lambda-resources:SplunkSubscriptionFilterRole
SplunkDeliveryStreamArn: !ImportValue lambda-resources:SplunkDeliveryStream

Outputs:
UpdatePrescriptionStatusFunctionName:
Description: The function name of the UpdatePrescriptionStatus lambda
Value: !Ref UpdatePrescriptionStatus

UpdatePrescriptionStatusFunctionArn:
Description: The function ARN of the UpdatePrescriptionStatus lambda
Value: !GetAtt UpdatePrescriptionStatus.Arn
Value: !GetAtt UpdatePrescriptionStatus.Arn

0 comments on commit 270de5a

Please sign in to comment.