Skip to content

Commit

Permalink
fix: changed resource arn if integration is deployed from govcloud [C…
Browse files Browse the repository at this point in the history
…DS-1667] (#184)

* changed resource arn if integration is deployed from govcloud

* fix: update changelog and example variables file

* fix: update readme file
  • Loading branch information
guyrenny authored Nov 10, 2024
1 parent 5e7e875 commit 575ba07
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v2.1.2
#### **coralogix-aws-shipper**
### 🧰 Bug fixes 🧰
- Add new variable `govcloud_deployment`, when set to true the arn of resource that are being used by the module will start with `arn:aws-us-gov` instead of `arn:aws`
- Add a condition to the `aws_iam_policy.AWSLambdaMSKExecutionRole` block so it will only create it when MSK is enabled

## v2.1.1
#### **S3-archive**
### 🧰 Bug fixes 🧰
Expand Down
6 changes: 6 additions & 0 deletions examples/coralogix-aws-shipper/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,9 @@ variable "custom_metadata" {
description = "Add custom metadata to the log message. Expects comma separated values. Options are key1=value1,key2=value2 "
type = string
}

variable "govcloud_deployment" {
description = "Enable if you deploy the integration in govcloud"
type = bool
default = false
}
2 changes: 1 addition & 1 deletion modules/coralogix-aws-shipper/Msk.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ resource "aws_iam_role_policy" "destination_policy" {
resource "aws_iam_role_policy_attachment" "msk-role-policy-attach" {
count = var.msk_cluster_arn != null ? 1 : 0
role = aws_iam_role.role_for_msk[0].name
policy_arn = data.aws_iam_policy.AWSLambdaMSKExecutionRole.arn
policy_arn = data.aws_iam_policy.AWSLambdaMSKExecutionRole[0].arn
}

resource "aws_lambda_event_source_mapping" "msk_event_mapping" {
Expand Down
1 change: 1 addition & 0 deletions modules/coralogix-aws-shipper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ If you want to avoid this issue, you can deploy in other ways:
| <a name="input_sampling_rate"></a> [sampling\_rate](#input\_sampling\_rate) | Send messages at a specific rate, such as 1 out of every N logs. For example, if your value is 10, a message will be sent for every 10th log. | `number` | `1` | no |
| <a name="input_notification_email"></a> [notification_email](#input\_notification\_email) | A failure notification will be sent to this email address. | `string` | n/a | no |
| <a name="input_custom_s3_bucket"></a> [custom\_s3\_bucket](#input\_custom\_s3\_bucket) | The name of an existing s3 bucket in your region, in which the lambda zip code will be uploaded to. | `string` | n/a | no |
| <a name="input_govcloud_deployment"></a> [govcloud\_deployment](#input\_govcloud\_deployment) | Enable if you deploy the integration in govcloud | `bool` | false | no |

**Custom S3 Bucket**

Expand Down
5 changes: 3 additions & 2 deletions modules/coralogix-aws-shipper/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ data "aws_iam_policy_document" "topic" {
}

actions = local.sns_enable ? ["SNS:Publish"] : ["SQS:SendMessage"]
resources = local.sns_enable ? ["arn:aws:sns:*:*:${data.aws_sns_topic.sns_topic[count.index].name}"] : ["arn:aws:sqs:*:*:${data.aws_sqs_queue.name[count.index].name}"]
resources = local.sns_enable ? ["${local.arn_prefix}:sns:*:*:${data.aws_sns_topic.sns_topic[count.index].name}"] : ["${local.arn_prefix}:sqs:*:*:${data.aws_sqs_queue.name[count.index].name}"]

condition {
test = "ArnLike"
Expand All @@ -59,5 +59,6 @@ data "aws_iam_policy_document" "topic" {
}

data "aws_iam_policy" "AWSLambdaMSKExecutionRole" {
arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole"
count = var.msk_cluster_arn != null ? 1 : 0
arn = "${local.arn_prefix}:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole"
}
1 change: 1 addition & 0 deletions modules/coralogix-aws-shipper/local.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ locals {
is_sns_integration = local.sns_enable && (var.integration_type == "S3" || var.integration_type == "Sns" || var.integration_type == "CloudTrail") ? true : false
is_sqs_integration = var.sqs_name != null && (var.integration_type == "S3" || var.integration_type == "CloudTrail" || var.integration_type == "Sqs") ? true : false

arn_prefix = var.govcloud_deployment ? "arn:aws-us-gov" : "arn:aws"
}
6 changes: 6 additions & 0 deletions modules/coralogix-aws-shipper/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ variable "custom_s3_bucket" {
default = ""
}

variable "govcloud_deployment" {
description = "Enable if you deploy the integration in govcloud"
type = bool
default = false
}

variable "lambda_name" {
type = string
description = "The name of the lambda function"
Expand Down

0 comments on commit 575ba07

Please sign in to comment.