-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor cloudwatch monitoring policy module (#21)
It was previously named _role, but it didn't create any actual IAM role. To keep the consistency with other modules in this repo, I've changed the sufix of the module to `_policy`, and modified it so it outputs the policy instead of attaching it to anything.
- Loading branch information
1 parent
382776b
commit 1685299
Showing
7 changed files
with
62 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
data "aws_iam_policy_document" "cloudwatch_monitoring_policy" { | ||
statement { | ||
sid = "CloudWatchMonitoring" | ||
|
||
actions = [ | ||
"cloudwatch:PutMetricData", | ||
"cloudwatch:GetMetricStatistics", | ||
"cloudwatch:ListMetrics", | ||
"ec2:DescribeTags" | ||
] | ||
|
||
effect = "Allow" | ||
|
||
resources = ["*"] | ||
} | ||
} | ||
|
||
resource "aws_iam_policy" "cloudwatch_monitoring_policy" { | ||
name = var.name != null ? "cloudwatch_monitoring_${var.name}" : null | ||
name_prefix = var.name == null ? "cloudwatch_monitoring_" : null | ||
policy = data.aws_iam_policy_document.cloudwatch_monitoring_policy.json | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
output "iam_policy_arn" { | ||
description = "ARN of the Cloudwatch monitoring IAM policy" | ||
value = aws_iam_policy.cloudwatch_monitoring_policy.arn | ||
} | ||
|
||
output "iam_policy_name" { | ||
description = "Name of the Cloudwatch monitoring IAM policy" | ||
value = aws_iam_policy.cloudwatch_monitoring_policy.name | ||
} | ||
|
||
output "iam_policy_id" { | ||
description = "ID of the Cloudwatch monitoring IAM policy" | ||
value = aws_iam_policy.cloudwatch_monitoring_policy.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
variable "name" { | ||
description = "Name to differentiate the policy name. Name will be autogenerated if omitted" | ||
type = string | ||
default = null | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.