From 37817df9623bca292971ed1b2b5655f5bb528fca Mon Sep 17 00:00:00 2001 From: vmankonda Date: Thu, 30 Jan 2025 14:43:42 +0530 Subject: [PATCH 1/3] Added condition support for US GOV cloud --- examples/modules/cloud-integrations/aws/main.tf | 4 ++-- examples/modules/cloud-integrations/aws/variables.tf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/modules/cloud-integrations/aws/main.tf b/examples/modules/cloud-integrations/aws/main.tf index 7e5776756..8338b27e7 100644 --- a/examples/modules/cloud-integrations/aws/main.tf +++ b/examples/modules/cloud-integrations/aws/main.tf @@ -5,7 +5,7 @@ data "aws_iam_policy_document" "newrelic_assume_policy" { principals { type = "AWS" // This is the unique identifier for New Relic account on AWS, there is no need to change this - identifiers = [754728514883] + identifiers = var.newrelic_account_region == "US_GOV" ? [266471868085] : [754728514883] } condition { @@ -125,7 +125,7 @@ resource "aws_kinesis_firehose_delivery_stream" "newrelic_firehose_stream" { name = "newrelic_firehose_stream_${var.name}" destination = "http_endpoint" http_endpoint_configuration { - url = var.newrelic_account_region == "US" ? "https://aws-api.newrelic.com/cloudwatch-metrics/v1" : "https://aws-api.eu01.nr-data.net/cloudwatch-metrics/v1" + url = var.newrelic_account_region == "US_GOV" ? "https://gov-aws-api.newrelic.com/cloudwatch-metrics/v1" : (var.newrelic_account_region == "US" ? "https://aws-api.newrelic.com/cloudwatch-metrics/v1" : "https://aws-api.eu01.nr-data.net/cloudwatch-metrics/v1)" name = "New Relic ${var.name}" access_key = newrelic_api_access_key.newrelic_aws_access_key.key buffering_size = 1 diff --git a/examples/modules/cloud-integrations/aws/variables.tf b/examples/modules/cloud-integrations/aws/variables.tf index 378af7083..d3fc88402 100644 --- a/examples/modules/cloud-integrations/aws/variables.tf +++ b/examples/modules/cloud-integrations/aws/variables.tf @@ -7,7 +7,7 @@ variable "newrelic_account_region" { default = "US" validation { - condition = contains(["US", "EU"], var.newrelic_account_region) + condition = contains(["US", "EU", "US_GOV"], var.newrelic_account_region) error_message = "Valid values for region are 'US' or 'EU'." } } From 105f034d4f5b9c4c85ddf71fb97db61748d99f6e Mon Sep 17 00:00:00 2001 From: vmankonda Date: Thu, 30 Jan 2025 16:08:34 +0530 Subject: [PATCH 2/3] Revert "Added condition support for US GOV cloud" This reverts commit 37817df9623bca292971ed1b2b5655f5bb528fca. --- examples/modules/cloud-integrations/aws/main.tf | 4 ++-- examples/modules/cloud-integrations/aws/variables.tf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/modules/cloud-integrations/aws/main.tf b/examples/modules/cloud-integrations/aws/main.tf index 8338b27e7..7e5776756 100644 --- a/examples/modules/cloud-integrations/aws/main.tf +++ b/examples/modules/cloud-integrations/aws/main.tf @@ -5,7 +5,7 @@ data "aws_iam_policy_document" "newrelic_assume_policy" { principals { type = "AWS" // This is the unique identifier for New Relic account on AWS, there is no need to change this - identifiers = var.newrelic_account_region == "US_GOV" ? [266471868085] : [754728514883] + identifiers = [754728514883] } condition { @@ -125,7 +125,7 @@ resource "aws_kinesis_firehose_delivery_stream" "newrelic_firehose_stream" { name = "newrelic_firehose_stream_${var.name}" destination = "http_endpoint" http_endpoint_configuration { - url = var.newrelic_account_region == "US_GOV" ? "https://gov-aws-api.newrelic.com/cloudwatch-metrics/v1" : (var.newrelic_account_region == "US" ? "https://aws-api.newrelic.com/cloudwatch-metrics/v1" : "https://aws-api.eu01.nr-data.net/cloudwatch-metrics/v1)" + url = var.newrelic_account_region == "US" ? "https://aws-api.newrelic.com/cloudwatch-metrics/v1" : "https://aws-api.eu01.nr-data.net/cloudwatch-metrics/v1" name = "New Relic ${var.name}" access_key = newrelic_api_access_key.newrelic_aws_access_key.key buffering_size = 1 diff --git a/examples/modules/cloud-integrations/aws/variables.tf b/examples/modules/cloud-integrations/aws/variables.tf index d3fc88402..378af7083 100644 --- a/examples/modules/cloud-integrations/aws/variables.tf +++ b/examples/modules/cloud-integrations/aws/variables.tf @@ -7,7 +7,7 @@ variable "newrelic_account_region" { default = "US" validation { - condition = contains(["US", "EU", "US_GOV"], var.newrelic_account_region) + condition = contains(["US", "EU"], var.newrelic_account_region) error_message = "Valid values for region are 'US' or 'EU'." } } From 18442cd5fc461cdb69d29dc915cf9b3504379239 Mon Sep 17 00:00:00 2001 From: vmankonda Date: Thu, 30 Jan 2025 17:17:47 +0530 Subject: [PATCH 3/3] US GOV Terraform Support 1. Created separate configurations for gov cloud. 2. applied correct resources assigned for gov cloud 3. removed aws resources for which gov cloud permissions do not allow integrations. check https://docs.newrelic.com/docs/infrastructure/amazon-integrations/connect/connect-aws-govcloud-new-relic/ --- .../cloud-integrations/aws_us_gov/main.tf | 320 ++++++++++++++++++ .../aws_us_gov/providers.tf | 10 + .../aws_us_gov/variables.tf | 20 ++ 3 files changed, 350 insertions(+) create mode 100644 examples/modules/cloud-integrations/aws_us_gov/main.tf create mode 100644 examples/modules/cloud-integrations/aws_us_gov/providers.tf create mode 100644 examples/modules/cloud-integrations/aws_us_gov/variables.tf diff --git a/examples/modules/cloud-integrations/aws_us_gov/main.tf b/examples/modules/cloud-integrations/aws_us_gov/main.tf new file mode 100644 index 000000000..c7dbd83f7 --- /dev/null +++ b/examples/modules/cloud-integrations/aws_us_gov/main.tf @@ -0,0 +1,320 @@ +data "aws_iam_policy_document" "newrelic_assume_policy" { + statement { + actions = ["sts:AssumeRole"] + + principals { + type = "AWS" + // This is the unique identifier for New Relic account on AWS, there is no need to change this + identifiers = [266471868085] + } + + condition { + test = "StringEquals" + variable = "sts:ExternalId" + values = [var.newrelic_account_id] + } + } +} + +resource "aws_iam_role" "newrelic_aws_role" { + name = "NewRelicInfrastructure-Integrations-${var.name}" + description = "New Relic Cloud integration role" + assume_role_policy = data.aws_iam_policy_document.newrelic_assume_policy.json +} + +resource "aws_iam_policy" "newrelic_aws_permissions" { + name = "NewRelicCloudStreamReadPermissions-${var.name}" + description = "" + policy = <