如何在部署cloudformation时获得AWS Api网关的arn



我正在尝试使用cloudformation部署一个函数和aws-api网关。在LambdaPermission资源中,有一个属性是SourceArn,它期望调用该函数的资源的ARN,在这种情况下,它将是api网关。现在ApiGateway资源不提供arn的输出值。所以我的问题是我们如何访问它?

这是Lambda Permission的资源,我需要将值放在sourcearn中。

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

格式:

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"

一个例子:

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

最新更新