serverless-step-functions icon indicating copy to clipboard operation
serverless-step-functions copied to clipboard

Config cloudWatch with serverless.yml Error

Open nuskirk opened this issue 3 years ago • 2 comments

I follow this example about config CloudWatchLogs for the Express Workflow

stepFunctions:
  stateMachines:
    hellostepfunc1:
      type: EXPRESS
      loggingConfig:
        level: ERROR
        includeExecutionData: true
        destinations:
          - Fn::GetAtt: [MyLogGroup, Arn]

But It not clear. What is the MyLogGroup and how I can config for this? I try to create a function lambda MyLogGroup and build but I have an issue:

Error: The CloudFormation template is invalid: ValidationError: Template error: instance of Fn::GetAtt references undefined resource MyLogGroup

Can help me with 1 example?

nuskirk avatar Apr 06 '21 07:04 nuskirk

@horike37

nuskirk avatar Apr 07 '21 03:04 nuskirk

@nuskirk I found this issue today, so I happy to explain:

this error displays because you do not have such a resource defined, so arn cannot be fetched.

What you can do is to define with cloudformation a new log group, and then refer to it:

Within the serverless.yml in the resources do:

resources:
  Resources:
    YourNameForTheLogGroup:
      Type: AWS::Logs::LogGroup
      Properties:
        RetentionInDays: 30

After this, in your step functions definition add:

      loggingConfig:
        level: ERROR
        includeExecutionData: true
        destinations: 
          - !GetAtt YourNameForTheLogGroup.Arn

And that's it: Screenshot 2022-09-07 at 21 59 01

@nuskirk can you check it, and ping here, so @horike37 could close the issue :)

Pigius avatar Sep 07 '22 20:09 Pigius