gpt4 book ai didi

amazon-web-services - Lambda SAM 部署在 'EC2DescribePolicy' 处给出错误 'policyArn' 未能满足约束 : Member must have length greater than or equal to 20

转载 作者:行者123 更新时间:2023-12-03 07:22:17 31 4
gpt4 key购买 nike

我正在使用 AWS SAM 通过 cloudformation 部署 Lambda。 lambda 使用 StartInstancesCommand、StopInstancesCommand 和DescribeInstancesCommand API 按计划打开和关闭实例。

同时使用 EC2DescribePolicyEC2FullAccessPolicy SAM 策略模板时,我遇到了以下错误:

sam 部署

1 validation error detected: Value'EC2DescribePolicy' at 'policyArn'failed to satisfy constraint:Member must have length greaterthan or equal to 20 (Service:AmazonIdentityManagement;Status Code: 400; Error Code: ValidationError;

Screenshot of SAM deploy error 'policyArn' failed to satisfy constraint: Member must have length greater than or equal to 20

如何修复此错误?我必须手动指定“policyArn”吗?

我的模板.yaml:

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
test-function

Resources:
TestFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: test-function/
Handler: app.lambdaHandler
Runtime: nodejs16.x
MemorySize: 512
Timeout: 60
Policies:
- AWSLambdaBasicExecutionRole
- AWSLambdaVPCAccessExecutionRole
- EC2DescribePolicy
Architectures:
- x86_64
Events:
ScheduledEvent:
Type: Schedule
Properties:
Schedule: cron(0 8 * * ? *)
Enabled: True

版本信息:

$ sam --version
SAM CLI, version 1.60.0
$ node --version
v16.17.0
$ docker --version
Docker version 20.10.17, build 100c701
$ python3 --version
Python 3.9.6

最佳答案

documentation状态:

For every policy template you specify in your AWS SAM template file, you must always specify an object containing the policy template's placeholder values. If a policy template does not require any placeholder values, you must specify an empty object.

所以你应该:

Policies:
- AWSLambdaBasicExecutionRole
- AWSLambdaVPCAccessExecutionRole
- EC2DescribePolicy : {}

关于amazon-web-services - Lambda SAM 部署在 'EC2DescribePolicy' 处给出错误 'policyArn' 未能满足约束 : Member must have length greater than or equal to 20,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74263148/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com