[fixed] how to create log group?

I think this is a simple job.

$ serverless create --template aws-nodejs --path my-service
$ cd my-service

# add a new resource `AWS::Logs::LogGroup` into `serverless.yml`

$ cat serverless.yml

service:  my-service

provider:
  name: aws
  runtime: nodejs6.10

functions:
  hello:
    handler: handler.hello

resources:
  Resources:
    AccessLogs:
      Type: AWS::Logs::LogGroup
      Properties:
        LogGroupName: /aws/apigateway/${self:service}-AccessLogs

When run sls deploy, there is no any error. But I don’t see the log group /aws/apigateway/my-service-AccessLogs is created.

Check the cloudformation template cloudformation-template-update-stack.json, two logs groups need be created.

"HelloLogGroup": {
  "Type": "AWS::Logs::LogGroup",
  "Properties": {
    "LogGroupName": "/aws/lambda/my-service-dev-hello"
  }
},

"AccessLogs": {
  "Type": "AWS::Logs::LogGroup",
  "Properties": {
    "LogGroupName": "/aws/apigateway/my-service-AccessLogs"
  }
}

but why I can’t see it in cloudwatch?

Any hints for me?

I finally saw an error when click its resource from the related cloudformation stack:

There was an error loading Log Streams. Please try again by refreshing this page.

Fix

I fixed it with the answer from aws:

Could you try going through the process at Amazon Web Services Sign-In and then verify if you still see the error?
The problem might be that accounts created long time ago would not subscribe to new services automatically. Going through above process will make the account subscribed to all existing services and future new services.
Similar post: Forums | AWS re:Post

This is my first time to know this resubscribe feature. Good to know.

Another fix

Furthermore, I met the same problem in another aws account, which need an extra step:

here is the link to activate the services on the account:
AWS Console - Signup
Once the services are activated and support, the EULA is signed.

Seems the owner to apply the account forgot to active EULA (End user license agreement). After actived EULA and resubscribe, the problem is fixed.

are you able to figure out why two log groups are being created? even you have give only one to create

Serverless will automatically create a log group, so this config is creating an additional one. You can disable the automatic one with disableLogs: true

Can you help me config Serverless cloudWatch?
My config
nameLogs:
handler: lambda/index.functionLogsLB
events:
- cloudwatchLog: ‘/aws/logs/name-logs’
But I have an error: he specified log group does not exist. (Service: AWSLogs; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: <id>; Proxy: null).
Can help me if I mistake something

1 Like