Skip to content

Commit 5942403

Browse files
author
Qingping Hou
committed
initial public release
0 parents  commit 5942403

File tree

16 files changed

+1535
-0
lines changed

16 files changed

+1535
-0
lines changed

.github/workflows/terraform.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 'Terraform GitHub Actions'
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
terraform:
11+
name: 'Terraform'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: 'Checkout'
15+
uses: actions/checkout@master
16+
17+
- name: 'Terraform Format'
18+
uses: hashicorp/terraform-github-actions@master
19+
with:
20+
tf_actions_version: 0.12.20
21+
tf_actions_subcommand: 'fmt'
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
- name: 'Terraform Init'
25+
uses: hashicorp/terraform-github-actions@master
26+
with:
27+
tf_actions_version: 0.12.20
28+
tf_actions_subcommand: 'init'
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: 'Inject provider configs for validate command'
33+
run: |
34+
cat > providers.tf <<EOF
35+
provider "aws" {
36+
region = "us-east-2"
37+
}
38+
39+
provider "datadog" {
40+
api_key = ""
41+
app_key = ""
42+
}
43+
EOF
44+
- name: 'Terraform Validate'
45+
uses: hashicorp/terraform-github-actions@master
46+
with:
47+
tf_actions_version: 0.12.20
48+
tf_actions_subcommand: 'validate'
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
*.tfstate
5+
*.tfstate.*
6+
7+
.idea/

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CHANGELOG
2+
3+
<!--- next entry here -->
4+
5+
- Initial public release

LICENSE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
BSD 0-CLAUSE LICENSE
2+
3+
Copyright 2020 Scribd. Inc.
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14+
PERFORMANCE OF THIS SOFTWARE.

README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# terraform-aws-datadog
2+
3+
Terraform module which sets up various AWS / Datadog integrations including:
4+
5+
- Configure Datadog's builtin AWS integration
6+
- Configure Cloudtrail logshipping
7+
- Create ELB S3 bucket for logs and logshipping
8+
- Sync Cloudwatch logs for a given list of log groups
9+
10+
11+
## Usage
12+
13+
**Set up all supported AWS / Datadog integrations**
14+
15+
```
16+
module "datadog" {
17+
source = "git::https://github.com/scribd/terraform-aws-datadog.git?ref=master"
18+
aws_account_id = data.aws_caller_identity.current.account_id
19+
datadog_api_key = var.datadog_api_key
20+
21+
cloudtrail_bucket_id = aws_s3_bucket.org-cloudtrail-bucket.id
22+
cloudtrail_bucket_arn = aws_s3_bucket.org-cloudtrail-bucket.arn
23+
24+
cloudwatch_log_groups = ["cloudwatch_log_group_1", "cloudwatch_log_group_2"]
25+
}
26+
```
27+
28+
Note: The full integration setup should only be done within one terraform stack
29+
per account since some of the resources it creates are global per account.
30+
Creating this module in multiple terraform stacks will cause conflicts.
31+
32+
33+
**Limit to only Cloudwatch log sync**
34+
35+
```
36+
module "datadog" {
37+
source = "git::https://github.com/scribd/terraform-aws-datadog.git?ref=master"
38+
datadog_api_key = var.datadog_api_key
39+
create_elb_logs_bucket = false
40+
enable_datadog_aws_integration = false
41+
cloudwatch_log_groups = ["cloudwatch_log_group_1", "cloudwatch_log_group_2"]
42+
}
43+
```
44+
45+
Note: It is safe to create multiple Cloudwatch only modules across different
46+
Terraform stacks within a single AWS account since all resouces used for
47+
Cloudwatch log sync are namspaced by module.
48+
49+
50+
## Examples
51+
52+
* [Full AWS Datadog integration](https://github.com/scribd/terraform-aws-datadog/tree/master/examples/full_integration)
53+
* [Cloudwatch log sync only](https://github.com/scribd/terraform-aws-datadog/tree/master/examples/cloudwatch_log_sync)
54+
55+
56+
## Development
57+
58+
Releases are cut using [go-semrel-gitlab](https://gitlab.com/juhani/go-semrel-gitlab)
59+
60+
Format commit messages using [Conventional Commits format](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) to determine the next version bump and to produce release notes
61+
62+
```
63+
type(scope): subject
64+
```
65+
or
66+
67+
```
68+
type: subject
69+
```
70+
71+
Types:
72+
```
73+
minor bump: feat
74+
patch bump: fix,refactor,perf,docs,style,tes
75+
```
76+
77+
When a commit contains a breaking change, the commit message should contain `BREAKING CHANGE:`
78+
79+
80+
## Cutting a release
81+
82+
### Maintainers
83+
- [Jim](https://github.com/jim80net)
84+
- [QP](https://github.com/houqp)
85+
86+
## Troubleshooting
87+
88+
If you should encounter `Datadog is not authorized to perform action sts:AssumeRole Accounts affected: 1234567890, 1234567891 Regions affected: every region Errors began reporting 18m ago, last seen 5m ago`
89+
Then perhaps the external ID has changed. Execute `./terraform taint module.datadog.datadog_integration_aws.core[0]` in the root module of the account repo to force a refresh.

examples/cloudwatch_log_sync/main.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
variable dd_api_key {
2+
type = string
3+
default = "1234567890"
4+
}
5+
6+
variable dd_app_key {
7+
type = string
8+
default = "1234567890"
9+
}
10+
11+
variable aws_region {
12+
type = string
13+
default = "us-west-2"
14+
}
15+
16+
provider "datadog" {
17+
api_key = var.dd_api_key
18+
app_key = var.dd_app_key
19+
}
20+
21+
provider "aws" {
22+
region = var.aws_region
23+
}
24+
25+
module "datadog" {
26+
source = "../.."
27+
datadog_api_key = var.dd_api_key
28+
aws_region = var.aws_region
29+
create_elb_logs_bucket = false
30+
enable_datadog_aws_integration = false
31+
cloudwatch_log_groups = ["cloudwatch_log_group_1", "cloudwatch_log_group_2"]
32+
}

examples/full_integration/main.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
variable dd_api_key {
2+
type = string
3+
default = "1234567890"
4+
}
5+
6+
variable dd_app_key {
7+
type = string
8+
default = "1234567890"
9+
}
10+
11+
variable aws_region {
12+
type = string
13+
default = "us-west-2"
14+
}
15+
16+
provider "datadog" {
17+
api_key = var.dd_api_key
18+
app_key = var.dd_app_key
19+
}
20+
21+
provider "aws" {
22+
region = var.aws_region
23+
}
24+
25+
module "datadog" {
26+
source = "../.."
27+
aws_region = var.aws_region
28+
datadog_api_key = var.dd_api_key
29+
datadog_app_key = var.dd_app_key
30+
aws_account_id = data.aws_caller_identity.current.account_id
31+
32+
cloudtrail_bucket_id = "S3_BUCKET_ID"
33+
cloudtrail_bucket_arn = "S3_BUCKET_ARN"
34+
35+
cloudwatch_log_groups = ["cloudwatch_log_group_1", "cloudwatch_log_group_2"]
36+
}

0 commit comments

Comments
 (0)