我需要制作一个包含Lambda和CloudWatch事件的CloudFormation模板,以便定期触发它。以下是我的模板:
这段代码创建了一个指向lambda的lambda和事件规则。
但它并没有在lambda本身中创建触发器。如果我手动添加触发器,它就可以正常工作。我做错了什么?
CertPolicyLambda:
Type: AWS::Serverless::Function
Properties:
Handler: cert-policy
Runtime: go1.x
CodeUri: s3://venafi-policy-sam/73b1ee5fab9f9f089838227389c27273
Description: Venfi policy with a RESTful API endpoint using Amazon API Gateway.
MemorySize: 512
Timeout: 10
Role:
Fn::Sub: arn:aws:iam::${AWS::AccountId}:role/lambda-venafi-role
S3_BUCKET: cert-policy-lambda
ScheduledRule:
Type: AWS::Events::Rule
Properties:
Description: ScheduledRule
ScheduleExpression: rate(1 minute)
State: ENABLED
Targets:
- Arn:
Fn::Sub: ${CertPolicyLambda.Arn}
Id:
Ref: CertPolicyLambda
PermissionForEventsToInvokeLambda:
Type: AWS::Lambda::Permission
Properties:
FunctionName:
Ref: CertPolicyLambda
Action: lambda:InvokeFunction
Principal: events.amazonaws.com
SourceArn:
Fn::GetAtt:
- CertPolicyLambda
- Arn
这段代码创建了一个指向lambda的lambda和事件规则。
![enter image description here](https://istack.dev59.com/VAJT3.webp)
AWS::Serverless::Function
还是AWS::Lambda::Function
? - jogoldAWS::Serverless::Function
。 - jogold