Files
ThingsBoard/EKKO Reports/thunderbirdfs-daily-report/template.yaml
2025-06-25 13:50:16 -05:00

85 lines
2.9 KiB
YAML

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
thunderbirdfs-daily-report
Sample SAM Template for thunderbirdfs-daily-report
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 6
MemorySize: 512
# You can add LoggingConfig parameters such as the Logformat, Log Group, and SystemLogLevel or ApplicationLogLevel. Learn more here https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-loggingconfig.
LoggingConfig:
LogFormat: JSON
Resources:
ThunderbirdFSReport:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
Timeout: 600
CodeUri: thunderbirdfsreport/
Handler: thunderbirdfsreport.lambda_handler
Runtime: python3.9
Environment:
Variables:
username: nico.a.melone@gmail.com
password: 9EE#mqb*b6bXV9hJrPYGm&w3q5Y@3acumvvb5isQ
Architectures:
- x86_64
Layers:
- !Ref TFSReportLayer
- arn:aws:lambda:us-east-1:668099181075:layer:AWSLambda-Python36-SciPy1x:115
Policies:
- AmazonSESFullAccess
- Statement:
- Effect: Allow
Action:
- s3:PutObject
Resource:
- !Sub arn:${AWS::Partition}:s3:::!ImportValue TBReportBucket
- !Sub arn:${AWS::Partition}:s3:::!ImportValue TBReportBucket/*
TFSReportLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: tfsreportlayer/
CompatibleRuntimes:
- python3.9
- python3.10
- python3.11
- python3.12
Metadata:
BuildMethod: python3.9
Schedule:
Type: AWS::Scheduler::Schedule
Properties:
ScheduleExpression: cron(0 2 * * ? *)
FlexibleTimeWindow:
Mode: 'OFF'
ScheduleExpressionTimezone: America/Juneau
Target:
Arn: !GetAtt ThunderbirdFSReport.Arn
RoleArn: !GetAtt ScheduleToTFSReportRole.Arn
ScheduleToTFSReportRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
Effect: Allow
Principal:
Service: !Sub scheduler.${AWS::URLSuffix}
Action: sts:AssumeRole
Policies:
- PolicyName: StartExecutionPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action: lambda:InvokeFunction
Resource:
- !GetAtt ThunderbirdFSReport.Arn
- !Sub arn:${AWS::Partition}:s3:::!ImportValue TBReportBucket
- !Sub arn:${AWS::Partition}:s3:::!ImportValue TBReportBucket/*