Skip to content

Commit 99da490

Browse files
committed
Fix review suggestions
1 parent 13a23e5 commit 99da490

File tree

9 files changed

+52
-6
lines changed

9 files changed

+52
-6
lines changed

addons/byo-cloudwatch-log-sharing/target-account-firehose/.header.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Because CloudWatch Logs destinations must be created in the same region as the s
99
- `aws.destination`: Region of the Fleet CloudWatch log group (source region).
1010
- `aws.target`: Region for the Firehose stream and S3 bucket (same region or different region).
1111

12+
Both provider aliases must use the same AWS account credentials. Cross-account is achieved between source and target subscriptions, not between `aws.destination` and `aws.target` within this module.
13+
1214
## Usage
1315

1416
```hcl

addons/byo-cloudwatch-log-sharing/target-account-firehose/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Because CloudWatch Logs destinations must be created in the same region as the s
99
- `aws.destination`: Region of the Fleet CloudWatch log group (source region).
1010
- `aws.target`: Region for the Firehose stream and S3 bucket (same region or different region).
1111

12+
Both provider aliases must use the same AWS account credentials. Cross-account is achieved between source and target subscriptions, not between `aws.destination` and `aws.target` within this module.
13+
1214
## Usage
1315

1416
```hcl

addons/byo-cloudwatch-log-sharing/target-account-firehose/firehose.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ data "aws_iam_policy_document" "firehose_assume_role" {
1212

1313
resource "aws_iam_role" "firehose" {
1414
provider = aws.target
15-
name = var.firehose.role_name
15+
name = local.firehose_role_name
1616
assume_role_policy = data.aws_iam_policy_document.firehose_assume_role.json
1717
tags = var.tags
1818
}

addons/byo-cloudwatch-log-sharing/target-account-firehose/iam.tf

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
locals {
2+
cloudwatch_destination_role_name = coalesce(
3+
var.cloudwatch_destination.role_name,
4+
"fleet-log-sharing-firehose-destination-role"
5+
)
6+
firehose_role_name = coalesce(
7+
var.firehose.role_name,
8+
"fleet-log-sharing-firehose-delivery-role"
9+
)
10+
211
cloudwatch_destination_policy_name = coalesce(
312
var.cloudwatch_destination.policy_name,
4-
"${var.cloudwatch_destination.role_name}-policy"
13+
"${local.cloudwatch_destination_role_name}-policy"
514
)
615
firehose_policy_name = coalesce(
716
var.firehose.policy_name,
8-
"${var.firehose.role_name}-policy"
17+
"${local.firehose_role_name}-policy"
918
)
1019
}
1120

@@ -29,7 +38,7 @@ data "aws_iam_policy_document" "assume_role" {
2938

3039
resource "aws_iam_role" "destination" {
3140
provider = aws.destination
32-
name = var.cloudwatch_destination.role_name
41+
name = local.cloudwatch_destination_role_name
3342
assume_role_policy = data.aws_iam_policy_document.assume_role.json
3443
tags = var.tags
3544
}

addons/byo-cloudwatch-log-sharing/target-account-firehose/variables.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ variable "cloudwatch_destination" {
2222
policy_name = optional(string)
2323
})
2424
default = {}
25+
26+
validation {
27+
condition = (
28+
var.cloudwatch_destination.role_name == null ||
29+
length(trimspace(var.cloudwatch_destination.role_name)) > 0
30+
)
31+
error_message = "cloudwatch_destination.role_name must be null or a non-empty string."
32+
}
2533
}
2634

2735
variable "firehose" {
@@ -57,6 +65,14 @@ variable "firehose" {
5765
], var.firehose.compression_format)
5866
error_message = "firehose.compression_format must be one of: UNCOMPRESSED, GZIP, ZIP, Snappy, HADOOP_SNAPPY."
5967
}
68+
69+
validation {
70+
condition = (
71+
var.firehose.role_name == null ||
72+
length(trimspace(var.firehose.role_name)) > 0
73+
)
74+
error_message = "firehose.role_name must be null or a non-empty string."
75+
}
6076
}
6177

6278
variable "s3" {

addons/byo-cloudwatch-log-sharing/target-account-kinesis/.header.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Because CloudWatch Logs destinations must be created in the same region as the s
77
- `aws.destination`: Region of the Fleet CloudWatch log group (source region).
88
- `aws.target`: Region for the Kinesis stream (same region or different region).
99

10+
Both provider aliases must use the same AWS account credentials. Cross-account is achieved between source and target subscriptions, not between `aws.destination` and `aws.target` within this module.
11+
1012
## Usage
1113

1214
```hcl

addons/byo-cloudwatch-log-sharing/target-account-kinesis/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Because CloudWatch Logs destinations must be created in the same region as the s
77
- `aws.destination`: Region of the Fleet CloudWatch log group (source region).
88
- `aws.target`: Region for the Kinesis stream (same region or different region).
99

10+
Both provider aliases must use the same AWS account credentials. Cross-account is achieved between source and target subscriptions, not between `aws.destination` and `aws.target` within this module.
11+
1012
## Usage
1113

1214
```hcl

addons/byo-cloudwatch-log-sharing/target-account-kinesis/iam.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
locals {
2+
cloudwatch_destination_role_name = coalesce(
3+
var.cloudwatch_destination.role_name,
4+
"fleet-log-sharing-destination-role"
5+
)
6+
27
cloudwatch_destination_policy_name = coalesce(
38
var.cloudwatch_destination.policy_name,
4-
"${var.cloudwatch_destination.role_name}-policy"
9+
"${local.cloudwatch_destination_role_name}-policy"
510
)
611
}
712

@@ -25,7 +30,7 @@ data "aws_iam_policy_document" "assume_role" {
2530

2631
resource "aws_iam_role" "destination" {
2732
provider = aws.destination
28-
name = var.cloudwatch_destination.role_name
33+
name = local.cloudwatch_destination_role_name
2934
assume_role_policy = data.aws_iam_policy_document.assume_role.json
3035
tags = var.tags
3136
}

addons/byo-cloudwatch-log-sharing/target-account-kinesis/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ variable "cloudwatch_destination" {
2222
policy_name = optional(string)
2323
})
2424
default = {}
25+
26+
validation {
27+
condition = (
28+
var.cloudwatch_destination.role_name == null ||
29+
length(trimspace(var.cloudwatch_destination.role_name)) > 0
30+
)
31+
error_message = "cloudwatch_destination.role_name must be null or a non-empty string."
32+
}
2533
}
2634

2735
variable "kinesis" {

0 commit comments

Comments
 (0)