Preview:
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      PackageType: Image
      Architectures:
        - x86_64
      Policies:
        - AWSSecretsManagerGetSecretValuePolicy:
            SecretArn: !Sub "arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:openweatherapi-mSlPys"
      Events:
        HelloWorld:
          Type: Api
          Properties:
            Path: /hello
            Method: get
            
            

  FunctionName:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: function_name/
      Handler: app.lambda_handler
      Runtime: python3.9
      Architectures:
        - x86_64
      Policies:
        - AWSSecretsManagerGetSecretValuePolicy:
            SecretArn: !Sub "arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:openweatherapi-[xxxxxx]"

## aws sam Cloudwatch Alarm ######################
LambdaFunctionAlarm:
  Type: 'AWS::CloudWatch::Alarm'
  Properties:
    ActionsEnabled: true
    AlarmName: !Sub '${FunctionName}-alarm'
    AlarmActions:
      - !Sub 'arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${SnsTopicName}'
    Namespace: 'AWS/Lambda'
    MetricName: Errors
    Dimensions:
        - Name: FunctionName
          Value: !Sub '${FunctionName}'
    Statistic: Average
    ComparisonOperator: GreaterThanOrEqualToThreshold
    Threshold: 1
    DatapointsToAlarm: 1
    Period: 5
    EvaluationPeriods: 1
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter