-
Notifications
You must be signed in to change notification settings - Fork 6
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 #4 from clouddrove/improvement
Improvement
- Loading branch information
Showing
11 changed files
with
301 additions
and
0 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
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,9 @@ | ||
## Managed By : CloudDrove | ||
## Copyright @ CloudDrove. All Right Reserved. | ||
|
||
|
||
resource "aws_ebs_encryption_by_default" "default" { | ||
count = var.enabled ? 1 : 0 | ||
|
||
enabled = true | ||
} |
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 @@ | ||
variable "enabled" { | ||
description = "The boolean flag whether this module is enabled or not. No resources are created when set to false." | ||
default = true | ||
} |
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,44 @@ | ||
data "aws_region" "current" {} | ||
|
||
# Enable SecurityHub | ||
resource "aws_securityhub_account" "main" { | ||
count = var.enabled ? 1 : 0 | ||
} | ||
|
||
# Add member accounts | ||
resource "aws_securityhub_member" "members" { | ||
count = var.enabled ? length(var.member_accounts) : 0 | ||
|
||
depends_on = [aws_securityhub_account.main] | ||
account_id = var.member_accounts[count.index].account_id | ||
email = var.member_accounts[count.index].email | ||
invite = true | ||
} | ||
|
||
# Subscribe CIS benchmark | ||
resource "aws_securityhub_standards_subscription" "cis" { | ||
count = var.enabled && var.enable_ccis_standard ? 1 : 0 | ||
|
||
standards_arn = "arn:aws:securityhub:::ruleset/cis-aws-foundations-benchmark/v/1.2.0" | ||
|
||
depends_on = [aws_securityhub_account.main] | ||
} | ||
|
||
# Subscribe AWS foundational security best practices standard | ||
resource "aws_securityhub_standards_subscription" "aws_foundational" { | ||
count = var.enabled && var.enable_aws_foundational_standard ? 1 : 0 | ||
|
||
standards_arn = "arn:aws:securityhub:${data.aws_region.current.name}::standards/aws-foundational-security-best-practices/v/1.0.0" | ||
|
||
depends_on = [aws_securityhub_account.main] | ||
} | ||
|
||
# Subscribe PCI DSS standard | ||
resource "aws_securityhub_standards_subscription" "pci_dss" { | ||
count = var.enabled && var.enable_pci_dss_standard ? 1 : 0 | ||
|
||
standards_arn = "arn:aws:securityhub:${data.aws_region.current.name}::standards/pci-dss/v/3.2.1" | ||
|
||
depends_on = [aws_securityhub_account.main] | ||
} | ||
|
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,28 @@ | ||
variable "enabled" { | ||
description = "The boolean flag whether this module is enabled or not. No resources are created when set to false." | ||
default = true | ||
} | ||
|
||
variable "enable_cis_standard" { | ||
description = "Boolean whether CIS standard is enabled." | ||
default = true | ||
} | ||
|
||
variable "enable_pci_dss_standard" { | ||
description = "Boolean whether PCI DSS standard is enabled." | ||
default = true | ||
} | ||
|
||
variable "enable_aws_foundational_standard" { | ||
description = "Boolean whether AWS Foundations standard is enabled." | ||
default = true | ||
} | ||
|
||
variable "member_accounts" { | ||
description = "A list of IDs and emails of AWS accounts which associated as member accounts." | ||
type = list(object({ | ||
account_id = string | ||
email = string | ||
})) | ||
default = [] | ||
} |
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,26 @@ | ||
## Managed By : CloudDrove | ||
## Copyright @ CloudDrove. All Right Reserved. | ||
|
||
|
||
#Module : Label | ||
#Description : This terraform module is designed to generate consistent label names and | ||
# tags for resources. You can use terraform-labels to implement a strict | ||
# naming convention | ||
module "labels" { | ||
source = "clouddrove/labels/aws" | ||
version = "0.15.0" | ||
|
||
name = var.name | ||
environment = var.environment | ||
label_order = var.label_order | ||
managedby = var.managedby | ||
} | ||
|
||
|
||
resource "aws_shield_protection" "default" { | ||
count = var.enabled ? 1 : 0 | ||
name = format("%s-shield", module.labels.id) | ||
resource_arn = var.resource_arn | ||
tags = module.labels.tags | ||
|
||
} |
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,9 @@ | ||
output "id" { | ||
value = join("", aws_shield_protection.default.*.id) | ||
description = "The unique identifier (ID) for the Protection object that is created." | ||
} | ||
|
||
output "arn" { | ||
value = join("", aws_shield_protection.default.*.arn) | ||
description = "The unique identifier (ID) for the Protection object that is created." | ||
} |
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,55 @@ | ||
#Module : LABEL | ||
#Description : Terraform label module variables. | ||
variable "name" { | ||
type = string | ||
default = "" | ||
description = "Name (e.g. `app` or `cluster`)." | ||
} | ||
|
||
variable "environment" { | ||
type = string | ||
default = "" | ||
description = "Environment (e.g. `prod`, `dev`, `staging`)." | ||
} | ||
|
||
variable "label_order" { | ||
type = list(any) | ||
default = [] | ||
description = "Label order, e.g. `name`,`application`." | ||
} | ||
|
||
variable "attributes" { | ||
type = list(any) | ||
default = [] | ||
description = "Additional attributes (e.g. `1`)." | ||
} | ||
|
||
variable "delimiter" { | ||
type = string | ||
default = "-" | ||
description = "Delimiter to be used between `organization`, `environment`, `name` and `attributes`." | ||
} | ||
|
||
variable "tags" { | ||
type = map(any) | ||
default = {} | ||
description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)." | ||
} | ||
|
||
variable "enabled" { | ||
type = bool | ||
default = true | ||
description = "The boolean flag whether this module is enabled or not. No resources are created when set to false." | ||
} | ||
|
||
variable "shield_name" { | ||
type = string | ||
default = "" | ||
description = "A friendly name for the Protection you are creating." | ||
} | ||
|
||
variable "resource_arn" { | ||
type = string | ||
default = "" | ||
description = "The ARN (Amazon Resource Name) of the resource to be protected." | ||
} |
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