labd / terraform-provider-commercetools

Terraform provider for commercetools
https://registry.terraform.io/providers/labd/commercetools/latest/docs
Mozilla Public License 2.0
64 stars 68 forks source link

Tax Category Rate Resource without State #459

Closed NicholasTing closed 8 months ago

NicholasTing commented 8 months ago

Hi there labd team,

Issue with this resource -> Tax Category Rate

Whenever I create a tax_category_rate without state defined, it will throw an error whenever I re-apply stating this error Error: A duplicate value '{"country":"AU","state":""}' exists for field 'country'.


resource "commercetools_tax_category" "taxable_goods" {
  key         = "taxable-goods"
  name        = "Taxable Goods"
  description = "Assigned to products where tax is required."
}

resource "commercetools_tax_category_rate" "taxable_goods_rates" {

  tax_category_id   = commercetools_tax_category.taxable_goods.id
  name              = "test-gst"
  amount            = 0.10
  included_in_price = true
  country           = "AU"
}
NicholasTing commented 8 months ago

Notes: If the only tax category rate present is the one without a state, it will not recognise it and will try to recreate the resource.

NicholasTing commented 8 months ago

This seemed to do the trick for me - explicitly defining state as null

resource "commercetools_tax_category" "taxable_goods" {
  key         = "taxable-goods"
  name        = "Taxable Goods"
  description = "Assigned to products where tax is required."
}

resource "commercetools_tax_category_rate" "taxable_goods_rates" {

  tax_category_id   = commercetools_tax_category.taxable_goods.id
  name              = "test-gst"
  amount            = 0.10
  included_in_price = true
  country           = "AU"
  state             = null
}