Amazon web services 如何使用OpenAPI for aws\u api\u gateway\u rest\u api
我尝试使用OpenAPI,因为它看起来像一个标准,而且比terraform资源更简单。我已将json转换为terraform可能采用的格式,但我得到了错误:Amazon web services 如何使用OpenAPI for aws\u api\u gateway\u rest\u api,amazon-web-services,terraform,openapi,Amazon Web Services,Terraform,Openapi,我尝试使用OpenAPI,因为它看起来像一个标准,而且比terraform资源更简单。我已将json转换为terraform可能采用的格式,但我得到了错误: module.aws_api_gateway.aws_api_gateway_rest_api.CICDAPI: body must be a single value, not a list 下面是我的代码: resource "aws_api_gateway_rest_api" "CICDAPI" { name =
module.aws_api_gateway.aws_api_gateway_rest_api.CICDAPI: body must be a single value, not a list
下面是我的代码:
resource "aws_api_gateway_rest_api" "CICDAPI" {
name = "cicdapi"
description = "cicd build pipeline"
binary_media_types = [
"application/json"
]
body = {
swagger = 2
info {
title = "AwsServerlessExpressApi"
}
basePath = "/prod"
schemes = [
"https"
]
....
我还没有找到一个关于如何将OpenAPI分配给aws网关api资源的示例。我能把body变成json字符串吗???文档中没有提到它。从错误中可以看出,它需要是字符串,而不是代码中的哈希映射 您应该能够简单地将主体值包装在一个容器中 所以你想要的是:
resource "aws_api_gateway_rest_api" "CICDAPI" {
name = "cicdapi"
description = "cicd build pipeline"
binary_media_types = [
"application/json"
]
body = <<EOF
{
swagger = 2
info {
title = "AwsServerlessExpressApi"
}
basePath = "/prod"
schemes = [
"https"
]
....
}
EOF
}
资源“aws\U api\U网关\U rest\U api”“CICDAPI”{
name=“cicdapi”
description=“cicd构建管道”
二进制\媒体\类型=[
“应用程序/json”
]
身体=