Skip to content

feat: attach extra iam policies #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions logs_monitoring.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource aws_cloudformation_stack "datadog-forwarder" {
resource "aws_cloudformation_stack" "datadog-forwarder" {
name = "${local.stack_prefix}datadog-forwarder"
capabilities = ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM", "CAPABILITY_AUTO_EXPAND"]
parameters = {
Expand All @@ -18,13 +18,13 @@ resource aws_cloudformation_stack "datadog-forwarder" {
}
}

resource aws_secretsmanager_secret "datadog_api_key" {
resource "aws_secretsmanager_secret" "datadog_api_key" {
name_prefix = "${local.stack_prefix}datadog-api-key"
description = "Datadog API Key"
tags = local.default_tags
}

resource aws_secretsmanager_secret_version "datadog_api_key" {
resource "aws_secretsmanager_secret_version" "datadog_api_key" {
secret_id = aws_secretsmanager_secret.datadog_api_key.id
secret_string = var.datadog_api_key
}
2 changes: 1 addition & 1 deletion logs_monitoring_cloudwatch_log.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resource "aws_cloudwatch_log_subscription_filter" "test_lambdafunction_logfilter
distribution = "Random"
}

resource aws_lambda_permission "allow_cloudwatch_logs_to_call_dd_lambda_handler" {
resource "aws_lambda_permission" "allow_cloudwatch_logs_to_call_dd_lambda_handler" {
count = length(var.cloudwatch_log_groups)
statement_id = "${replace(var.cloudwatch_log_groups[count.index], "/", "_")}-AllowExecutionFromCloudWatchLogs"
action = "lambda:InvokeFunction"
Expand Down
6 changes: 6 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,9 @@ resource "aws_iam_role_policy_attachment" "datadog-core-attach" {
role = aws_iam_role.datadog-integration[0].name
policy_arn = aws_iam_policy.datadog-core[0].arn
}

resource "aws_iam_role_policy_attachment" "datadog-core-attach-extras" {
for_each = toset(var.extra_policy_arns)
role = aws_iam_role.datadog-integration[0].name
policy_arn = each.value
}
8 changes: 7 additions & 1 deletion vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ variable "env" {
}
variable "account_specific_namespace_rules" {
description = "account_specific_namespace_rules argument for datadog_integration_aws resource"
type = map
type = map(any)
default = {}
}
variable "elb_logs_bucket_prefix" {
Expand Down Expand Up @@ -86,3 +86,9 @@ variable "filter_tags" {
type = list(string)
default = []
}

variable "extra_policy_arns" {
description = "Extra policy arns to attach to the datadog-integration-role"
type = list(string)
default = []
}