1Password / terraform-provider-onepassword

Use the 1Password Terraform Provider to reference, create, or update items in your 1Password Vaults.
https://developer.1password.com/docs/terraform/
MIT License
324 stars 48 forks source link

Changing `field` s of a `section` gives unexpected results (re-labeling of existing fields and thus data moved) #77

Open daniel-ciaglia opened 1 year ago

daniel-ciaglia commented 1 year ago

Your environment

Terraform Provider Version: 1.1.4 (latest) Connect Server Version: 1.5.7 OS: MacOS 13.3 on M1 Terraform Version: 1.4.4

What happened?

What did you expect to happen?

Steps to reproduce

  1. see above, source code attached below, authentication is stored in AWS Secrets manager for Connect authentication
  2. I tried to give an id to the field, but this id was happily changed as well

Source code

terraform {
  required_version = ">= 1.4.0"

  required_providers {
    onepassword = {
      source  = "1Password/onepassword"
      version = "~> 1.1.4"
    }
  }
}

# ########################## 1Password config ############################
# the configuration for connecting to 1password Agent

data "aws_secretsmanager_secret" "onepassword_token" {
  name = "onepassword-token"
}
data "aws_secretsmanager_secret_version" "onepassword_token" {
  secret_id = data.aws_secretsmanager_secret.onepassword_token.id
}

provider "onepassword" {
  url   = "http://localhost:8080"
  token = data.aws_secretsmanager_secret_version.onepassword_token.secret_string
}

locals {
  one_password_vault = "your-vault-goes-here"
}

data "onepassword_vault" "this" {
  name = local.one_password_vault
}

# plain resources
resource "onepassword_item" "plain" {
  vault = data.onepassword_vault.this.uuid

  title    = "plain"
  category = "password"

  section {
    label = "collector"
     field {
      label = "a_password"
      type  = "CONCEALED"
    }
    field {
      label = "b_password"
      type  = "CONCEALED"
    }
    # initially commented out
    # field {
    #   label = "c_password"
    #   type  = "CONCEALED"
    # }
    field {
      label = "z_password"
      type  = "CONCEALED"
    }
  }
}