terraform-provider-commercetools icon indicating copy to clipboard operation
terraform-provider-commercetools copied to clipboard

while applying terraform for update getting error

Open SatishAlghanim opened this issue 1 year ago • 1 comments

Hi Team,

we are using labd for configuring the commercetools schema we added root category like this by terraform scripts

resource "commercetools_category" "category_root_ksa" { key = "category-root-ksa" name = { en-KW = "KSA Root Category" en-SA = "KSA Root Category" } slug = { en-KW = "root-ksa" en-SA = "root-ksa" } }

resource "commercetools_category" "category_root_kw" { key = "category-root-kw" name = { en-KW = "Kuwait Root Category" en-SA = "Kuwait Root Category" } slug = { en-KW = "root-kw" ar-SA = "root-kw" } }

if we want to apply terraform getting this error Error: A duplicate value '"category-root-kw"' exists for field 'key'. │ │ with commercetools_category.category_root_kw, │ on main.tf line 13, in resource "commercetools_category" "category_root_kw": │ 13: resource "commercetools_category" "category_root_kw" { │ ╵ ╷ │ Error: A duplicate value '"category-invisible"' exists for field 'key'. │ │ with commercetools_category.category_invisible, │ on main.tf line 26, in resource "commercetools_category" "category_invisible": │ 26: resource "commercetools_category" "category_invisible" {

as per commercetools key should be unique. But we are not changing any thing for these categories but labd terrform trying to create these categories again(seems it is not correct).

Can you please help on this issue.

Thanks and Regards, satish

SatishAlghanim avatar Jan 09 '24 12:01 SatishAlghanim

Hi @SatishAlghanim

I do not seem to be able to reproduce this issue. It feels like something is not being handled correctly with the state. It looks like terraform does not know the categories were already added. Are you working with the same state configuration on both runs?

demeyerthom avatar Jan 19 '24 10:01 demeyerthom