gpt4 book ai didi

amazon-web-services - 有没有办法使用 cloudformation 创建 aws lambda 执行角色?

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

我正在尝试使用 cloudformation 创建 lambda 函数,但它需要 lambda 执行角色 - 有没有办法可以使用 cloudformation 生成一个 lambda 函数?

最佳答案

是的,CloudFormation 可用于创建 IAM 角色。 lambda 执行角色是一个 IAM 角色,与任何其他 IAM 角色一样。 documentation为此,请参阅以下示例:

MyRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument: Json
Description: String
ManagedPolicyArns:
- String
MaxSessionDuration: Integer
Path: String
PermissionsBoundary: String
Policies:
- Policy
RoleName: String
Tags:
- Tag

然后在 lambda 中,使用角色资源名称的 ref 来引用它。例如:

  MyLambdaFunction:
Type: AWS::Lambda::Function
Properties:
Role: !Ref MyRole

关于amazon-web-services - 有没有办法使用 cloudformation 创建 aws lambda 执行角色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70368288/

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