Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal server conflict error when using Service Accounts #108

Closed
volodymyrZotov opened this issue Nov 28, 2023 · 0 comments · Fixed by #118
Closed

Internal server conflict error when using Service Accounts #108

volodymyrZotov opened this issue Nov 28, 2023 · 0 comments · Fixed by #118
Assignees
Labels
bug Something isn't working

Comments

@volodymyrZotov
Copy link
Collaborator

Your environment

Terraform Provider Version: 1.2.2

Connect Server Version: n/a

OP CLI Version: 2.23.0

OS: macOS 14.1.1

Terraform Version: 1.6.4

What happened?

When using provider with Service Accounts users may encounter the following error op error: (409) Conflict: Internal server conflict when create/update/delete a bunch of items in the same vault as Terraform Provider handles each resource separately and therefore it makes a bunch of parallel requests using CLI for each of the resources.

What did you expect to happen?

No errors occurred.

Steps to reproduce

  1. Create Service Account token with write permissions.
  2. Create main.tf with the following content (see Notes section below)
  3. terraform init
  4. terraform apply
  5. Some items won't be created and you should see op error: (409) Conflict: Internal server conflict in the console.

Notes & Logs

main.tf example

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

provider "onepassword" {
  service_account_token = "your_service_account_token"
}

resource "onepassword_item" "demo_password" {
  vault = "vault_id"

  title    = "Demo Password Recipe"
  category = "password"

  password_recipe {
    length  = 40
    symbols = false
  }

  section {
    label = "API Creds"

    field {
      label = "PORT"
      type  = "CONCEALED"
      value = "8080"
    }

    field {
      label = "HOSTNAME"
      value = "example.com"
    }
  }
}

resource "onepassword_item" "demo_login" {
  vault = "vault_id"

  title    = "Demo Terraform Login changed"
  category = "login"
  username = "test@example.com"
}

resource "onepassword_item" "demo_sections" {
  vault = "vault_id"

  title    = "Demo Terraform Item with Sections"
  category = "login"
  username = "test_changed@example.com"


  section {
    label = "Terraform Section"

    field {
      label = "API_KEY"
      type  = "CONCEALED"
      value = "2Federate2!"
    }

    field {
      label = "HOSTNAME"
      value = "example.com"
    }
  }

  section {
    label = "Terraform Second Section"

    field {
      label = "App Specific Password"
      type  = "CONCEALED"

      password_recipe {
        length  = 30
        symbols = false
      }
    }

    field {
      label = "User"
      value = "dchanged emo"
    }
  }
}

resource "onepassword_item" "another_password" {
  vault = "vault_id"

  title    = "Another Demo Password Recipe"
  category = "password"

  password_recipe {
    length  = 40
    symbols = false
  }
}

resource "onepassword_item" "another_demo_login" {
  vault = "vault_id"

  title    = "Another Demo Terraform Login changed"
  category = "login"
  username = "test@example.com"
}

resource "onepassword_item" "another_demo_sections" {
  vault = "vault_id"

  title    = "Another Demo Terraform Item with Sections"
  category = "login"
  username = "test_changed@example.com"


  section {
    label = "Terraform Section"

    field {
      label = "API_KEY"
      type  = "CONCEALED"
      value = "2Federate2!"
    }

    field {
      label = "HOSTNAME"
      value = "example.com"
    }
  }

  section {
    label = "Another Terraform Second Section"

    field {
      label = "App Specific Password"
      type  = "CONCEALED"

      password_recipe {
        length  = 30
        symbols = false
      }
    }

    field {
      label = "User"
      value = "dchanged emo"
    }
  }
}

Possible solution:

The issue might be solved by adding a retry mechanism when getting 409 error from the server using op-cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant