on 2025 Jan 27 4:21 PM
Hi all,
I'm working to migrate my existing entries for APIRule v1beta1 to v2alpha1, and I've hit upon something that I think might be an issue with the default manifest coming from Terraform.
Below is my original version of the v1beta1 rule in our Terraform (since it's just a manifest it should map to the YAML directly):
resource "kubernetes_manifest" "api_gateway_seq" {
depends_on = [
kubernetes_namespace_v1.o11y, data.kubernetes_service_v1.grafana_service, kubernetes_namespace_v1.dns_management,
kubernetes_manifest.istio_gateway
]
for_each = local.gateways
manifest = {
apiVersion = "gateway.kyma-project.io/v1beta1"
kind = "APIRule"
metadata = {
name = "seq-apigateway-https-${each.value.suffix}"
namespace = kubernetes_namespace_v1.o11y.metadata[0].name
}
spec = {
gateway = each.value.gateway
host = "seq.${each.value.host}"
service = {
name = data.kubernetes_service_v1.seq.metadata[0].name
port = 80
}
rules = [{
path = "/.*"
methods = ["GET", "POST", "PUT", "DELETE"]
accessStrategies = [{
handler = "allow"
config = {}
}]
}]
}
}
}And below are the modifications I've made to support v2alpha1 --
resource "kubernetes_manifest" "api_gateway_seq" {
depends_on = [
kubernetes_namespace_v1.o11y, data.kubernetes_service_v1.grafana_service, kubernetes_namespace_v1.dns_management,
kubernetes_manifest.istio_gateway
]
for_each = local.gateways # we have multiple gateways
manifest = {
apiVersion = "gateway.kyma-project.io/v2alpha1"
kind = "APIRule"
metadata = {
name = "seq-apigateway-https-${each.value.suffix}"
namespace = kubernetes_namespace_v1.o11y.metadata[0].name
}
spec = {
gateway = each.value.gateway
hosts = ["seq.${each.value.host}"]
service = {
name = data.kubernetes_service_v1.seq.metadata[0].name
namespace = data.kubernetes_service_v1.seq.metadata[0].namespace
port = 80
}
rules = [{
path = "/.*"
methods = ["GET", "POST", "PUT", "DELETE"]
noAuth = true
}]
}
}
}However, when I attempt to apply the Terraform, I see:
> AttributeName("maxAge"): can't use tftypes.String as tftypes.Number
I can't find any reference to maxAge in any default YAML files I've seen, but it does seem like it factors into corsPolicy.
Is there an appropriate default I should be moving to here? Or is this an issue with the standard resource definition?
Request clarification before answering.
Ultimately, this seemed to be an edge case caused by the fact that we hadn't yet defined a CORS policy for this APIRule in the v1 structure.
What was ultimately successful for us to move to a v2alpha1 rule in our setup was:
We could choose to add a corsPolicy object in our v1 resources or as part of v2. I extracted a default policy and applied that in our Terraform while moving to v2alpha1.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.