generated from clouddrove/terraform-module-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.
Feat: 🚀 Add example for ECR Cloudwatch dashboard (#7)
* feat: added example for ecr dashboard and did changes in readme * feat: update terraform version to latest * feat: update dynamic value for ecr dashboard body * feat: added zip fileh and updated output in examples --------- Co-authored-by: Anmol Nagpal <anmol@clouddrove.com>
- Loading branch information
1 parent
4fd4f6a
commit d2d09d9
Showing
14 changed files
with
215 additions
and
137 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,36 @@ | ||
# ignored files | ||
*.tfstate | ||
*.tfstate.backup | ||
.terraform | ||
.idea | ||
*.iml | ||
go.sum | ||
*.terraform.lock.hcl | ||
|
||
################################################################# | ||
# Default .gitignore content for all terraform-aws-modules below | ||
################################################################# | ||
|
||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# Terraform lockfile | ||
**/*.terraform.lock.hcl | ||
|
||
# .tfstate files | ||
**/*.tfstate | ||
**/*.tfstate.* | ||
**/*.tfplan | ||
|
||
# Crash log files | ||
crash.log | ||
|
||
# Exclude all .tfvars files, which are likely to contain sentitive data, such as | ||
# password, private keys, and other secrets. These should not be part of version | ||
# control as they are data points which are potentially sensitive and subject | ||
# to change depending on the environment. | ||
**/*.tfvars | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
# Ignore CLI configuration files | ||
.terraformrc | ||
terraform.rc |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "dashboard_arn" { | ||
description = "The Amazon Resource Name (ARN) of the dashboard" | ||
value = module.cloudwatch_dashboard.dashboard_arn | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"start": "-P1M", | ||
"widgets": [ | ||
{ | ||
"type": "log", | ||
"x": 0, | ||
"y": 0, | ||
"width": 24, | ||
"height": 6, | ||
"properties": { | ||
"query": "SOURCE '${log-group}' | filter eventName = 'BatchGetImage'\n\n\n\n | fields @timestamp, @message\n\n\n\n | stats count(*) as apiCalls by userIdentity.accountId as accountId,\n\nrequestParameters.repositoryName as repository\n| sort accountId desc", | ||
"region": "${region}", | ||
"title": "Images per Accounts", | ||
"view": "table" | ||
} | ||
}, | ||
{ | ||
"type": "log", | ||
"x": 0, | ||
"y": 6, | ||
"width": 12, | ||
"height": 6, | ||
"properties": { | ||
"query": "SOURCE '${log-group}' | filter eventName = 'BatchGetImage'\n\n\n\n\n\n\n\n | fields @timestamp, @message\n\n\n\n\n\n\n\n | stats count_distinct(requestParameters.repositoryName) as Images by\nuserIdentity.accountId as accountId\n\n\n| sort Images desc", | ||
"region": "${region}", | ||
"title": "Usage by Accounts", | ||
"view": "pie", | ||
"legend": { | ||
"position": "left" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "log", | ||
"x": 12, | ||
"y": 6, | ||
"width": 12, | ||
"height": 6, | ||
"properties": { | ||
"query": "SOURCE '${log-group}' | filter eventName = 'BatchGetImage'\n\n\n\n\n\n\n\n | fields @timestamp, @message\n\n\n\n\n\n\n\n | stats count_distinct(userIdentity.accountId) as Accounts by requestParameters.repositoryName as imageName \n\n\n| sort Accounts desc", | ||
"region": "${region}", | ||
"title": "ECR Repositories Usage", | ||
"view": "pie", | ||
"legend": { | ||
"position": "left" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "log", | ||
"x": 0, | ||
"y": 12, | ||
"width": 24, | ||
"height": 6, | ||
"properties": { | ||
"query": "SOURCE '${log-group}' | filter eventName = 'BatchGetImage'\n\n\n\n | fields @timestamp, @message\n\n\n\n | stats count(*) as apiCalls by userIdentity.accountId as accountId,\n\nrequestParameters.repositoryName as repository, coalesce(requestParameters.imageIds.0.imageTag, requestParameters.imageIds.0.imageDigest) as tag\n| sort accountId desc", | ||
"region": "${region}", | ||
"title": "Images and tags per accounts", | ||
"view": "table" | ||
} | ||
} | ||
] | ||
} |
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,38 @@ | ||
provider "aws" { | ||
region = local.region | ||
} | ||
|
||
locals { | ||
name = "dashboard" | ||
environment = "test" | ||
region = "us-east-1" | ||
} | ||
|
||
##----------------------------------------------------------------------------- | ||
## Private ECR. | ||
##----------------------------------------------------------------------------- | ||
module "private_ecr" { | ||
source = "clouddrove/ecr/aws" | ||
version = "1.3.2" | ||
|
||
enable_private_ecr = true | ||
name = format("%s-private-ecr",local.name) | ||
environment = local.environment | ||
scan_on_push = true | ||
max_image_count = 7 | ||
} | ||
|
||
##----------------------------------------------------------------------------- | ||
## CLOUDWATCH DASHBOARD | ||
##----------------------------------------------------------------------------- | ||
module "cloudwatch_dashboard" { | ||
source = "../../" | ||
|
||
enable = true | ||
name = local.name | ||
environment = local.environment | ||
dashboard_body = templatefile("${path.module}/ecr_dashboard.json", { | ||
region = local.region | ||
log-group = "cloudtrail-log-group" # Log group of the cloudtrail or log group name where the ECR history/API Calls is stored | ||
}) | ||
} |
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,4 @@ | ||
output "dashboard_arn" { | ||
description = "The Amazon Resource Name (ARN) of the dashboard" | ||
value = module.cloudwatch_dashboard.dashboard_arn | ||
} |
This file was deleted.
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
Oops, something went wrong.