I need to create two basepath proxy enpoints for an Apigee API proxy using Terraform. Below illistates what I am trying to accomplish (of course it does not work due to duplicate basepath properties)-
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>
Since v1 and v2 are at the beginning of the basepath, wildcards cannot be used as Apigee does not support wildcards at the start of the basepath.
Thanks in advance!
Be warned, this approach is considered an antipattern.
Apigee supports multiple proxy endpoints within the same API proxy. You may leverage this to define multiple base paths within the same API proxy.
Something like this -
default-v1.xml
<HttpProxyConnection>
<BasePath>/v1/products</BasePath>
<VirutalHost>secure</VirtualHost>
</HttpProxyConnection>
default-v2.xml
<HttpProxyConnection>
<BasePath>/v2/products</BasePath>
<VirutalHost>secure</VirtualHost>
</HttpProxyConnection>
Both default-v1.xml
and default-v2.xml
will need to be in the proxies
directory. Depending on the URL the request will be routed to appropriate proxy endpoint.
I cannot comment on how this could be done using Terraform as I do not have any experience with Terraform.