Closed CameronHudson8 closed 10 months ago
Unfortunately, while it is possible to terraform apply
the TriggerTemplate after changing the capitalization, Terraform subsequently emits an error, and the resource is tainted. So there isn't a clean workaround at the moment.
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ module.tekton_pipelines.module.trigger_templates.kubernetes_manifest.trigger_template_github_image_pr,
│ provider "provider[\"registry.terraform.io/hashicorp/kubernetes\"]"
│ produced an unexpected new value: .object: wrong final value type:
│ attribute "spec": attribute "resourceTemplates" is required.
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵
Performing terraform plan
after this shows a persistent diff in the state.
# module.tekton_pipelines.module.trigger_templates.kubernetes_manifest.trigger_template_github_image_pr is tainted, so must be replaced
-/+ resource "kubernetes_manifest" "trigger_template_github_image_pr" {
~ object = {
~ spec = {
+ resourceTemplates = [
+ {
+ apiVersion = "tekton.dev/v1"
+ kind = "PipelineRun"
+ metadata = {
+ generateName = "github-image-pr-"
}
+ spec = {
+ params = [
+ {
+ name = "github-status-url"
+ value = "$(tt.params.github-status-url)"
},
+ {
+ name = "pr-number"
+ value = "$(tt.params.pr-number)"
},
+ {
+ name = "repo-name"
+ value = "$(tt.params.repo-name)"
},
+ {
+ name = "repo-url"
+ value = "$(tt.params.repo-url)"
},
]
+ pipelineRef = {
+ name = "github-image-pr"
}
+ taskRunTemplate = {
+ serviceAccountName = "cicd-bot"
}
+ workspaces = [
+ {
+ name = "default"
+ volumeClaimTemplate = {
+ spec = {
+ accessModes = [
+ "ReadWriteOnce",
]
+ resources = {
+ requests = {
+ storage = "512Mi"
}
}
}
}
},
]
}
},
]
- resourcetemplates = [
- {
- apiVersion = "tekton.dev/v1"
- kind = "PipelineRun"
- metadata = {
- generateName = "github-image-pr-"
}
- spec = {
- params = [
- {
- name = "github-status-url"
- value = "$(tt.params.github-status-url)"
},
- {
- name = "pr-number"
- value = "$(tt.params.pr-number)"
},
- {
- name = "repo-name"
- value = "$(tt.params.repo-name)"
},
- {
- name = "repo-url"
- value = "$(tt.params.repo-url)"
},
]
- pipelineRef = {
- name = "github-image-pr"
}
- taskRunTemplate = {
- serviceAccountName = "cicd-bot"
}
- workspaces = [
- {
- name = "default"
- volumeClaimTemplate = {
- spec = {
- accessModes = [
- "ReadWriteOnce",
]
- resources = {
- requests = {
- storage = "512Mi"
}
}
}
}
},
]
}
},
]
# (1 unchanged attribute hidden)
}
# (3 unchanged attributes hidden)
}
# (1 unchanged attribute hidden)
}
Hi @CameronHudson8 :wave:
I followed the steps which you have provided but i did not see any issue
terraform apply
$ terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# kubernetes_manifest.trigger_template_github_image_pr will be created
+ resource "kubernetes_manifest" "trigger_template_github_image_pr" {
+ manifest = {
+ apiVersion = "triggers.tekton.dev/v1beta1"
+ kind = "TriggerTemplate"
+ metadata = {
+ name = "github-image-pr"
+ namespace = "tekton-pipelines"
}
+ spec = {
+ params = [
+ {
+ name = "github-status-url"
},
+ {
+ name = "pr-number"
},
+ {
+ name = "repo-name"
},
+ {
+ name = "repo-url"
},
]
+ resourcetemplates = [
+ {
+ apiVersion = "tekton.dev/v1"
+ kind = "PipelineRun"
+ metadata = {
+ generateName = "github-image-pr-"
}
+ spec = {
+ params = [
+ {
+ name = "github-status-url"
+ value = "$(tt.params.github-status-url)"
},
+ {
+ name = "pr-number"
+ value = "$(tt.params.pr-number)"
},
+ {
+ name = "repo-name"
+ value = "$(tt.params.repo-name)"
},
+ {
+ name = "repo-url"
+ value = "$(tt.params.repo-url)"
},
]
+ pipelineRef = {
+ name = "github-image-pr"
}
+ taskRunTemplate = {
+ serviceAccountName = "tekton-triggers-example-sa"
}
+ workspaces = [
+ {
+ name = "default"
+ volumeClaimTemplate = {
+ spec = {
+ accessModes = [
+ "ReadWriteOnce",
]
+ resources = {
+ requests = {
+ storage = "512Mi"
}
}
}
}
},
]
}
},
]
}
}
+ object = {
+ apiVersion = "triggers.tekton.dev/v1beta1"
+ kind = "TriggerTemplate"
+ metadata = {
+ name = "github-image-pr"
+ namespace = "tekton-pipelines"
}
+ spec = {
+ params = [
+ {
+ name = "github-status-url"
},
+ {
+ name = "pr-number"
},
+ {
+ name = "repo-name"
},
+ {
+ name = "repo-url"
},
]
+ resourcetemplates = [
+ {
+ apiVersion = "tekton.dev/v1"
+ kind = "PipelineRun"
+ metadata = {
+ generateName = "github-image-pr-"
}
+ spec = {
+ params = [
+ {
+ name = "github-status-url"
+ value = "$(tt.params.github-status-url)"
},
+ {
+ name = "pr-number"
+ value = "$(tt.params.pr-number)"
},
+ {
+ name = "repo-name"
+ value = "$(tt.params.repo-name)"
},
+ {
+ name = "repo-url"
+ value = "$(tt.params.repo-url)"
},
]
+ pipelineRef = {
+ name = "github-image-pr"
}
+ taskRunTemplate = {
+ serviceAccountName = "tekton-triggers-example-sa"
}
+ workspaces = [
+ {
+ name = "default"
+ volumeClaimTemplate = {
+ spec = {
+ accessModes = [
+ "ReadWriteOnce",
]
+ resources = {
+ requests = {
+ storage = "512Mi"
}
}
}
}
},
]
}
},
]
}
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Warning: This custom resource does not have an associated OpenAPI schema.
│
│ with kubernetes_manifest.trigger_template_github_image_pr,
│ on main.tf line 1, in resource "kubernetes_manifest" "trigger_template_github_image_pr":
│ 1: resource "kubernetes_manifest" "trigger_template_github_image_pr" {
│
│ We could not find an OpenAPI schema for this custom resource. Updates to this resource will cause a forced replacement.
╵
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
kubernetes_manifest.trigger_template_github_image_pr: Creating...
kubernetes_manifest.trigger_template_github_image_pr: Creation complete after 0s
╷
│ Warning: This custom resource does not have an associated OpenAPI schema.
│
│ with kubernetes_manifest.trigger_template_github_image_pr,
│ on main.tf line 1, in resource "kubernetes_manifest" "trigger_template_github_image_pr":
│ 1: resource "kubernetes_manifest" "trigger_template_github_image_pr" {
│
│ We could not find an OpenAPI schema for this custom resource. Updates to this resource will cause a forced replacement.
╵
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
`TriggerTemplate created successfully
$ kubectl get tt -n tekton-pipelines
NAME AGE
github-image-pr 7s
Kubectl version
$ kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.6", GitCommit:"11902a838028edef305dfe2f96be929bc4d114d8", GitTreeState:"archive", BuildDate:"2023-06-15T00:00:00Z", GoVersion:"go1.20.4", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.3", GitCommit:"9e644106593f3f4aa98f8a84b23db5fa378900bd", GitTreeState:"clean", BuildDate:"2023-03-15T13:33:12Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
Terraform version
$ terraform version
Terraform v1.5.7
on linux_amd64
+ provider registry.terraform.io/hashicorp/kubernetes v2.17.0
Let me know if i misunderstand your question
I started from scratch, this time with a cluster of kubernetes version 1.27, and I'm no longer able to reproduce it. Weird, but works for me!
Expected Behavior
It should be possible to create a TriggerTemplate using the Terraform
kubernetes_manifest
resource, based on the examples from the Tekton documentation.Actual Behavior
Creation fails due to a capitalization conflict in the field
.spec.resourcetemplates
.Steps to Reproduce the Problem
hashicorp/kubernetes
provider version2.23.0
.kubernetes_manifest
for the TriggerTemplate, and specify the field.spec.resourcetemplates
(example below).terraform plan
orterraform apply
and encounter an error (example below)..spec.resourcetemplates
to.spec.resourceTemplates
.terraform plan
andterraform apply
successfully.Additional Info
Kubernetes version:
Output of
kubectl version
:Tekton Pipeline version:
Output of
tkn version
orkubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'
Terraform code
Logs:
PS: Thank you for creating and maintaining Tekton. It rocks! 🙂