Specify log group for an AWS lambda?

前端 未结 4 1540
星月不相逢
星月不相逢 2020-12-05 06:27

Is there a way to specify the CloudWatch log group that an AWS lambda logs to? It seems to be generated directly from the lambda name; however, it would be especially conve

4条回答
  •  醉梦人生
    2020-12-05 07:00

    Creating the log group as mentioned as one of the answers works. To keep the retention policy after the stack is deleted, just add a DeletionPolicy.

    "MyLambdaFunctionLogGroup": {
      "Type": "AWS::Logs::LogGroup",
      "DependsOn": "MyLambdaFunction",
      "DeletionPolicy": "Retain",
      "Properties": {
        "LogGroupName": {"Fn::Join": ["", ["/aws/lambda/", {"Ref": "MyLambdaFunction"}]]},
        "RetentionInDays": 14
      }
    }
    

提交回复
热议问题