forked from DataDog/datadog-serverless-functions
-
Notifications
You must be signed in to change notification settings - Fork 0
terraform module for the lambda_function #1
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
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
8c5a02b
terraform module for the lambda_function
6f91fba
json.loads of os env METADATA
9b10ec6
order those imports!
aeikenberry 2c51912
merge fix
aeikenberry 5c95a95
cleaning up
aeikenberry 84be834
support log_tags variable to supply CUSTOM_TAGS env variable and add …
886bfc2
[Logs] Improve retry logic to catch exceptions in the socket
tmichelet 75768b7
[Logs] Print more information when catching an exception
tmichelet 19fd398
[Logs] Avoid logging an error when we successfully retry submission
tmichelet d9f4726
Merge pull request #24 from DataDog/tristan/fix-logs-lambda-retry
tmichelet 06c2498
should be awslogS not singular
aldegoeij 5afe7fd
Merge pull request #25 from aldegoeij/master
88e0a0b
Add source auto detection for mysql and mariadb in RDS
a659fde
Refactor the Parse_event_source function
bc24709
add apigateway automatic source detection
004b562
Fix gzip decompression
da93f30
fix formatting
6ad517d
Fix elb source issue after refactoring
7d2ef76
Merge pull request #27 from DataDog/nils/rds
6ba484b
Merge pull request #28 from tinyclues/fix-gzip-decompress
2a2c157
update yaml files to add key parameter
DanielLanger d2385bd
lower case kms
DanielLanger 686df82
add type
DanielLanger a5b1881
lower case arn
DanielLanger 4f3e6ab
Merge pull request #29 from DataDog/daniel/samtemplateupdate
DanielLanger 706ab14
rename custom tag
DanielLanger d0152ac
fix typo
DanielLanger 55e976b
Merge pull request #31 from DataDog/daniel/samtemplateupdate
DanielLanger 1b8fb3d
Merge pull request #30 from DataDog/daniel/awslogfunction
DanielLanger f83ecd8
Lowercase on the lambda function name to match infrastructure tags
86e6e11
Merge pull request #33 from DataDog/nils/logs-lambda-lowercase
be3d38e
Add support for Cloudwatch Events
2d3779c
Merge pull request #35 from DataDog/nils/cloudwatch-events
4dd76c2
[Logs] Update endpoint for logs-submitter lambda function
tmichelet f73db17
Merge pull request #37 from DataDog/tristan/logs
tmichelet 0c04d66
Merge remote-tracking branch 'base/master' into feature/terraform-app…
75215f9
adding METADATA env variable json to log lines
ebd1387
Terraform Usage comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 +2,7 @@ env | |
base.zip | ||
*/gen | ||
*/env | ||
*.tfvars | ||
*.tfstate* | ||
.terraform | ||
*.zip |
This file contains hidden or 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 hidden or 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 hidden or 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,83 @@ | ||
variable "aws_region" { | ||
default = "us-east-1" | ||
} | ||
|
||
provider "aws" { | ||
region = "${var.aws_region}" | ||
} | ||
|
||
variable "DD_API_KEY" { | ||
description = "This token is used to associate AWS CloudWatch logs to a log in your Logentries account." | ||
} | ||
|
||
variable "function_name" { | ||
default = "dd_log_appender" | ||
} | ||
|
||
variable "role" { | ||
description = "arn of the lambda role" | ||
} | ||
|
||
variable "memory_size" { | ||
default = 1024 | ||
} | ||
|
||
variable "timeout" { | ||
default = 300 | ||
} | ||
|
||
variable "metadata" { | ||
type = "map" | ||
default = {} | ||
description = "map of custom key:value entries on each log statement" | ||
} | ||
|
||
variable "tags" { | ||
type = "map" | ||
default = {} | ||
description = "lambda function tags" | ||
} | ||
|
||
data "archive_file" "fn" { | ||
type = "zip" | ||
source_file = "${path.module}/lambda_function.py" | ||
output_path = "${path.module}/lambda_function.py.zip" | ||
} | ||
|
||
resource "aws_lambda_function" "fn" { | ||
function_name = "${var.function_name}" | ||
role = "${var.role}" | ||
handler = "lambda_function.lambda_handler" | ||
filename = "${path.module}/lambda_function.py.zip" | ||
source_code_hash = "${data.archive_file.fn.output_base64sha256}" | ||
|
||
# Set memory to 128 MB | ||
memory_size = "${var.memory_size}" | ||
|
||
# Set timeout to ~2 minutes (script only runs for seconds at a time) | ||
timeout = "${var.timeout}" | ||
runtime = "python2.7" | ||
|
||
environment { | ||
variables = { | ||
DD_API_KEY = "${var.DD_API_KEY}" | ||
METADATA = "${jsonencode(var.metadata)}" | ||
} | ||
} | ||
|
||
tags = "${var.tags}" | ||
|
||
depends_on = ["data.archive_file.fn"] | ||
} | ||
|
||
output "function_arn" { | ||
value = "${aws_lambda_function.fn.arn}" | ||
} | ||
|
||
output "function_name" { | ||
value = "${aws_lambda_function.fn.function_name}" | ||
} | ||
|
||
output "function_version" { | ||
value = "${aws_lambda_function.fn.version}" | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,18 +1,27 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: Pushes RDS Enhanced metrics to Datadog. | ||
Parameters: | ||
KMSKeyId: | ||
Type: String | ||
Description: The id (final part of the key's ARN) of a KMS key used to encrypt and decrypt your Datadog API and App keys. | ||
Resources: | ||
rdslambdaddfunction: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
Description: Pushes RDS Enhanced metrics to Datadog. | ||
Environment: | ||
Variables: | ||
kmsEncryptedKeys: YOUR_KEY | ||
kmsEncryptedKeys: 'YOUR_KEY' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this right? |
||
Handler: lambda_function.lambda_handler | ||
MemorySize: 128 | ||
Policies: | ||
KMSDecryptPolicy: | ||
KeyId: YOUR_KEY | ||
KeyId: !Ref KMSKeyId | ||
Runtime: python2.7 | ||
Timeout: 10 | ||
KmsKeyArn: | ||
!Sub | ||
- 'arn:${AWS::Partition}:kms:${AWS::Region}:${AWS::AccountId}:key/${keyId}' | ||
- {keyId: !Ref KMSKeyId} | ||
Type: AWS::Serverless::Function | ||
Transform: AWS::Serverless-2016-10-31 |
This file contains hidden or 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 |
---|---|---|
@@ -1,18 +1,27 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: Pushes VPC Flow Log metrics to Datadog. | ||
Parameters: | ||
KMSKeyId: | ||
Type: String | ||
Description: The id (final part of the key's ARN) of a KMS key used to encrypt and decrypt your Datadog API and App keys. | ||
Resources: | ||
vpcflowlambdaddfunction: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
Description: Pushes VPC Flow Log metrics to Datadog. | ||
Environment: | ||
Variables: | ||
kmsEncryptedKeys: YOUR_KEY | ||
kmsEncryptedKeys: 'YOUR_KEY' | ||
Handler: lambda_function.lambda_handler | ||
MemorySize: 128 | ||
Policies: | ||
KMSDecryptPolicy: | ||
KeyId: YOUR_KEY | ||
KeyId: !Ref KMSKeyId | ||
Runtime: python2.7 | ||
Timeout: 10 | ||
KmsKeyArn: | ||
!Sub | ||
- 'arn:${AWS::Partition}:kms:${AWS::Region}:${AWS::AccountId}:key/${keyId}' | ||
- {keyId: !Ref KMSKeyId} | ||
Type: AWS::Serverless::Function | ||
Transform: AWS::Serverless-2016-10-31 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeikenberry thinking of having Terraform map variable impact the default metadata on each of these logs...is this the right python code to support that?