Deal with Optional Field which orders the resources

I have a Firewall Rule Resource. Every Rule has a Priority. However the Attrubite can be Optional and Computed. The User can specify the Priority if they wish, if not the API will give the rule a Priority (the nth + 1 Priority). However, if I create a Firewall Rule with an existing Priority (e.g there is a conflict) as there exists a Firewall Rule with Priority of 1 and Terraform creates a Rule with the Priority of 1. The framework will panic. What would be the best way to handle this problem?

type FirewallRuleModel struct {
    ID          types.String            `tfsdk:"id"`
    Description types.String            `tfsdk:"description"`
    Type        types.String            `tfsdk:"type"`
    Conditions  []CustomConditionModel  `tfsdk:"condition"`
    Priority    types.Int64             `tfsdk:"priority"`
"priority": schema.Int64Attribute{
    Optional:    true, // Optional and Computed can both be true
    Computed:    true,
    Description: "The priority of the Firewall Rule.",
    Validators: []validator.Int64{
        int64validator.Between(1, 1000),

Hi @kderck,

Sorry that you are running into trouble here. If I understand the problem correctly, are you looking to prevent users from being able to create a firewall rule with an existing priority (ie throw an error if there is a config with an existing priority)? Or are you trying to have the provider allow the conflicting firewall rule and automatically resolve the conflict?

Also can you provide the error/panic that you are seeing from the Framework? Just to make sure that what you’re seeing is not a bug on our side.

Hi @SBGoods. I will follow up.