generated from rhythmictech/terraform-terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from rhythmictech/rds-enhanced-monitoring
Add DataDog enhanced monitoring
- Loading branch information
Showing
10 changed files
with
276 additions
and
177 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name: pre-commit-check | ||
on: | ||
push: | ||
branches: -- main | ||
branches: | ||
- master | ||
- prod | ||
- develop | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,49 @@ | ||
# TODO: allow version specification | ||
# right now you can't use variables in a module's source so we'll have to use the external provider or git submodules | ||
module "rds_enhanced_monitoring_lambda_code" { | ||
source = "git::https://github.com/DataDog/datadog-serverless-functions.git?ref=aws-dd-forwarder-3.83.0" | ||
} | ||
|
||
########################################## | ||
# this is basically copied from https://github.com/DataDog/datadog-serverless-functions/blob/master/aws/rds_enhanced_monitoring/rds-enhanced-sam-template.yaml | ||
# because their documentation says to use the SAM repo which points to an out-of-date version | ||
# and because we load the API key differently | ||
########################################## | ||
|
||
resource "aws_cloudformation_stack" "rds_enhanced_monitoring_lambda" { | ||
count = var.install_rds_enhanced_monitoring_lambda ? 1 : 0 | ||
|
||
name = "${var.name}-rds-enhanced-monitoring-forwarder" | ||
capabilities = ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM", "CAPABILITY_AUTO_EXPAND"] | ||
depends_on = [module.rds_enhanced_monitoring_lambda_code] | ||
|
||
template_body = <<EOF | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: 'Pushes RDS Enhanced metrics to Datadog.' | ||
Resources: | ||
rdslambdaddfunction: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
Description: Pushes RDS Enhanced metrics to Datadog. | ||
InlineCode: | | ||
${indent(8, file("${path.module}.rds_enhanced_monitoring_lambda_code/aws/rds_enhanced_monitoring/lambda_function.py"))} | ||
Environment: | ||
Variables: | ||
DD_API_KEY_SECRET_ARN: '${aws_secretsmanager_secret_version.datadog.arn}' | ||
Events: | ||
RDSEnhancedMetrics: | ||
Type: CloudWatchLogs | ||
Properties: | ||
LogGroupName: RDSOSMetrics | ||
FilterPattern: "" | ||
Handler: index.lambda_handler | ||
MemorySize: 128 | ||
Runtime: python3.9 | ||
Policies: | ||
- AWSLambdaExecute | ||
- AWSSecretsManagerGetSecretValuePolicy: | ||
SecretArn: '${aws_secretsmanager_secret_version.datadog.arn}' | ||
Timeout: 10 | ||
EOF | ||
} |
Oops, something went wrong.