bug: workflow_template_revision import does not set template_id, forcing replacement on next plan
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go
- Domain
- devops, infrastructure
Research direction
Start in internal/resource/workflow_template_revision/resource.go, focusing on ImportState and the existing Read behavior. Check the related stack_template_revision and workflow_step_template_revision resources for the same pattern. Done means importing an ID such as my-template-abc123:1 populates template_id without a replacement on the next plan, while malformed IDs produce an error.
Written by the indexing model from the issue text.
Description
Provider version
1.12.1 (the ImportState code on main / 1.12.2-rc4 is identical)
Terraform / OpenTofu version
Terraform v1.14.9 on darwin_arm64
Which API region?
EU
Affected resources or data sources
stackguardian_workflow_template_revision
Terraform configuration
resource "stackguardian_workflow_template" "example" {
id = "my-template-abc123"
template_name = "my-template"
source_config_kind = "TERRAFORM"
is_public = "0"
}
resource "stackguardian_workflow_template_revision" "v1" {
template_id = stackguardian_workflow_template.example.id
source_config_kind = "TERRAFORM"
is_public = "0"
user_job_cpu = 512
user_job_memory = 1024
}
import {
to = stackguardian_workflow_template_revision.v1
id = "my-template-abc123:1"
}
What did you expect to happen?
terraform plan shows the revision being imported with no further changes, since the configuration matches the existing revision.
What actually happened?
The import succeeds, but template_id is left null in state. Because template_id is RequiresReplace, the very next plan wants to destroy the imported revision and recreate it:
# stackguardian_workflow_template_revision.v1 must be replaced
# (imported from "my-template-abc123:1")
# Warning: this will destroy the imported resource
-/+ resource "stackguardian_workflow_template_revision" "v1" {
...
+ template_id = "my-template-abc123" # forces replacement
...
}
Plan: 1 to import, 1 to add, 0 to change, 1 to destroy.
The same happens with terraform import stackguardian_workflow_template_revision.v1 my-template-abc123:1.
Root cause: ImportState in internal/resource/workflow_template_revision/resource.go only sets id:
func (r *workflowTemplateRevisionResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), req.ID)...)
}
and Read copies template_id from prior state (revisionModel.TemplateId = state.TemplateId), so it is never populated from the <template-name>:<revision> ID.
Suggested fix: in ImportState, split req.ID on the last : and set template_id to the prefix (and error if there is no :). The same pattern may affect stackguardian_stack_template_revision and stackguardian_workflow_step_template_revision.
Workaround used: import with the CLI, then terraform state pull, set template_id on the revision instance, bump serial, terraform state push. Since Read preserves the state value, the patch persists.
Before submitting
- I have removed all credentials and org-identifying values from the above.
- Dominant language
- Go
- Stars
- 4
- Forks
- 3
- Avg merge
- 3d 9m
- Merged PRs (30d)
- 12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from StackGuardian/terraform-provider-stackguardian
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 76/100
-
bug: workflow_template_revision create sends driftCron: "" when drift_cron is unset, API returns 400 Openbug
Difficulty 3/5 1-2 days Newbie friendliness 78/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
StackGuardian/terraform-provider-stackguardian#136 · 1 comment ·
-
enhancement
StackGuardian/terraform-provider-stackguardian#124 · 1 assignee ·
-
enhancement
StackGuardian/terraform-provider-stackguardian#123 · 1 assignee ·
All issues in StackGuardian/terraform-provider-stackguardian
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100