Closed
Description
Terraform CLI and Framework Versions
$ terraform version
Terraform v1.10.0
$ go list -m github.com/hashicorp/terraform-plugin-framework
github.com/hashicorp/terraform-plugin-framework v1.13.0
Terraform Plugin Framework Code
"image": schema.StringAttribute{
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Validators: []validator.String{
stringvalidator.ConflictsWith(
path.Expressions{
path.MatchRoot("source_instance"),
}...
),
stringvalidator.AtLeastOneOf(
path.Expressions{
path.MatchRoot("image"),
path.MatchRoot("source_instance"),
}...
),
},
},
"source_instance": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"project": schema.StringAttribute{
Required: true,
},
"name": schema.StringAttribute{
Required: true,
},
"snapshot": schema.StringAttribute{
Optional: true,
},
},
PlanModifiers: []planmodifier.Object{
objectplanmodifier.RequiresReplace(),
},
Validators: []validator.Object{
objectvalidator.ConflictsWith(
path.Expressions{
path.MatchRoot("image"),
}...),
objectvalidator.AtLeastOneOf(
path.Expressions{
path.MatchRoot("image"),
path.MatchRoot("source_instance"),
}...
),
},
},
Terraform Configuration
variable "source_instance"{
default = null
}
resource "my_resource"{
image = "my_image"
source_instance = var.source_instance
}
Expected Behavior
terraform validate
should run with no errors for the configuration above. Since var.source_instance
is Unkown.
Actual Behavior
terraform validate
fails with
Error: Invalid Attribute Combination
with incus_instance.instance1,
on main.tf line 33, in resource "incus_instance" "instance1":
33: source_instance = var.source_instance
Attribute "image" cannot be specified when "source_instance" is specified
Steps to Reproduce
- Create a resource with attribute that is using ConflictsWith
- Define one of the conflicting attribute and pass the other one from a variable (Unknown)
terraform validate
Logs
No response
Additional Information
No response
Code of Conduct
- I agree to follow this project's Code of Conduct