Skip to content

OpsLevel/terraform-provider-opslevel

Repository files navigation

Overall

Terraform Provider for OpsLevel

Minimum requirements

  • Terraform 1.7.0 or newer. We recommend running the latest version for optimal compatibility with the OpsLevel provider.

Migrating to v1.0.0

Notes on migrating to v1.0.0 and fixes to migration issues can be found in [./MIGRATION.md].

Provider Documentation Quickstart Importing All Existing Account Data

Example

provider "opslevel" {
  api_token = "XXX" // or environment variable OPSLEVEL_API_TOKEN
}

resource "opslevel_team" "foo" {
  name = "foo"
  responsibilities = "Responsible for foo frontend and backend"

  member {
    email = "[email protected]"
    role = "manager"
  }
  member {
    email = "[email protected]"
    role = "contributor"
  }
}

resource "opslevel_service" "foo-frontend" {
  name = "foo-frontend"

  description = "The foo frontend service"
  framework   = "rails"
  language    = "ruby"

  lifecycle_alias = "beta"
  tier_alias = "tier_3"
  owner = opslevel_team.foo.alias

  tags = [
    "environment:production",
  ]
}

data "opslevel_rubric_category" "security" {
  filter {
    field = "name"
    value = "Security"
  }
}

data "opslevel_rubric_level" "bronze" {
  filter {
    field = "name"
    value = "Bronze"
  }
}

resource "opslevel_filter" "filter" {
  name = "foo"
  predicate {
    key = "tier_index"
    type = "equals"
    value = "tier_3"
  }
  connective = "and"
}

resource "opslevel_check_repository_integrated" "foo" {
  name = "foo"
  enabled = true
  category = data.opslevel_rubric_category.security.id
  level = data.opslevel_rubric_level.bronze.id
  owner = opslevel_team.foo.id
  filter = opslevel_filter.filter.id
  notes = "Optional additional info on why this check is run or how to fix it"
}

Useful Terraform Snippets

Get a service's tag keys

output "service_tag_keys" {
    value = values({for entry in opslevel_service.example.tags : entry => split(":", entry)[0]})
}

Get a service's tag values

output "service_tag_values" {
    value = values({for entry in opslevel_service.example.tags : entry => split(":", entry)[1]})
}