src/services/dashboard/serverless.yml
service: ${self:custom.project}-dashboard
frameworkVersion: "3"
package:
individually: true
plugins:
- serverless-plugin-typescript
- serverless-stack-termination-protection
- "@stratiformdigital/serverless-iam-helper"
- "@stratiformdigital/serverless-s3-security-helper"
provider:
name: aws
runtime: nodejs18.x
region: ${env:REGION_A}
stackTags:
PROJECT: ${self:custom.project}
SERVICE: ${self:service}
iam:
role:
path: /delegatedadmin/developer/
permissionsBoundary: arn:aws:iam::${aws:accountId}:policy/cms-cloud-admin/developer-boundary-policy
statements:
- Effect: Allow
Action:
- cloudwatch:GetDashboard
Resource: "*"
custom:
project: ${env:PROJECT}
accountId: !Sub "${AWS::AccountId}"
serverlessTerminationProtection:
stages: # Apply CloudFormation termination protection for these stages
- master
- val
- production
functions:
templatizeCloudWatchDashboard:
handler: handlers/templatizeCloudWatchDashboard.handler
environment:
stage: ${sls:stage}
region: ${env:REGION_A}
project: ${self:custom.project}
accountId: ${aws:accountId}
service: ${self:service}
maximumRetryAttempts: 0
createDashboardTemplateWidget:
handler: handlers/createDashboardTemplateWidget.handler
environment:
lambdaArnToCall: !GetAtt TemplatizeCloudWatchDashboardLambdaFunction.Arn
resources:
Resources:
CloudWatchDashboard:
Type: AWS::CloudWatch::Dashboard
Properties:
DashboardName: ${self:service}-${sls:stage}
DashboardBody: ${file(./templateDashboard.txt)}