sl1pm4t / k2tf

Kubernetes YAML to Terraform HCL converter
Mozilla Public License 2.0
1.17k stars 108 forks source link

Fix ClusterRole aggregation_rule.cluster_role_selector] not found #86

Closed sl1pm4t closed 2 years ago

sl1pm4t commented 2 years ago

Fixes error:

3:43PM Warn | excluding attribute [kubernetes_cluster_role.aggregation_rule.cluster_role_selector] not found in Terraform schema  field=ClusterRole.AggregationRule.ClusterRoleSelectors name=monitoring type=kubernetes_cluster_role
resource "kubernetes_cluster_role" "monitoring" {
  metadata {
    name = "monitoring"
  }

  aggregation_rule {}
}

based on input YAML:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: monitoring
aggregationRule:
  clusterRoleSelectors:
    - matchLabels:
        rbac.example.com/aggregate-to-monitoring: "true"
rules: [] # The control plane automatically fills in the rules

After this fix, outputs as:

resource "kubernetes_cluster_role" "monitoring" {
  metadata {
    name = "monitoring"
  }
  aggregation_rule {
    cluster_role_selectors {
      match_labels = { "rbac.example.com/aggregate-to-monitoring" = "true" }
    }
  }
}

Closes #81