Description
Your environment
Terraform Provider Version: 2.1.2
OS: macOS Sonoma
Terraform Version: 1.5.7
What happened?
The current implementation of the provider does not handle manually item property changes very well. Mainly for username
and url
the behaviour is strange in various ways. Example:
resource "onepassword_item" "test" {
vault = data.onepassword_vault.acceptance-tests.uuid
title = "TestItemResourceIntegrationUsername-D2AbjK"
category = "login"
username = null
password_recipe {}
url = null
}
- Setting
username
andurl
tonull
will not touch the item property in 1Password. Thats desired behaviour. - Setting
username
andurl
to a valid String e.g."xxx"
will overwrite underlaying values. Thats also expected. - Setting
username
andurl
to""
will result inWhen applying changes to onepassword_item.test, provider produced an unexpected new value: .username: was cty.StringVal(""), but now null
error message. See below. - Setting
username
andurl
tonull
after manually changed those properties beforehand will result in overwriting the value in 1Password. This is not expected (see below).
What did you expect to happen?
The following behaviour would be expected based on the scenarios 3 and 4 from above:
username
andurl
=""
: this should "reset" the property in 1Password i.e. the value of this property should be unset after apply.username
andurl
=null
or not set in resource: should leave the value for the item in 1Password untouched i.e. ignored by Terraform.
Steps to reproduce
Imagine the following test scenario:
- create an item leaving
username
andurl
unset inonepassword_item
- manually set those item properties
- reapply the resource -> no changes should be planed
- set the item properties in Terraform e.g.
username = "test"
and reapply -> properties should be set by Terraform - unset the item properties in Terraform e.g.
username = ""
and reapply -> properties should be empty (unset i.e. without value) again
Notes & Logs
We use the provider to create items that are populated with values derived directly from Terraform resources as well as placeholder items with predefined properties that are not set and needs to stay untouched by Terraform. The 1.4 version of the provider was able to handle those scenarios however it disappear with version 2.
Sadly the unit tests implemented are not very flexible and it seems to me that some integration tests will be needed to make sure the behaviour is like described above. Do you have any integration tests available or planned? I'm happy to share mine ;).