Skip to content

Commit

Permalink
Add datadog metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
rotciw committed Sep 2, 2024
1 parent efc4445 commit fa1afa2
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ locals {
DD_LOGS_CONFIG_PROCESSING_RULES = "[{ \"type\" : \"exclude_at_match\", \"name\" : \"exclude_start_and_end_logs\", \"pattern\" : \"(START|END) RequestId\" }]"
DD_PROFILING_ENABLED = "true"
DD_EXTENSION_VERSION = "next"
DD_SERVICE = var.name
DD_SERVICE = var.dd_service_name
DD_ENV = module.account_metadata.account.environment
DD_VERSION = var.artifact.version
DD_API_KEY_SECRET_ARN = data.aws_secretsmanager_secret.datadog_api_key.arn
Expand All @@ -85,6 +85,13 @@ locals {
}
}

module "datadog_metadata" {
source = "./modules/datadog_metadata"

team = "Utviklerplattform"
service_name = var.dd_service_name
}

module "account_metadata" {
source = "github.com/nsbno/terraform-aws-account-metadata?ref=0.1.2"
}
Expand Down
26 changes: 26 additions & 0 deletions modules/datadog_metadata/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
locals {
service_definition = {
schema-version = "v2.2"
team = var.team
dd-service = var.service_name
description = var.description
# contacts = [
# {
# name = "Support Email"
# type = "email"
# contact = var.support_email
# },
# ]
# tier = var.tier
# application = var.application
# languages = var.languages
# type = var.type
# links = var.links
# tags = var.tags
}
}

// Service Definition with v2.2 Schema Definition
resource "datadog_service_definition_yaml" "service_definition_v2_2" {
service_definition = yamlencode(local.service_definition)
}
10 changes: 10 additions & 0 deletions modules/datadog_metadata/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.3.0"

required_providers {
datadog = {
source = "DataDog/datadog"
version = ">= 3.40.0"
}
}
}
15 changes: 15 additions & 0 deletions modules/datadog_metadata/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "team" {
description = "The team responsible for the service"
type = string
}

variable "service_name" {
description = "The name of the service"
type = string
}

variable "description" {
description = "A description of the service"
type = string
default = ""
}
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ variable "name" {
type = string
}

variable "dd_service_name" {
description = "The name of the service. A group of function names can be part of the same service"

default = ""
type = string
}

variable "artifact_type" {
description = "The type of artifact to deploy"

Expand Down
4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ terraform {
source = "hashicorp/aws"
version = ">= 5.26.0"
}
datadog = {
source = "DataDog/datadog"
version = ">= 3.40.0"
}
}
}

0 comments on commit fa1afa2

Please sign in to comment.