簡體   English   中英

在 SAM 模板(CF 堆棧)中引用 AWS Lambda 的角色 YAML

[英]Referencing an AWS Lambda's role inside a SAM Template (CF Stack) YAML

我有一個 AWS SAM 模板,其中定義了一個 JavaScript Lambda:

Resources:
  notesFunction:
    Type: AWS::Serverless::Function
    Properties:
      PackageType: Zip
      CodeUri: notes/
      Handler: app.lambdaHandler
      Runtime: nodejs18.x
      Policies:
      - AmazonDynamoDBFullAccess
      Architectures:
        - x86_64
      Events:
        Fetchnotes:
          Type: Api
          Properties:
            Path: /notes
            Method: get
        Givenotes:
          Type: Api
          Properties:
            Path: /notes
            Method: post
        Users:
          Type: Api
          Properties:
            Path: /notes/users
            Method: get
    Metadata:
      BuildMethod: esbuild
      BuildProperties:
        Minify: true
        Target: "es2020"
        Sourcemap: true
        EntryPoints:
        - app.ts

稍后在模板中,我嘗試引用此 Lambda 的角色(例如: Role: !Ref <MyLambdaRole> )但不確定如何執行此操作,因為角色是在部署 SAM 模板(CloudFormation 堆棧)時即時創建的. 我有什么想法可以做到這一點?

如果您未在AWS::Serverless::Function定義中提供角色,SAM 會創建一個邏輯 ID 為<function‑LogicalId>Role

在您的情況下,這將是!Ref notesFunctionRole

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM