使用无服务器框架创建日志组和日志流
create log group and log stream using serverless framework
我有以下 Terraform
代码。我如何在 Serverless
框架中实现相同的功能?
resource "aws_cloudwatch_log_group" "abc" {
name = logGroupName
tags = tags
}
resource "aws_cloudwatch_log_stream" "abc" {
depends_on = ["aws_cloudwatch_log_group.abc"]
name = logStreamName
log_group_name = logGroupName
}
我的 Serverless.yml
文件看起来更像这样。基本上我需要用名称创建一个日志组和日志流。
provider:
name: aws
runtime: python3.7
cfnRole: arn:cfnRole
iamRoleStatements:
- Effect: 'Allow'
Action:
- lambda:InvokeFunction
Resource: 'arn....'
functions:
handle:
handler: handler.handle
events:
- schedule:
rate: rate (2 hours)
resources:
Resources:
IamRoleLambdaExecution:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
在您的 Resources
中,您必须添加 AWS::Logs::LogGroup and AWS::Logs::LogStream。
但是 AWS::Logs::LogGroup
上的 tags
是 not supported。
我有以下 Terraform
代码。我如何在 Serverless
框架中实现相同的功能?
resource "aws_cloudwatch_log_group" "abc" {
name = logGroupName
tags = tags
}
resource "aws_cloudwatch_log_stream" "abc" {
depends_on = ["aws_cloudwatch_log_group.abc"]
name = logStreamName
log_group_name = logGroupName
}
我的 Serverless.yml
文件看起来更像这样。基本上我需要用名称创建一个日志组和日志流。
provider:
name: aws
runtime: python3.7
cfnRole: arn:cfnRole
iamRoleStatements:
- Effect: 'Allow'
Action:
- lambda:InvokeFunction
Resource: 'arn....'
functions:
handle:
handler: handler.handle
events:
- schedule:
rate: rate (2 hours)
resources:
Resources:
IamRoleLambdaExecution:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
在您的 Resources
中,您必须添加 AWS::Logs::LogGroup and AWS::Logs::LogStream。
但是 AWS::Logs::LogGroup
上的 tags
是 not supported。