如何在一个Apigee API Proxy上创建两个基本路径



我需要使用Terraform为Apigee API代理创建两个基路径代理端点。下面列出了我想要完成的任务(当然,由于重复的基本路径属性,它无法工作)-

terraform.tfvars

app_version = "1.0.0"
approval_type = "manual"
basepath = "/v1/products"
basepath = "/v2/products"

apigee.tf

locals {
basepath = var.basepath
...
}
resource "local_file" "apiproxy_files" {
basepath = locals.basepath
...
}

default.xml

<HttpProxyConnection>
<BasePath>${basepath}</BasePath>
<VirutalHost>secure</VirtualHost>
</HttpProxyConnection>

由于v1和v2位于基本路径的开头,因此不能使用通配符,因为Apigee不支持在基本路径的开头使用通配符。

提前感谢!

请注意,这种方法被认为是一种反模式。

Apigee支持同一API代理中的多个代理端点。您可以利用它在同一个API代理中定义多个基路径。


default-v1.xml
<HttpProxyConnection>
<BasePath>/v1/products</BasePath>
<VirutalHost>secure</VirtualHost>
</HttpProxyConnection>

default-v2.xml

<HttpProxyConnection>
<BasePath>/v2/products</BasePath>
<VirutalHost>secure</VirtualHost>
</HttpProxyConnection>

default-v1.xmldefault-v2.xml都需要在proxies目录下。根据URL,请求将被路由到适当的代理端点。

我无法评论如何使用Terraform来完成这一点,因为我没有任何使用Terraform的经验。

最新更新