简体   繁体   English

使用 cloudformation 部署时如何获取 AWS Api 网关的 arn

[英]How to get arn of AWS Api gateway when deploying with cloudformation

I am trying to deploy a function and aws api gateway using cloudformation.我正在尝试使用 cloudformation 部署 function 和 aws api 网关。 In LambdaPermission resource there is a property which is SourceArn and it expects the ARN of the resource that will invoke the function, in this case it will be api gateway.LambdaPermission资源中有一个属性是SourceArn ,它期望资源的 ARN 将调用 function,在这种情况下它将是 api 网关。 Now ApiGateway resource does not provide the output value of arn.现在ApiGateway资源不提供 arn 的 output 值。 So my question is how we can access it?所以我的问题是我们如何访问它?

here is the resource of Lambda Permission where I need to put the value in sourcearn.这是 Lambda 权限的资源,我需要将值放入 sourcearn。

LambdaPermission:
    Type: "AWS::Lambda::Permission"
    Properties:
        Action: "lambda:InvokeFunction"
        FunctionName: !GetAtt LambdaFunction.Arn
        Principal: "apigateway.amazonaws.com"
        SourceArn: "How to get this value"

The format:格式:

SourceArn:
  Fn::Join:
  - ''
  - - 'arn:'
    - Ref: AWS::Partition
    - ":execute-api:"
    - Ref: AWS::Region
    - ":"
    - Ref: AWS::AccountId
    - ":"
    - Ref: "Logical ID of resource of type AWS::ApiGateway::RestApi"
    - "/"
    - Ref: "Logical ID of resource of type AWS::ApiGateway::Stage"
    - "/GET or POST or other HTTP Methods/your/resource/path/here"

An example:一个例子:

SourceArn:
  Fn::Join:
  - ''
  - - 'arn:'
    - Ref: AWS::Partition
    - ":execute-api:"
    - Ref: AWS::Region
    - ":"
    - Ref: AWS::AccountId
    - ":"
    - Ref: ApiGatewayRestApiResource
    - "/"
    - Ref: ApiGatewayStageResource
    - "/GET/example"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM