Skip to content

Commit

Permalink
revert changes to add as PR
Browse files Browse the repository at this point in the history
Revert "provider update"

This reverts commit e96f1de.
  • Loading branch information
dpacheconr committed May 15, 2024
1 parent e96f1de commit de2bb30
Show file tree
Hide file tree
Showing 12 changed files with 475 additions and 1,023 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module "SSLChecker" {
source = "./modules/sslchecker"
insertAPIKey = var.insertAPIKey
locations = ["AWS_US_EAST_1"] //set the AWS region(s) you want it to run
frequency = "EVERY_5_MINUTES"
frequency = 60
jobs = {
# Small example

Expand Down
49 changes: 29 additions & 20 deletions terraform/modules/sslchecker/modules/sslminion/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,42 @@ variable "insertKeyValue" { description = "Insert key valye"}
variable "targetDataJS" { description = "JS code to set target data"}
variable "nameSpace" { description = "Namespace for the app, usually SSLCHKR, provide a different one if deploying this app more than once to an account" }


resource "newrelic_synthetics_script_monitor" "monitor" {
status = "ENABLED"
name = "${var.nameSpace}-${var.name}"
type = "SCRIPT_API"
locations_public = var.locations
period = var.frequency

script = "const MONITOR_NAME=\"${var.nameSpace}-${var.name}\"\nconst NAMESPACE=\"${var.nameSpace}\" \nlet INSERT_KEY=$secure.${newrelic_synthetics_secure_credential.metricsInsertKey.key}\n${var.targetDataJS}\n${data.local_file.synthetic_js.content}"

script_language = "JAVASCRIPT"
runtime_type = "NODE_API"
runtime_type_version = "16.10"
resource "newrelic_synthetics_monitor" "monitor" {
name = "${var.nameSpace}-${var.name}"
type = "SCRIPT_API"
frequency = var.frequency
status = "ENABLED"
locations = var.locations
}

resource "newrelic_synthetics_secure_credential" "metricsInsertKey" {
key = "${random_string.random.result}"
key = "${var.nameSpace}_MetricInsertKey_${replace(newrelic_synthetics_monitor.monitor.id,"-","_")}"
value = var.insertKeyValue
description = "API key for inserting metrics data to New Relic"
}

resource "random_string" "random" {
length = 6
special = true
override_special = "/@£$"
data "local_file" "base_js" {
filename = "${path.module}/src/base_script.js"
}

data "local_file" "utils_js" {
filename = "${path.module}/src/utils_script.js"
}

data "template_file" "header_js" {
template = templatefile(
"${path.module}/src/header_script.js",
{
monitorName = var.name
monitorId = newrelic_synthetics_monitor.monitor.id
nameSpace = var.nameSpace
insertKeyName = newrelic_synthetics_secure_credential.metricsInsertKey.key
}
)
}

data "local_file" "synthetic_js" {
filename = "${path.module}/src/synthetic.js"
resource "newrelic_synthetics_monitor_script" "main" {
monitor_id = newrelic_synthetics_monitor.monitor.id
text = "${data.template_file.header_js.rendered} ${data.local_file.utils_js.content} ${var.targetDataJS} ${data.local_file.base_js.content}"
depends_on = [newrelic_synthetics_secure_credential.metricsInsertKey]
}
6 changes: 3 additions & 3 deletions terraform/modules/sslchecker/modules/sslminion/provider.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
terraform {
required_providers {
required_providers {
newrelic = {
source = "newrelic/newrelic"
version = ">=3.36.0"
source = "newrelic/newrelic"
version = "~> 2.23.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ async function run() {
//Construct metric payload
let commonMetricBlock={"attributes": {}}
commonMetricBlock.attributes[`${NAMESPACE}.monitorName`]=MONITOR_NAME
commonMetricBlock.attributes[`${NAMESPACE}.monitorId`]=MONITOR_ID
commonMetricBlock.attributes[`tool`]=NAMESPACE

let unixTimeNow=Math.round(Date.now()/1000)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let INSERT_KEY=$secure.${insertKeyName}
const MONITOR_NAME="${monitorName}"
const MONITOR_ID="${monitorId}"
const NAMESPACE ="${nameSpace}"
// End of terraform

Loading

0 comments on commit de2bb30

Please sign in to comment.