代码之家  ›  专栏  ›  技术社区  ›  divyanayan awasthi

通过控制台创建sam应用程序时,在template.yml文件中附加先前存在的角色

  •  0
  • divyanayan awasthi  · 技术社区  · 6 年前

    这是我的模板

    AWSTemplateFormatVersion : '2010-09-09'
    Transform: AWS::Serverless-2016-10-31
    Resources:
      POCLambdaExecutionRole:
      Type: 'AWS::IAM::Role'
      SAMLocal:
        Type: AWS::Serverless::Function
        Properties:
          Handler: SAMLocal.lambda_handler
          Runtime: python2.7
        TracingConfig:
          Mode: Active
          Environment:
            Variables:
              dev_table: "MessageQueue"
          Events:
            SAMLocal:
              Type: Api
              Properties:
                Path: /
                Method: GET
      SAMLocal1:
        Type: AWS::Serverless::Function
        Properties:
          Handler: SAMLocal.lambda_handler
          Runtime: python2.7
    

    我怎样才能达到同样的效果。

    找到这篇关于堆栈溢出的文章,但对我的原因没有帮助 Associate existing IAM role with EC2 instance in CloudFormation

    2 回复  |  直到 6 年前
        1
  •  3
  •   Yash Bindlish    6 年前

    您需要将现有角色以ARN格式放入yaml文件中

        2
  •  0
  •   Yash Bindlish    6 年前

    您可以设置角色或权限。如果未为函数定义角色,SAM将为每个函数创建一个角色。默认情况下,它将分别作用于每个函数。

    按照我在解决方案Role:arn:aws:iam::XXXXXX:Role/Role中描述的方式在您的功能之外声明角色

    Check THIS