Skip to main content

OpenTofu/Terraform code and asset repository setup

Overview

After creating your account, the next step is configuring your providers for both code repositories (GitHub, GitLab, or Azure DevOps) and asset repositories (Docker Registry, ECR, etc.). This guide shows you how to set up both providers using OpenTofu/Terraform (remember to replace data with your actual real values).

OpenTofu/Terraform Configuration

Below is the complete configuration for setting up both your code repository provider and asset repository provider. Save this in a .tf file:

terraform {
required_providers {
nullplatform = {
source = "nullplatform/nullplatform"
}
}
}

provider "nullplatform" {
api_key = "my-secret-api-key"
}

# GitLab Provider Configuration
resource "nullplatform_provider_config" "gitlab-configuration" {
account = "your-account-slug" # Replace with your account slug
type = "gitlab-configuration"
dimensions = {
environment = "example-environment"
}
attributes = jsonencode({
"setup": {
"installation_url": "https://gitlab.com",
"access_token": "glpat-XXXXXXXXXXXXXXXXXXXXX",
"group_path": "my-organization/my-group",
"topics": [
"web",
"api",
"backend"
]
},
"access": {
"default_collaborators": [
{
"type": "user",
"id": "np-pilundain",
"role": "developer"
},
{
"type": "group",
"id": "wallet",
"role": "developer"
}
]
}
})
}

# Docker Registry Configuration
resource "nullplatform_provider_config" "docker-server" {
account = "your-account-slug" # Replace with your account slug
type = "docker-server"
dimensions = {
environment = "example-environment"
}
attributes = jsonencode({
"setup": {
"server": "registry.hub.docker",
"username": "example-string",
"password": "example-string",
"path": "myorg/team-a",
},
})
}

Applying the Configuration

  1. Initialize Terraform:
terraform init
  1. Review the changes:
terraform plan
  1. Apply the configuration:
terraform apply

Verification

After applying the configuration, verify that:

  1. Your code repository provider is properly configured in Platform Settings > Code Repository
  2. Your asset repository provider is set up in Platform Settings > Asset Repository