Skip to content

[Feature]: Access credentials by name rather than ID #60

@adamrtalbot

Description

@adamrtalbot

Feature Type

New Resource

Seqera API Endpoint

GET /credentials

Feature Description

There is no way to access the credentials by name rather than ID. The interface of Seqera Platform does not show this ID so it is very difficult to find the ID unless you do it programmatically. This makes it very hard to make a compute environment using existing credentials.

We should be able to get the /credentials resource then filter by name somehow. We could do this as a credentials (multiple) data source or by some underlying logic to allow ID or name when fetching the credential (singular) resource.

Use Case

Below is an example for using the mastercard restapi provider:

terraform {
  required_version = ">= 1.0"

  required_providers {
    restapi = {
      source  = "Mastercard/restapi"
      version = "~> 1.18"
    }
  }
}

# REST API provider for credential lookup
provider "restapi" {
  uri      = trimsuffix(var.seqera_api_endpoint, "/")
  headers = {
    "Authorization" = var.seqera_access_token == null ? "" : "Bearer ${var.seqera_access_token}"
    "Content-Type"  = "application/json"
    "Accept"        = "application/json"
  }
  write_returns_object  = true
  create_returns_object = true
}

# Get credentials by name using REST API
data "restapi_object" "credentials" {
  path         = "/credentials"
  search_key   = "name"
  search_value = var.seqera_credentials_name
  query_string = "workspaceId=${var.seqera_workspace_id}"
  results_key  = "credentials"
}

locals {
  # Extract credential ID from REST API response
  credentials_id = jsondecode(data.restapi_object.credentials[0].api_response).credentials.id
}

Proposed Terraform Configuration

# Fetch all credentials as a list
resource "seqera_credentials" "workspace_credentials" {
    workspace_id = var.seqera_workspace_id
    platform_id  = (optional) var.platform_type (aws, azure, etc)
}

# Fetch specific credential by name
data "seqera_credential" "credentials" {
  credentials_name = var.seqera_credentials_name
  workspace_id     = var.seqera_workspace_id
}

Alternatives Considered

  • The restapi implementation above is currently the only way I can see to mimic this behaviour.
  • Alternatively, managing 100% of your resources in Terraform will solve this issue (i.e., creating your credentials in the same Terraform).

Priority

Medium - Would improve workflow

Additional Context

This is more important for 'brownfield' sites, i.e. with existing resources in a workspace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions