Skip to content

sentry_organization_repository data source #581

Open
@jonny-puma

Description

@jonny-puma

I'm on version 0.14.3 of jianyuan/sentry runinng on opentofu version 1.9.0.

Hi,
I'm creating a new sentry project with terraform and want to create a code mapping for the project using an existing sentry github repo integration:

data "sentry_organization_integration" "github" {
  organization = sentry_project.default.organization
  provider_key = "github"
  name         = "<my_github>"
}

resource  "sentry_organization_repository" "github" {
  organization     = sentry_project.default.organization
  integration_type = "github"
  integration_id   = data.sentry_organization_integration.github.id
  identifier       = "<my_github>/<repo>"
}

resource "sentry_organization_code_mapping" "default" {
  organization   = data.sentry_organization.default.id
  integration_id = data.sentry_organization_integration.github.id
  repository_id  = sentry_organization_repository.github.id
  project_id     = sentry_project.default.id
}

Because the integration already exists i get the following error:

│ Error: Client error
│ 
│   with sentry_organization_repository.github,
│   on sentry.tf line 58, in resource "sentry_organization_repository" "github":
│   58: resource "sentry_organization_repository" "github" {
│ 
│ Unable to create, got error: POST
│ https://sentry.io/api/0/organizations/<sentry_project>/repos/: 400
│ map[detail:map[code:repo_exists extra:map[] message:A repository with that
│ configuration already exists]]
╵
Error: Process completed with exit code 1.

I believe this can be fixed by adding a data source for sentry_organization_repository so I could fetch the existing repository and reference it in sentry_organization_code_mapping.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions