resource "anypoint_api_instance" "weighted_routing" {
environment_id = var.environment_id
gateway_id = var.gateway_id
instance_label = "weighted-routing-demo"
spec = {
asset_id = "my-api"
group_id = var.organization_id
version = "1.0.0"
}
endpoint = {
base_path = "weightedRouting"
}
routing = [
{
label = "canary"
upstreams = [
{
weight = 90
uri = "http://backend-stable.internal:8080"
label = "stable"
},
{
weight = 10
uri = "http://backend-canary.internal:8080"
label = "canary"
}
]
}
]
}
if i run apply after making some changes in upstreams , it would throw error
Terraform will perform the following actions:
anypoint_api_instance.terraform_demo will be updated in-place
~ resource "anypoint_api_instance" "terraform_demo" {
id = "20938007"
~ routing = [
~ {
~ upstreams = [
~ {
~ uri = "http://backend-canary.internal:8080" -> "http://backend-canary.internal:8090"
# (2 unchanged attributes hidden)
},
# (1 unchanged element hidden)
]
# (1 unchanged attribute hidden)
},
]
# (12 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
anypoint_api_instance.terraform_demo: Modifying... [id=20938007]
╷
│ Error: Error updating API instance
│
│ with anypoint_api_instance.terraform_demo,
│ on main.tf line 1, in resource "anypoint_api_instance" "terraform_demo":
│ 1: resource "anypoint_api_instance" "terraform_demo" {
│
│ Could not update API instance: failed to update API instance with status 400:
│ {"name":"RoutingValidationError","errors":[{"instancePath":"/0/upstreams/0","schemaPath":"#/items/properties/upstreams/items/required","keyword":"required","params":{"missingProperty":"id"},"message":"must
│ have required property
│ 'id'"},{"instancePath":"/0/upstreams/0","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"uri"},"message":"must
│ NOT have unevaluated
│ properties"},{"instancePath":"/0/upstreams/0","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"label"},"message":"must
│ NOT have unevaluated
│ properties"},{"instancePath":"/0/upstreams/0","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"tlsContext"},"message":"must
│ NOT have unevaluated
│ properties"},{"instancePath":"/0/upstreams/1","schemaPath":"#/items/properties/upstreams/items/required","keyword":"required","params":{"missingProperty":"id"},"message":"must
│ have required property
│ 'id'"},{"instancePath":"/0/upstreams/1","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"uri"},"message":"must
│ NOT have unevaluated
│ properties"},{"instancePath":"/0/upstreams/1","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"label"},"message":"must
│ NOT have unevaluated properties"}],"message":"The routing configuration is invalid"}
resource "anypoint_api_instance" "weighted_routing" {
environment_id = var.environment_id
gateway_id = var.gateway_id
instance_label = "weighted-routing-demo"
spec = {
asset_id = "my-api"
group_id = var.organization_id
version = "1.0.0"
}
endpoint = {
base_path = "weightedRouting"
}
routing = [
{
label = "canary"
upstreams = [
{
weight = 90
uri = "http://backend-stable.internal:8080"
label = "stable"
},
{
weight = 10
uri = "http://backend-canary.internal:8080"
label = "canary"
}
]
}
]
}
if i run apply after making some changes in upstreams , it would throw error
Terraform will perform the following actions:
anypoint_api_instance.terraform_demo will be updated in-place
~ resource "anypoint_api_instance" "terraform_demo" {
id = "20938007"
~ routing = [
~ {
~ upstreams = [
~ {
~ uri = "http://backend-canary.internal:8080" -> "http://backend-canary.internal:8090"
# (2 unchanged attributes hidden)
},
# (1 unchanged element hidden)
]
# (1 unchanged attribute hidden)
},
]
# (12 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
anypoint_api_instance.terraform_demo: Modifying... [id=20938007]
╷
│ Error: Error updating API instance
│
│ with anypoint_api_instance.terraform_demo,
│ on main.tf line 1, in resource "anypoint_api_instance" "terraform_demo":
│ 1: resource "anypoint_api_instance" "terraform_demo" {
│
│ Could not update API instance: failed to update API instance with status 400:
│ {"name":"RoutingValidationError","errors":[{"instancePath":"/0/upstreams/0","schemaPath":"#/items/properties/upstreams/items/required","keyword":"required","params":{"missingProperty":"id"},"message":"must
│ have required property
│ 'id'"},{"instancePath":"/0/upstreams/0","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"uri"},"message":"must
│ NOT have unevaluated
│ properties"},{"instancePath":"/0/upstreams/0","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"label"},"message":"must
│ NOT have unevaluated
│ properties"},{"instancePath":"/0/upstreams/0","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"tlsContext"},"message":"must
│ NOT have unevaluated
│ properties"},{"instancePath":"/0/upstreams/1","schemaPath":"#/items/properties/upstreams/items/required","keyword":"required","params":{"missingProperty":"id"},"message":"must
│ have required property
│ 'id'"},{"instancePath":"/0/upstreams/1","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"uri"},"message":"must
│ NOT have unevaluated
│ properties"},{"instancePath":"/0/upstreams/1","schemaPath":"#/items/properties/upstreams/items/unevaluatedProperties","keyword":"unevaluatedProperties","params":{"unevaluatedProperty":"label"},"message":"must
│ NOT have unevaluated properties"}],"message":"The routing configuration is invalid"}