From 5398d8f78ffb175176d6143ca8c295988076a2c2 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Wed, 11 Jan 2023 19:53:59 -0800 Subject: infra: add datadog api key --- jinwei.me/config/roles/debian_init/tasks/main.yaml | 4 ++++ jinwei.me/infra/dockerhub.tf | 6 ++++++ jinwei.me/infra/variables.tf | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/jinwei.me/config/roles/debian_init/tasks/main.yaml b/jinwei.me/config/roles/debian_init/tasks/main.yaml index 750f83c..539c43f 100644 --- a/jinwei.me/config/roles/debian_init/tasks/main.yaml +++ b/jinwei.me/config/roles/debian_init/tasks/main.yaml @@ -92,3 +92,7 @@ src: "//{{ lookup('aws_ssm', '/jinwei-me/hetzner/storagebox') }}" path: "{{ samba_mount_point }}" become: true + +- name: Install Datadog + command: + DD_API_KEY={{ lookup('aws_secretsmanager_secret', '/jinwei-me/datadog/api_key') }} DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)" diff --git a/jinwei.me/infra/dockerhub.tf b/jinwei.me/infra/dockerhub.tf index 00a3bf2..9ada77d 100644 --- a/jinwei.me/infra/dockerhub.tf +++ b/jinwei.me/infra/dockerhub.tf @@ -9,3 +9,9 @@ resource "aws_ssm_parameter" "dockerhub_token" { type = "SecureString" value = var.dockerhub_token } + +resource "aws_secretsmanager_secret" "datadog_api_key" { + name = "/${local.name}/datadog/api_key" + type = "SecureString" + value = var.datadog_api_key +} diff --git a/jinwei.me/infra/variables.tf b/jinwei.me/infra/variables.tf index f364ef4..11cf2cf 100644 --- a/jinwei.me/infra/variables.tf +++ b/jinwei.me/infra/variables.tf @@ -100,3 +100,9 @@ variable "dockerhub_token" { type = string sensitive = true } + +variable "datadog_api_key" { + description = "Datadog.com API Key" + type = string + sensitive = true +} -- cgit v1.2.3 From 1863462e23f8d7099bb26c3a11d5ed9a2cce54cd Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Wed, 11 Jan 2023 19:55:59 -0800 Subject: use aws_ssm --- jinwei.me/config/roles/debian_init/tasks/main.yaml | 2 +- jinwei.me/infra/dockerhub.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jinwei.me/config/roles/debian_init/tasks/main.yaml b/jinwei.me/config/roles/debian_init/tasks/main.yaml index 539c43f..a8d45d7 100644 --- a/jinwei.me/config/roles/debian_init/tasks/main.yaml +++ b/jinwei.me/config/roles/debian_init/tasks/main.yaml @@ -95,4 +95,4 @@ - name: Install Datadog command: - DD_API_KEY={{ lookup('aws_secretsmanager_secret', '/jinwei-me/datadog/api_key') }} DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)" + DD_API_KEY={{ lookup('aws_ssm', '/jinwei-me/datadog/api_key') }} DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)" diff --git a/jinwei.me/infra/dockerhub.tf b/jinwei.me/infra/dockerhub.tf index 9ada77d..f4c6bf5 100644 --- a/jinwei.me/infra/dockerhub.tf +++ b/jinwei.me/infra/dockerhub.tf @@ -10,7 +10,7 @@ resource "aws_ssm_parameter" "dockerhub_token" { value = var.dockerhub_token } -resource "aws_secretsmanager_secret" "datadog_api_key" { +resource "aws_ssm_parameter" "datadog_api_key" { name = "/${local.name}/datadog/api_key" type = "SecureString" value = var.datadog_api_key -- cgit v1.2.3