在 CloudFormation 模板中为 "AWS::ApiGateway::Resource" 指定 ParentId
Specify ParentId for "AWS::ApiGateway::Resource" in CloudFormation template
如何在 CloudFormation 模板中为 "AWS::ApiGateway::Resource" 指定现有 "AWS::ApiGateway::RestApi" 的 ParentId?例如,我已经创建了 API Gateway REST API 并且我想在我的模板中指定它:
MyTestResource:
Type: 'AWS::ApiGateway::Resource'
Properties:
RestApiId:
Ref: 'RestApi'
ParentId: <<placeholder_for_my_value>>
如果我也在我的模板中描述 "AWS::ApiGateway::RestApi",我可以这样做:
ParentId: !GetAtt "RestApi.RootResourceId"
但是我如何才能对现有的 REST API 执行此操作?
您可以通过控制台查找现有 REST API 的资源 ID
单击 "your REST API" -> "Resources"
在左上方你会看到类似
的东西
APIs>YOUR_API_NAME (YOUT_API_ID)>Resources>/your_already_existing_resource (YOUR_RESOURCE_ID)
这就是您可以指定为 "parentId" 的资源 ID。
或者,使用 aws
cli。
https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-resources.html
您需要指定 rest-api-id
的位置,您可以再次从控制台或通过 https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-rest-apis.html
获取
事实上,如果您需要在现有 API 中指定新资源,您可以在 CloudFormation 中检查堆栈,在资源选项卡中查看 [=21= 的 Logical Did ] 已生成。
Whit that LogicalId 你可以用那种方式指定,将逻辑 Id 考虑为 RestApiLogicalId:
"ParentId": {
"Fn::GetAtt": [
"RestApiLogicalId",
"RootResourceId"
]
}
尽情享受吧!
如何在 CloudFormation 模板中为 "AWS::ApiGateway::Resource" 指定现有 "AWS::ApiGateway::RestApi" 的 ParentId?例如,我已经创建了 API Gateway REST API 并且我想在我的模板中指定它:
MyTestResource:
Type: 'AWS::ApiGateway::Resource'
Properties:
RestApiId:
Ref: 'RestApi'
ParentId: <<placeholder_for_my_value>>
如果我也在我的模板中描述 "AWS::ApiGateway::RestApi",我可以这样做:
ParentId: !GetAtt "RestApi.RootResourceId"
但是我如何才能对现有的 REST API 执行此操作?
您可以通过控制台查找现有 REST API 的资源 ID 单击 "your REST API" -> "Resources" 在左上方你会看到类似
的东西 APIs>YOUR_API_NAME (YOUT_API_ID)>Resources>/your_already_existing_resource (YOUR_RESOURCE_ID)
这就是您可以指定为 "parentId" 的资源 ID。
或者,使用 aws
cli。
https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-resources.html
您需要指定 rest-api-id
的位置,您可以再次从控制台或通过 https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-rest-apis.html
事实上,如果您需要在现有 API 中指定新资源,您可以在 CloudFormation 中检查堆栈,在资源选项卡中查看 [=21= 的 Logical Did ] 已生成。
Whit that LogicalId 你可以用那种方式指定,将逻辑 Id 考虑为 RestApiLogicalId:
"ParentId": {
"Fn::GetAtt": [
"RestApiLogicalId",
"RootResourceId"
]
}
尽情享受吧!