使用 cloudformation 部署时如何获取 AWS Api 网关的 arn
How to get arn of AWS Api gateway when deploying with cloudformation
我正在尝试使用 cloudformation 部署函数和 aws api 网关。在 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. Now 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"
我正在尝试使用 cloudformation 部署函数和 aws api 网关。在 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. Now 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"