generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 3
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 #627 from ministryofjustice/feature/8076-unit-tests
Add unit tests for securityhub module
- Loading branch information
Showing
11 changed files
with
160 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
output "sechub_eventbridge_rule_arn" { | ||
description = "The ARN of the SecurityHub EventBridge rule" | ||
value = aws_cloudwatch_event_rule.sechub_high_and_critical_findings.arn | ||
} | ||
output "sechub_sns_topic_arn" { | ||
description = "The ARN of the SecurityHub SNS topic" | ||
value = aws_sns_topic.sechub_findings_sns_topic.arn | ||
} | ||
|
||
output "sechub_sns_kms_key_arn" { | ||
description = "The ARN of the SecurityHub SNS Topic KMS key" | ||
value = aws_kms_key.sns_kms_key.arn | ||
} |
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,17 @@ | ||
variable "sechub_eventbridge_rule_name" { | ||
description = "SecurityHub Eventbridge rule name" | ||
default = "sechub_high_and_critical_findings" | ||
type = string | ||
} | ||
|
||
variable "sechub_sns_topic_name" { | ||
description = "SecurityHub SNS Topic name" | ||
default = "sechub_findings_sns_topic" | ||
type = string | ||
} | ||
|
||
variable "sechub_sns_kms_key_name" { | ||
description = "SecurityHub SNS Topic KMS key name" | ||
default = "alias/sns-kms-key" | ||
type = string | ||
} |
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,3 @@ | ||
locals { | ||
environment_management = jsondecode(data.aws_secretsmanager_secret_version.environment_management.secret_string) | ||
} |
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,6 @@ | ||
module "securityhub-test" { | ||
source = "../../modules/securityhub" | ||
sechub_eventbridge_rule_name = var.sechub_eventbridge_rule_name | ||
sechub_sns_topic_name = var.sechub_sns_topic_name | ||
sechub_sns_kms_key_name = var.sechub_sns_kms_key_name | ||
} |
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,13 @@ | ||
output "sechub_eventbridge_rule_arn" { | ||
description = "The ARN of the SecurityHub EventBridge rule" | ||
value = module.securityhub-test.sechub_eventbridge_rule_arn | ||
} | ||
output "sechub_sns_topic_arn" { | ||
description = "The ARN of the SecurityHub SNS topic" | ||
value = module.securityhub-test.sechub_sns_topic_arn | ||
} | ||
|
||
output "sechub_sns_kms_key_arn" { | ||
description = "The ARN of the SecurityHub SNS Topic KMS key" | ||
value = module.securityhub-test.sechub_sns_kms_key_arn | ||
} |
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,13 @@ | ||
# AWS provider for the workspace you're working in (every resource will default to using this, unless otherwise specified) | ||
provider "aws" { | ||
region = "eu-west-2" | ||
assume_role { | ||
role_arn = "arn:aws:iam::${local.environment_management.account_ids["testing-test"]}:role/MemberInfrastructureAccess" | ||
} | ||
} | ||
|
||
# AWS provider for the testing-ci user (testing-test account), to get things from there if required | ||
provider "aws" { | ||
alias = "testing-ci-user" | ||
region = "eu-west-2" | ||
} |
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,16 @@ | ||
# Get secret by arn for environment management | ||
data "aws_ssm_parameter" "environment_management_arn" { | ||
provider = aws.testing-ci-user | ||
name = "environment_management_arn" | ||
} | ||
|
||
data "aws_secretsmanager_secret" "environment_management" { | ||
provider = aws.testing-ci-user | ||
arn = data.aws_ssm_parameter.environment_management_arn.value | ||
} | ||
|
||
# Get latest secret value with ID from above. This secret stores account IDs for the Modernisation Platform sub-accounts | ||
data "aws_secretsmanager_secret_version" "environment_management" { | ||
provider = aws.testing-ci-user | ||
secret_id = data.aws_secretsmanager_secret.environment_management.id | ||
} |
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,17 @@ | ||
variable "sechub_eventbridge_rule_name" { | ||
description = "SecurityHub Eventbridge rule name" | ||
default = "sechub_high_and_critical_findings" | ||
type = string | ||
} | ||
|
||
variable "sechub_sns_topic_name" { | ||
description = "SecurityHub SNS Topic name" | ||
default = "sechub_findings_sns_topic" | ||
type = string | ||
} | ||
|
||
variable "sechub_sns_kms_key_name" { | ||
description = "SecurityHub SNS Topic KMS key name" | ||
default = "alias/sns-kms-key" | ||
type = string | ||
} |
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,13 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
version = "~> 5.0" | ||
source = "hashicorp/aws" | ||
} | ||
http = { | ||
version = "~> 3.0" | ||
source = "hashicorp/http" | ||
} | ||
} | ||
required_version = "~> 1.0" | ||
} |