Skip to content

Commit 7463a22

Browse files
committed
fix: add cloudwatch_log_group_principals variable to fix IAM trust policy
Fixes #35 ## Problem The module uses the cloudposse/cloudwatch-logs/aws module which defaults to ec2.amazonaws.com as the principal service for the IAM role trust policy. This is incorrect for API Gateway and causes deployment failures. ## Solution Add a cloudwatch_log_group_principals variable that: - Accepts a map of service principals for the CloudWatch Logs IAM role - Defaults to apigateway.amazonaws.com (the correct principal) - Passes through to the cloudwatch-logs module ## Impact - Fixes API Gateway deployments with CloudWatch logging enabled - Backward compatible - uses sensible default - Allows overriding principals if needed for specific use cases ## Testing Existing tests should pass as they now use the correct IAM principal. The complete example creates an API Gateway with logging enabled and verifies successful deployment.
1 parent 8c52717 commit 7463a22

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module "cloudwatch_log_group" {
3333
enabled = local.create_log_group
3434
iam_tags_enabled = var.iam_tags_enabled
3535
permissions_boundary = var.permissions_boundary
36+
principals = var.cloudwatch_log_group_principals
3637

3738
context = module.this.context
3839
}

variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,11 @@ variable "throttling_rate_limit" {
151151
type = number
152152
default = -1
153153
}
154+
155+
variable "cloudwatch_log_group_principals" {
156+
description = "Map of service principals allowed to assume the CloudWatch Logs IAM role. Defaults to apigateway.amazonaws.com to fix the incorrect ec2.amazonaws.com default from the cloudwatch-logs module."
157+
type = map(list(string))
158+
default = {
159+
Service = ["apigateway.amazonaws.com"]
160+
}
161+
}

0 commit comments

Comments
 (0)