Amazon cloudformation 在CloudFormation模板中指定外部边缘网关APID的格式是什么?
我正在尝试使用以下CloudFormation模板创建或更新堆栈:Amazon cloudformation 在CloudFormation模板中指定外部边缘网关APID的格式是什么?,amazon-cloudformation,aws-api-gateway,Amazon Cloudformation,Aws Api Gateway,我正在尝试使用以下CloudFormation模板创建或更新堆栈: AWSTemplateFormatVersion: '2010-09-09' Parameters: ApiGatewayId: Type: String ApiLayerArn: Type: String JarLocation: Type: String Resources: Function: Type: 'AWS::Lambda::Function' Prop
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
ApiGatewayId:
Type: String
ApiLayerArn:
Type: String
JarLocation:
Type: String
Resources:
Function:
Type: 'AWS::Lambda::Function'
Properties:
Handler: net.bitsandpaper.api.kiosk.PlatformChecker
Runtime: java11
Code:
S3Bucket: bnp-build-artifacts
S3Key: !Ref JarLocation
Description: ''
MemorySize: 128
Timeout: 5
Role: arn:aws:iam::479832603967:role/bnp-api-lambda-execution-role
Layers:
- !Ref ApiLayerArn
ApiIntegration:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref ApiGatewayId
IntegrationType: AWS_PROXY
IntegrationUri: !Join
- ''
- - 'arn:'
- !Ref 'AWS::Partition'
- ':apigateway:'
- !Ref 'AWS::Region'
- ':lambda:path/2015-03-31/functions/'
- !Ref Function
- /invocations
TimeoutInMillis: 6000
ApiRoute:
Type: AWS::ApiGatewayV2::Route
Properties:
ApiId: !Ref ApiGatewayId
RouteKey: 'GET /kiosk/platform-check'
Target: !Join
- /
- - integrations
- !Ref ApiIntegration
参数通过外部文件正确传递,它们在Web控制台中看起来很好,尤其是参数ApiGatewayId
具有值8548rqrsm5
。然而,在部署期间,我有一个CREATE\u失败的apintegration
,消息如下:
指定的API标识符479832603967:8548rqrsm5无效(服务:
AmazonApiGatewayV2;状态代码:404;错误代码:NotFoundException;
请求ID:84918a83-cf9d-48d2-acf7-18d9d2e4d330;代理:null)
该API是一个边缘Rest API,与CloudFormation堆栈位于同一区域。CLI通过aws API网关获取rest API
检索ID
我是否缺少APID格式中的某些内容?当不引用同一堆栈中的API时,该文件非常稀少…这似乎像是在集成之前创建了AWS::ApiGatewayV2::Route。因此,当它试图引用APIC集成时,它还没有被创建
所以您应该尝试使用DependsOn属性
使用DependsOn属性,可以指定
具体资源紧随其后。添加DependsOn属性时
对于资源,该资源仅在创建
DependsOn属性中指定的资源
请尝试以下代码:
ApiRoute:
Type: AWS::ApiGatewayV2::Route
DependsOn: ApiIntegration
Properties:
ApiId: !Ref ApiGatewayId
RouteKey: 'GET /kiosk/platform-check'
Target: !Join
- /
- - integrations
- !Ref ApiIntegration
我希望这能帮助你解决你的问题
链接:AWS::ApiGatewayV2
仅适用于WebSocket和HTTP类型。发件人:
API协议。有效值为WEBSOCKET或HTTP
但是,由于您正在编写关于边缘优化的(HTTP api不支持),因此您似乎在使用REST api,而不是HTTP api。因此,您应该使用资源,而不是AWS::ApiGatewayV2
感谢您指出Abdul,它在将来肯定会有帮助,遗憾的是,这不是问题所在。我在模板中添加了DependsOn说明,但是,谢谢:)这是我的问题,谢谢。这是AWS方面的糟糕命名…@SilverQuettier没问题。很高兴我能帮忙。