Skip to content
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

Updated SSL policy used in listeners to use secure TLS protocols #6162

Merged
merged 1 commit into from
May 20, 2024

Conversation

dms1981
Copy link
Contributor

@dms1981 dms1981 commented May 20, 2024

I noted that a number of MP-provided environments in this repository are not using secure TLS policies. This PR updates the configuration to use secure listeners. From some investigation, it appears that when a policy is not specified in Terraform, it defaults to using ELBSecurityPolicy-2016-08 as discussed here.

@dms1981 dms1981 requested review from a team as code owners May 20, 2024 10:59
@github-actions github-actions bot added the environments-repository Used to exclude PRs from this repo in our Slack PR update label May 20, 2024
Copy link
Contributor

Trivy Scan Failed

Show Output ```hcl

Trivy will check the following folders:
terraform/environments/cooker terraform/environments/example terraform/environments/sprinkler


Running Trivy in terraform/environments/cooker
2024-05-20T11:02:06Z INFO Need to update DB
2024-05-20T11:02:06Z INFO Downloading DB... repository="ghcr.io/aquasecurity/trivy-db:2"
2024-05-20T11:02:08Z INFO Vulnerability scanning is enabled
2024-05-20T11:02:08Z INFO Misconfiguration scanning is enabled
2024-05-20T11:02:08Z INFO Need to update the built-in policies
2024-05-20T11:02:08Z INFO Downloading the built-in policies...
50.41 KiB / 50.41 KiB [-----------------------------------------------------------] 100.00% ? p/s 0s2024-05-20T11:02:09Z INFO Secret scanning is enabled
2024-05-20T11:02:09Z INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-05-20T11:02:09Z INFO Please see also https://aquasecurity.github.io/trivy/v0.51/docs/scanner/secret/#recommendation for faster secret detection
2024-05-20T11:02:09Z INFO Number of language-specific files num=0
2024-05-20T11:02:09Z INFO Detected config files num=2

main.tf (terraform)

Tests: 20 (SUCCESSES: 13, FAILURES: 6, EXCEPTIONS: 1)
Failures: 6 (HIGH: 4, CRITICAL: 2)

HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.

By setting drop_invalid_header_fields to true, anything that doe not conform to well known, defined headers will be removed by the load balancer.

See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
main.tf:408-423
────────────────────────────────────────
408 ┌ resource "aws_lb" "external" {
409 │
410 │ name = "external-${var.networking[0].application}"
411 │ internal = false
412 │ load_balancer_type = "application"
413 │ security_groups = [aws_security_group.external_lb.id]
414 │ subnets = data.aws_subnets.shared-public.ids
415 │ enable_deletion_protection = false
416 └
...
────────────────────────────────────────

HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.

By setting drop_invalid_header_fields to true, anything that doe not conform to well known, defined headers will be removed by the load balancer.

See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
main.tf:548-563
────────────────────────────────────────
548 ┌ resource "aws_lb" "inner" {
549 │
550 │ name = "inner-${var.networking[0].application}"
551 │ internal = true
552 │ load_balancer_type = "application"
553 │ security_groups = [aws_security_group.inner_lb.id]
554 │ subnets = data.aws_subnets.shared-private.ids
555 │ enable_deletion_protection = false
556 └
...
────────────────────────────────────────

HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.

See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
main.tf:411
via main.tf:408-423 (aws_lb.external)
────────────────────────────────────────
408 resource "aws_lb" "external" {
...
411 [ internal = false
...
423 }
────────────────────────────────────────

HIGH: Instance does not have storage encryption enabled.
════════════════════════════════════════
Encryption should be enabled for an RDS Database instances.

When enabling encryption by setting the kms_key_id.

See https://avd.aquasec.com/misconfig/avd-aws-0080
────────────────────────────────────────
main.tf:703-723
────────────────────────────────────────
703 ┌ resource "aws_db_instance" "app" {
704 │
705 │ identifier = var.networking[0].application
706 │ allocated_storage = local.application_data.accounts[local.environment].rds_storage
707 │ engine = "postgres"
708 │ engine_version = local.application_data.accounts[local.environment].rds_postgresql_version
709 │ instance_class = local.application_data.accounts[local.environment].rds_instance_class
710 │ db_name = var.networking[0].application
711 └ username = "dbmain"
...
────────────────────────────────────────

CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
main.tf:97
via main.tf:90-98 (aws_security_group_rule.app_egress_1)
────────────────────────────────────────
90 resource "aws_security_group_rule" "app_egress_1" {
91
92 security_group_id = aws_security_group.app.id
93 type = "egress"
94 from_port = 0
95 to_port = 0
96 protocol = -1
97 [ cidr_blocks = ["0.0.0.0/0"]
98 }
────────────────────────────────────────

CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
main.tf:657
via main.tf:650-658 (aws_security_group_rule.rds_egress_1)
────────────────────────────────────────
650 resource "aws_security_group_rule" "rds_egress_1" {
651
652 security_group_id = aws_security_group.rds.id
653 type = "egress"
654 from_port = 0
655 to_port = 0
656 protocol = -1
657 [ cidr_blocks = ["0.0.0.0/0"]
658 }
────────────────────────────────────────

trivy_exitcode=1


Running Trivy in terraform/environments/example
2024-05-20T11:02:10Z INFO Vulnerability scanning is enabled
2024-05-20T11:02:10Z INFO Misconfiguration scanning is enabled
2024-05-20T11:02:10Z INFO Secret scanning is enabled
2024-05-20T11:02:10Z INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-05-20T11:02:10Z INFO Please see also https://aquasecurity.github.io/trivy/v0.51/docs/scanner/secret/#recommendation for faster secret detection
2024-05-20T11:02:17Z INFO Number of language-specific files num=0
2024-05-20T11:02:17Z INFO Detected config files num=16

ec2.tf (terraform)

Tests: 8 (SUCCESSES: 5, FAILURES: 0, EXCEPTIONS: 3)
Failures: 0 (HIGH: 0, CRITICAL: 0)

ec2_autoscaling_group.tf (terraform)

Tests: 2 (SUCCESSES: 0, FAILURES: 0, EXCEPTIONS: 2)
Failures: 0 (HIGH: 0, CRITICAL: 0)

ec2_complete.tf (terraform)

Tests: 3 (SUCCESSES: 2, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (HIGH: 0, CRITICAL: 1)

CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
ec2_complete.tf:235
via ec2_complete.tf:227-236 (aws_security_group_rule.complete_egress_traffic["TCP_ALL"])
────────────────────────────────────────
227 resource "aws_security_group_rule" "complete_egress_traffic" {
228 for_each = local.complete_ec2_sg_egress_rules
229 description = format("Outbound traffic for %s %d", each.value.protocol, each.value.from_port)
230 from_port = each.value.from_port
231 protocol = each.value.protocol
232 security_group_id = aws_security_group.example_ec2_sg.id
233 to_port = each.value.to_port
234 type = "egress"
235 [ cidr_blocks = [each.value.cidr_block]
236 }
────────────────────────────────────────

ecs.tf (terraform)

Tests: 5 (SUCCESSES: 3, FAILURES: 1, EXCEPTIONS: 1)
Failures: 1 (HIGH: 0, CRITICAL: 1)

CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
ecs.tf:209
via ecs.tf:204-211 (content)
via ecs.tf:202-212 (dynamic.egress["cluster_ec2_lb_egress"])
via ecs.tf:186-214 (aws_security_group.cluster_ec2)
────────────────────────────────────────
186 resource "aws_security_group" "cluster_ec2" {
...
209 [ cidr_blocks = lookup(egress.value, "cidr_blocks", null)
...
214 }
────────────────────────────────────────

github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=95ed3c3f454e2014a62990aacd5d68c64d026f11/main.tf (terraform)

Tests: 7 (SUCCESSES: 5, FAILURES: 0, EXCEPTIONS: 2)
Failures: 0 (HIGH: 0, CRITICAL: 0)

github.com/ministryofjustice/modernisation-platform-terraform-ec2-autoscaling-group?ref=03913ac182decfc8224923520439d53d7c930661/main.tf (terraform)

Tests: 2 (SUCCESSES: 1, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (HIGH: 1, CRITICAL: 0)

HIGH: Launch template does not require IMDS access to require a token
════════════════════════════════════════

IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.

See https://avd.aquasec.com/misconfig/avd-aws-0130
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-ec2-autoscaling-group?ref=03913ac182decfc8224923520439d53d7c930661/main.tf:44
via github.com/ministryofjustice/modernisation-platform-terraform-ec2-autoscaling-group?ref=03913ac182decfc8224923520439d53d7c930661/main.tf:40-45 (metadata_options)
via github.com/ministryofjustice/modernisation-platform-terraform-ec2-autoscaling-group?ref=03913ac182decfc8224923520439d53d7c930661/main.tf:1-99 (aws_launch_template.this)
via ec2_autoscaling_group.tf:1-29 (module.ec2_test_autoscaling_group["dev-rh-rhel79"])
────────────────────────────────────────
1 resource "aws_launch_template" "this" {
.
44 [ http_tokens = coalesce(var.instance.metadata_options_http_tokens, "required")
..
99 }
────────────────────────────────────────

github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf (terraform)

Tests: 14 (SUCCESSES: 12, FAILURES: 2, EXCEPTIONS: 0)
Failures: 2 (HIGH: 2, CRITICAL: 0)

HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:9-64 (module.s3-bucket[0])
via ecs.tf:115-134 (module.ecs_lb_access_logs_enabled)
────────────────────────────────────────
171 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
172 │ bucket = aws_s3_bucket.default.id
173 │ rule {
174 │ apply_server_side_encryption_by_default {
175 │ sse_algorithm = var.sse_algorithm
176 │ kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
177 │ }
178 │ }
179 └ }
────────────────────────────────────────

HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:9-64 (module.s3-bucket[0])
via loadbalancer_module.tf:2-21 (module.lb_access_logs_enabled)
────────────────────────────────────────
171 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
172 │ bucket = aws_s3_bucket.default.id
173 │ rule {
174 │ apply_server_side_encryption_by_default {
175 │ sse_algorithm = var.sse_algorithm
176 │ kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
177 │ }
178 │ }
179 └ }
────────────────────────────────────────

github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf (terraform)

Tests: 16 (SUCCESSES: 10, FAILURES: 4, EXCEPTIONS: 2)
Failures: 4 (HIGH: 2, CRITICAL: 2)

HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.

See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:148
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:144-175 (aws_lb.loadbalancer)
via ecs.tf:115-134 (module.ecs_lb_access_logs_enabled)
────────────────────────────────────────
144 resource "aws_lb" "loadbalancer" {
...
148 [ internal = var.internal_lb
...
175 }
────────────────────────────────────────

HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.

See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:148
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:144-175 (aws_lb.loadbalancer)
via loadbalancer_module.tf:2-21 (module.lb_access_logs_enabled)
────────────────────────────────────────
144 resource "aws_lb" "loadbalancer" {
...
148 [ internal = var.internal_lb
...
175 }
────────────────────────────────────────

CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:202
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:197-204 (content)
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:195-205 (dynamic.egress["cluster_ec2_lb_egress"])
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:177-213 (aws_security_group.lb[0])
via ecs.tf:115-134 (module.ecs_lb_access_logs_enabled)
────────────────────────────────────────
177 resource "aws_security_group" "lb" {
...
202 [ cidr_blocks = lookup(egress.value, "cidr_blocks", null)
...
213 }
────────────────────────────────────────

CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:202
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:197-204 (content)
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:195-205 (dynamic.egress["cluster_ec2_lb_egress"])
via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:177-213 (aws_security_group.lb[0])
via loadbalancer_module.tf:2-21 (module.lb_access_logs_enabled)
────────────────────────────────────────
177 resource "aws_security_group" "lb" {
...
202 [ cidr_blocks = lookup(egress.value, "cidr_blocks", null)
...
213 }
────────────────────────────────────────

github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf (terraform)

Tests: 14 (SUCCESSES: 12, FAILURES: 2, EXCEPTIONS: 0)
Failures: 2 (HIGH: 2, CRITICAL: 0)

HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179
via s3.tf:8-72 (module.s3-bucket)
────────────────────────────────────────
171 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
172 │ bucket = aws_s3_bucket.default.id
173 │ rule {
174 │ apply_server_side_encryption_by_default {
175 │ sse_algorithm = var.sse_algorithm
176 │ kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
177 │ }
178 │ }
179 └ }
────────────────────────────────────────

HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179
via loadbalancer.tf:185-248 (module.s3-bucket-lb)
────────────────────────────────────────
171 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
172 │ bucket = aws_s3_bucket.default.id
173 │ rule {
174 │ apply_server_side_encryption_by_default {
175 │ sse_algorithm = var.sse_algorithm
176 │ kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
177 │ }
178 │ }
179 └ }
────────────────────────────────────────

loadbalancer.tf (terraform)

Tests: 7 (SUCCESSES: 5, FAILURES: 1, EXCEPTIONS: 1)
Failures: 1 (HIGH: 1, CRITICAL: 0)

HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.

See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
loadbalancer.tf:328-345
────────────────────────────────────────
328 ┌ resource "aws_instance" "lb_example_instance" {
329 │ #checkov:skip=CKV2_AWS_41:"IAM role is not implemented for this example EC2. SSH/AWS keys are not used either."
330 │ #checkov:skip=CKV_AWS_8: "Encryption not required for example instance"
331 │ # Specify the instance type and ami to be used (this is the Amazon free tier option)
332 │ instance_type = local.application_data.accounts[local.environment].instance_type
333 │ ami = local.application_data.accounts[local.environment].ami_image_id
334 │ vpc_security_group_ids = [aws_security_group.example_load_balancer_sg.id]
335 │ subnet_id = data.aws_subnet.private_subnets_a.id
336 └ monitoring = true
...
────────────────────────────────────────

trivy_exitcode=2


Running Trivy in terraform/environments/sprinkler
2024-05-20T11:02:17Z INFO Vulnerability scanning is enabled
2024-05-20T11:02:17Z INFO Misconfiguration scanning is enabled
2024-05-20T11:02:17Z INFO Secret scanning is enabled
2024-05-20T11:02:17Z INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-05-20T11:02:17Z INFO Please see also https://aquasecurity.github.io/trivy/v0.51/docs/scanner/secret/#recommendation for faster secret detection
2024-05-20T11:02:21Z INFO Number of language-specific files num=0
2024-05-20T11:02:21Z INFO Detected config files num=9

db_manager.tf (terraform)

Tests: 9 (SUCCESSES: 4, FAILURES: 0, EXCEPTIONS: 5)
Failures: 0 (HIGH: 0, CRITICAL: 0)

github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.1/main.tf (terraform)

Tests: 7 (SUCCESSES: 5, FAILURES: 0, EXCEPTIONS: 2)
Failures: 0 (HIGH: 0, CRITICAL: 0)

github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.0.0/main.tf (terraform)

Tests: 7 (SUCCESSES: 6, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (HIGH: 1, CRITICAL: 0)

HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.0.0/main.tf:157-165
via github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0/main.tf:3-57 (module.s3-bucket[0])
via ssm.tf:1-17 (module.ssm-auto-patching)
────────────────────────────────────────
157 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
158 │ bucket = aws_s3_bucket.default.id
159 │ rule {
160 │ apply_server_side_encryption_by_default {
161 │ sse_algorithm = var.sse_algorithm
162 │ kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
163 │ }
164 │ }
165 └ }
────────────────────────────────────────

github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0/main.tf (terraform)

Tests: 2 (SUCCESSES: 0, FAILURES: 0, EXCEPTIONS: 2)
Failures: 0 (HIGH: 0, CRITICAL: 0)

main.tf (terraform)

Tests: 20 (SUCCESSES: 17, FAILURES: 0, EXCEPTIONS: 3)
Failures: 0 (HIGH: 0, CRITICAL: 0)

trivy_exitcode=3

</details> #### `Checkov Scan` Failed
<details><summary>Show Output</summary>

```hcl

*****************************

Checkov will check the following folders:
terraform/environments/cooker terraform/environments/example terraform/environments/sprinkler

*****************************

Running Checkov in terraform/environments/cooker
Excluding the following checks: CKV_GIT_1,CKV_AWS_126,CKV2_AWS_38,CKV2_AWS_39
terraform scan results:

Passed checks: 103, Failed checks: 39, Skipped checks: 0

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.app_egress_1
	File: /main.tf:90-98
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		90 | resource "aws_security_group_rule" "app_egress_1" {
		91 | 
		92 |   security_group_id = aws_security_group.app.id
		93 |   type              = "egress"
		94 |   from_port         = 0
		95 |   to_port           = 0
		96 |   protocol          = -1
		97 |   cidr_blocks       = ["0.0.0.0/0"]
		98 | }

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.app_ingress_1
	File: /main.tf:100-108
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		100 | resource "aws_security_group_rule" "app_ingress_1" {
		101 | 
		102 |   security_group_id        = aws_security_group.app.id
		103 |   type                     = "ingress"
		104 |   from_port                = 3000
		105 |   to_port                  = 3000
		106 |   protocol                 = "tcp"
		107 |   source_security_group_id = aws_security_group.external_lb.id
		108 | }

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.app_ingress_2
	File: /main.tf:110-118
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		110 | resource "aws_security_group_rule" "app_ingress_2" {
		111 | 
		112 |   security_group_id        = aws_security_group.app.id
		113 |   type                     = "ingress"
		114 |   from_port                = 3000
		115 |   to_port                  = 3000
		116 |   protocol                 = "tcp"
		117 |   source_security_group_id = aws_security_group.inner_lb.id
		118 | }

Check: CKV_AWS_65: "Ensure container insights are enabled on ECS cluster"
	FAILED for resource: aws_ecs_cluster.app
	File: /main.tf:120-130
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/bc-aws-logging-11

		120 | resource "aws_ecs_cluster" "app" {
		121 | 
		122 |   name = var.networking[0].application
		123 | 
		124 |   tags = merge(
		125 |     local.tags,
		126 |     {
		127 |       Name = var.networking[0].application
		128 |     },
		129 |   )
		130 | }

Check: CKV_AWS_336: "Ensure ECS containers are limited to read-only access to root filesystems"
	FAILED for resource: aws_ecs_task_definition.app
	File: /main.tf:175-239
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-336

		Code lines for this resource are too many. Please use IDE of your choice to review the file.
Check: CKV_AWS_355: "Ensure no IAM policies documents allow "*" as a statement's resource for restrictable actions"
	FAILED for resource: aws_iam_role_policy.app_execution
	File: /main.tf:268-304
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-355

		268 | resource "aws_iam_role_policy" "app_execution" {
		269 |   name = "execution-${var.networking[0].application}"
		270 |   role = aws_iam_role.app_execution.id
		271 | 
		272 |   policy = <<-EOF
		273 |   {
		274 |     "Version": "2012-10-17",
		275 |     "Statement": [
		276 |       {
		277 |            "Action": [
		278 |                "logs:CreateLogStream",
		279 |                "logs:PutLogEvents",
		280 |                "ecr:GetAuthorizationToken"
		281 |            ],
		282 |            "Resource": "*",
		283 |            "Effect": "Allow"
		284 |       },
		285 |       {
		286 |             "Action": [
		287 |               "ecr:BatchCheckLayerAvailability",
		288 |               "ecr:GetDownloadUrlForLayer",
		289 |               "ecr:BatchGetImage"
		290 |             ],
		291 |               "Resource": "arn:aws:ecr:*:${local.environment_management.account_ids[terraform.workspace]}:repository/testlab",
		292 |             "Effect": "Allow"
		293 |       },
		294 |       {
		295 |           "Action": [
		296 |                "secretsmanager:GetSecretValue"
		297 |            ],
		298 |           "Resource": "arn:aws:secretsmanager:*:${local.environment_management.account_ids[terraform.workspace]}:secret:${var.networking[0].application}-db-master-*",
		299 |           "Effect": "Allow"
		300 |       }
		301 |     ]
		302 |   }
		303 |   EOF
		304 | }

Check: CKV_AWS_290: "Ensure IAM policies does not allow write access without constraints"
	FAILED for resource: aws_iam_role_policy.app_execution
	File: /main.tf:268-304
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-290

		268 | resource "aws_iam_role_policy" "app_execution" {
		269 |   name = "execution-${var.networking[0].application}"
		270 |   role = aws_iam_role.app_execution.id
		271 | 
		272 |   policy = <<-EOF
		273 |   {
		274 |     "Version": "2012-10-17",
		275 |     "Statement": [
		276 |       {
		277 |            "Action": [
		278 |                "logs:CreateLogStream",
		279 |                "logs:PutLogEvents",
		280 |                "ecr:GetAuthorizationToken"
		281 |            ],
		282 |            "Resource": "*",
		283 |            "Effect": "Allow"
		284 |       },
		285 |       {
		286 |             "Action": [
		287 |               "ecr:BatchCheckLayerAvailability",
		288 |               "ecr:GetDownloadUrlForLayer",
		289 |               "ecr:BatchGetImage"
		290 |             ],
		291 |               "Resource": "arn:aws:ecr:*:${local.environment_management.account_ids[terraform.workspace]}:repository/testlab",
		292 |             "Effect": "Allow"
		293 |       },
		294 |       {
		295 |           "Action": [
		296 |                "secretsmanager:GetSecretValue"
		297 |            ],
		298 |           "Resource": "arn:aws:secretsmanager:*:${local.environment_management.account_ids[terraform.workspace]}:secret:${var.networking[0].application}-db-master-*",
		299 |           "Effect": "Allow"
		300 |       }
		301 |     ]
		302 |   }
		303 |   EOF
		304 | }

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.external_lb_ingress_1
	File: /main.tf:374-384
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		374 | resource "aws_security_group_rule" "external_lb_ingress_1" {
		375 | 
		376 |   security_group_id = aws_security_group.external_lb.id
		377 |   type              = "ingress"
		378 |   from_port         = 80
		379 |   to_port           = 80
		380 |   protocol          = "tcp"
		381 |   cidr_blocks = [
		382 |     "81.157.202.5/32"
		383 |   ]
		384 | }

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.external_lb_egress_1
	File: /main.tf:386-394
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		386 | resource "aws_security_group_rule" "external_lb_egress_1" {
		387 | 
		388 |   security_group_id        = aws_security_group.external_lb.id
		389 |   type                     = "egress"
		390 |   from_port                = 3000
		391 |   to_port                  = 3000
		392 |   protocol                 = "tcp"
		393 |   source_security_group_id = aws_security_group.app.id
		394 | }

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.external_lb_ingress_2
	File: /main.tf:396-406
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		396 | resource "aws_security_group_rule" "external_lb_ingress_2" {
		397 | 
		398 |   security_group_id = aws_security_group.external_lb.id
		399 |   type              = "ingress"
		400 |   from_port         = 443
		401 |   to_port           = 443
		402 |   protocol          = "tcp"
		403 |   cidr_blocks = [
		404 |     "81.157.202.5/32"
		405 |   ]
		406 | }

Check: CKV_AWS_131: "Ensure that ALB drops HTTP headers"
	FAILED for resource: aws_lb.external
	File: /main.tf:408-423
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-that-alb-drops-http-headers

		408 | resource "aws_lb" "external" {
		409 | 
		410 |   name                       = "external-${var.networking[0].application}"
		411 |   internal                   = false
		412 |   load_balancer_type         = "application"
		413 |   security_groups            = [aws_security_group.external_lb.id]
		414 |   subnets                    = data.aws_subnets.shared-public.ids
		415 |   enable_deletion_protection = false
		416 | 
		417 |   tags = merge(
		418 |     local.tags,
		419 |     {
		420 |       Name = "external-${var.networking[0].application}"
		421 |     },
		422 |   )
		423 | }

Check: CKV_AWS_150: "Ensure that Load Balancer has deletion protection enabled"
	FAILED for resource: aws_lb.external
	File: /main.tf:408-423
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-150

		408 | resource "aws_lb" "external" {
		409 | 
		410 |   name                       = "external-${var.networking[0].application}"
		411 |   internal                   = false
		412 |   load_balancer_type         = "application"
		413 |   security_groups            = [aws_security_group.external_lb.id]
		414 |   subnets                    = data.aws_subnets.shared-public.ids
		415 |   enable_deletion_protection = false
		416 | 
		417 |   tags = merge(
		418 |     local.tags,
		419 |     {
		420 |       Name = "external-${var.networking[0].application}"
		421 |     },
		422 |   )
		423 | }

Check: CKV_AWS_91: "Ensure the ELBv2 (Application/Network) has access logging enabled"
	FAILED for resource: aws_lb.external
	File: /main.tf:408-423
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/bc-aws-logging-22

		408 | resource "aws_lb" "external" {
		409 | 
		410 |   name                       = "external-${var.networking[0].application}"
		411 |   internal                   = false
		412 |   load_balancer_type         = "application"
		413 |   security_groups            = [aws_security_group.external_lb.id]
		414 |   subnets                    = data.aws_subnets.shared-public.ids
		415 |   enable_deletion_protection = false
		416 | 
		417 |   tags = merge(
		418 |     local.tags,
		419 |     {
		420 |       Name = "external-${var.networking[0].application}"
		421 |     },
		422 |   )
		423 | }

Check: CKV_AWS_261: "Ensure HTTP HTTPS Target group defines Healthcheck"
	FAILED for resource: aws_lb_target_group.external
	File: /main.tf:425-440
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-aws-kendra-index-server-side-encryption-uses-customer-managed-keys-cmks

		425 | resource "aws_lb_target_group" "external" {
		426 | 
		427 |   name                 = "external-${var.networking[0].application}"
		428 |   port                 = "3000"
		429 |   protocol             = "HTTP"
		430 |   target_type          = "ip"
		431 |   deregistration_delay = "30"
		432 |   vpc_id               = data.aws_vpc.shared.id
		433 | 
		434 |   tags = merge(
		435 |     local.tags,
		436 |     {
		437 |       Name = "external-${var.networking[0].application}"
		438 |     },
		439 |   )
		440 | }

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.inner_lb_ingress_1
	File: /main.tf:528-536
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		528 | resource "aws_security_group_rule" "inner_lb_ingress_1" {
		529 | 
		530 |   security_group_id        = aws_security_group.inner_lb.id
		531 |   type                     = "ingress"
		532 |   from_port                = 443
		533 |   to_port                  = 443
		534 |   protocol                 = "tcp"
		535 |   source_security_group_id = aws_security_group.inner_lb.id
		536 | }

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.inner_lb_egress_1
	File: /main.tf:538-546
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		538 | resource "aws_security_group_rule" "inner_lb_egress_1" {
		539 | 
		540 |   security_group_id        = aws_security_group.inner_lb.id
		541 |   type                     = "egress"
		542 |   from_port                = 3000
		543 |   to_port                  = 3000
		544 |   protocol                 = "tcp"
		545 |   source_security_group_id = aws_security_group.app.id
		546 | }

Check: CKV_AWS_131: "Ensure that ALB drops HTTP headers"
	FAILED for resource: aws_lb.inner
	File: /main.tf:548-563
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-that-alb-drops-http-headers

		548 | resource "aws_lb" "inner" {
		549 | 
		550 |   name                       = "inner-${var.networking[0].application}"
		551 |   internal                   = true
		552 |   load_balancer_type         = "application"
		553 |   security_groups            = [aws_security_group.inner_lb.id]
		554 |   subnets                    = data.aws_subnets.shared-private.ids
		555 |   enable_deletion_protection = false
		556 | 
		557 |   tags = merge(
		558 |     local.tags,
		559 |     {
		560 |       Name = "inner-${var.networking[0].application}"
		561 |     },
		562 |   )
		563 | }

Check: CKV_AWS_150: "Ensure that Load Balancer has deletion protection enabled"
	FAILED for resource: aws_lb.inner
	File: /main.tf:548-563
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-150

		548 | resource "aws_lb" "inner" {
		549 | 
		550 |   name                       = "inner-${var.networking[0].application}"
		551 |   internal                   = true
		552 |   load_balancer_type         = "application"
		553 |   security_groups            = [aws_security_group.inner_lb.id]
		554 |   subnets                    = data.aws_subnets.shared-private.ids
		555 |   enable_deletion_protection = false
		556 | 
		557 |   tags = merge(
		558 |     local.tags,
		559 |     {
		560 |       Name = "inner-${var.networking[0].application}"
		561 |     },
		562 |   )
		563 | }

Check: CKV_AWS_91: "Ensure the ELBv2 (Application/Network) has access logging enabled"
	FAILED for resource: aws_lb.inner
	File: /main.tf:548-563
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/bc-aws-logging-22

		548 | resource "aws_lb" "inner" {
		549 | 
		550 |   name                       = "inner-${var.networking[0].application}"
		551 |   internal                   = true
		552 |   load_balancer_type         = "application"
		553 |   security_groups            = [aws_security_group.inner_lb.id]
		554 |   subnets                    = data.aws_subnets.shared-private.ids
		555 |   enable_deletion_protection = false
		556 | 
		557 |   tags = merge(
		558 |     local.tags,
		559 |     {
		560 |       Name = "inner-${var.networking[0].application}"
		561 |     },
		562 |   )
		563 | }

Check: CKV_AWS_261: "Ensure HTTP HTTPS Target group defines Healthcheck"
	FAILED for resource: aws_lb_target_group.inner
	File: /main.tf:565-580
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-aws-kendra-index-server-side-encryption-uses-customer-managed-keys-cmks

		565 | resource "aws_lb_target_group" "inner" {
		566 | 
		567 |   name                 = "inner-${var.networking[0].application}"
		568 |   port                 = "3000"
		569 |   protocol             = "HTTP"
		570 |   target_type          = "ip"
		571 |   deregistration_delay = "30"
		572 |   vpc_id               = data.aws_vpc.shared.id
		573 | 
		574 |   tags = merge(
		575 |     local.tags,
		576 |     {
		577 |       Name = "inner-${var.networking[0].application}"
		578 |     },
		579 |   )
		580 | }

Check: CKV_AWS_233: "Ensure Create before destroy for ACM certificates"
	FAILED for resource: aws_acm_certificate.inner
	File: /main.tf:613-621
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-aws-acm-certificate-enables-create-before-destroy

		613 | resource "aws_acm_certificate" "inner" {
		614 |   domain_name               = "${var.networking[0].business-unit}-sandbox.modernisation-platform.internal"
		615 |   certificate_authority_arn = local.is_live[0] == "live" ? data.terraform_remote_state.core_network_services.outputs.acmpca_subordinate_live : data.terraform_remote_state.core_network_services.outputs.acmpca_subordinate_non_live
		616 | 
		617 |   subject_alternative_names = ["*.${var.networking[0].business-unit}-sandbox.modernisation-platform.internal"]
		618 |   tags = {
		619 |     Environment = "test"
		620 |   }
		621 | }

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.rds_ingress_1
	File: /main.tf:640-648
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		640 | resource "aws_security_group_rule" "rds_ingress_1" {
		641 | 
		642 |   security_group_id        = aws_security_group.rds.id
		643 |   type                     = "ingress"
		644 |   from_port                = 5432
		645 |   to_port                  = 5432
		646 |   protocol                 = "tcp"
		647 |   source_security_group_id = aws_security_group.app.id
		648 | }

Check: CKV_AWS_23: "Ensure every security group and rule has a description"
	FAILED for resource: aws_security_group_rule.rds_egress_1
	File: /main.tf:650-658
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/networking-31

		650 | resource "aws_security_group_rule" "rds_egress_1" {
		651 | 
		652 |   security_group_id = aws_security_group.rds.id
		653 |   type              = "egress"
		654 |   from_port         = 0
		655 |   to_port           = 0
		656 |   protocol          = -1
		657 |   cidr_blocks       = ["0.0.0.0/0"]
		658 | }

Check: CKV_AWS_149: "Ensure that Secrets Manager secret is encrypted using KMS CMK"
	FAILED for resource: aws_secretsmanager_secret.master_password
	File: /main.tf:686-696
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-that-secrets-manager-secret-is-encrypted-using-kms

		686 | resource "aws_secretsmanager_secret" "master_password" {
		687 | 
		688 |   name = "${var.networking[0].application}-db-master-${random_string.secret_name_suffix.result}"
		689 | 
		690 |   tags = merge(
		691 |     local.tags,
		692 |     {
		693 |       Name = "${var.networking[0].application}-db-master-${random_string.secret_name_suffix.result}"
		694 |     },
		695 |   )
		696 | }

Check: CKV_AWS_293: "Ensure that AWS database instances have deletion protection enabled"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-293

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV_AWS_129: "Ensure that respective logs of Amazon Relational Database Service (Amazon RDS) are enabled"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/ensure-that-respective-logs-of-amazon-relational-database-service-amazon-rds-are-enabled

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV_AWS_226: "Ensure DB instance gets all minor upgrades automatically"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-aws-db-instance-gets-all-minor-upgrades-automatically

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV_AWS_157: "Ensure that RDS instances have Multi-AZ enabled"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/general-73

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV_AWS_118: "Ensure that enhanced monitoring is enabled for Amazon RDS instances"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/ensure-that-enhanced-monitoring-is-enabled-for-amazon-rds-instances

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV_AWS_161: "Ensure RDS database has IAM authentication enabled"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/ensure-rds-database-has-iam-authentication-enabled

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV_AWS_353: "Ensure that RDS instances have performance insights enabled"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/bc-aws-353

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV_AWS_16: "Ensure all data stored in the RDS is securely encrypted at rest"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/general-4

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV_AWS_354: "Ensure RDS Performance Insights are encrypted using KMS CMKs"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-354

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV_AWS_338: "Ensure CloudWatch log groups retains logs for at least 1 year"
	FAILED for resource: aws_cloudwatch_log_group.app
	File: /main.tf:729-740
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/bc-aws-338

		729 | resource "aws_cloudwatch_log_group" "app" {
		730 | 
		731 |   name              = var.networking[0].application
		732 |   retention_in_days = 90
		733 | 
		734 |   tags = merge(
		735 |     local.tags,
		736 |     {
		737 |       Name = var.networking[0].application
		738 |     },
		739 |   )
		740 | }
Check: CKV_AWS_158: "Ensure that CloudWatch Log Group is encrypted by KMS"
	FAILED for resource: aws_cloudwatch_log_group.app
	File: /main.tf:729-740
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-that-cloudwatch-log-group-is-encrypted-by-kms

		729 | resource "aws_cloudwatch_log_group" "app" {
		730 | 
		731 |   name              = var.networking[0].application
		732 |   retention_in_days = 90
		733 | 
		734 |   tags = merge(
		735 |     local.tags,
		736 |     {
		737 |       Name = var.networking[0].application
		738 |     },
		739 |   )
		740 | }
Check: CKV2_AWS_60: "Ensure RDS instance with copy tags to snapshots is enabled"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-2-60

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV2_AWS_57: "Ensure Secrets Manager secrets should have automatic rotation enabled"
	FAILED for resource: aws_secretsmanager_secret.master_password
	File: /main.tf:686-696
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-2-57

		686 | resource "aws_secretsmanager_secret" "master_password" {
		687 | 
		688 |   name = "${var.networking[0].application}-db-master-${random_string.secret_name_suffix.result}"
		689 | 
		690 |   tags = merge(
		691 |     local.tags,
		692 |     {
		693 |       Name = "${var.networking[0].application}-db-master-${random_string.secret_name_suffix.result}"
		694 |     },
		695 |   )
		696 | }

Check: CKV2_AWS_30: "Ensure Postgres RDS as aws_db_instance has Query Logging enabled"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:703-723
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-postgres-rds-has-query-logging-enabled

		703 | resource "aws_db_instance" "app" {
		704 | 
		705 |   identifier             = var.networking[0].application
		706 |   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
		707 |   engine                 = "postgres"
		708 |   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
		709 |   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
		710 |   db_name                = var.networking[0].application
		711 |   username               = "dbmain"
		712 |   password               = random_password.db_master_password.result
		713 |   vpc_security_group_ids = [aws_security_group.rds.id]
		714 |   db_subnet_group_name   = aws_db_subnet_group.app.id
		715 |   skip_final_snapshot    = true
		716 | 
		717 |   tags = merge(
		718 |     local.tags,
		719 |     {
		720 |       Name = var.networking[0].application
		721 |     }
		722 |   )
		723 | }

Check: CKV2_AWS_28: "Ensure public facing ALB are protected by WAF"
	FAILED for resource: aws_lb.external
	File: /main.tf:408-423
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-public-facing-alb-are-protected-by-waf

		408 | resource "aws_lb" "external" {
		409 | 
		410 |   name                       = "external-${var.networking[0].application}"
		411 |   internal                   = false
		412 |   load_balancer_type         = "application"
		413 |   security_groups            = [aws_security_group.external_lb.id]
		414 |   subnets                    = data.aws_subnets.shared-public.ids
		415 |   enable_deletion_protection = false
		416 | 
		417 |   tags = merge(
		418 |     local.tags,
		419 |     {
		420 |       Name = "external-${var.networking[0].application}"
		421 |     },
		422 |   )
		423 | }


checkov_exitcode=1

*****************************

Running Checkov in terraform/environments/example
Excluding the following checks: CKV_GIT_1,CKV_AWS_126,CKV2_AWS_38,CKV2_AWS_39
2024-05-20 11:02:27,578 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-ecs-cluster//cluster?ref=b00647922a9204a99b023ac884440162e2b51b66:None (for external modules, the --download-external-modules flag is required)
2024-05-20 11:02:27,578 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-ecs-cluster//service?ref=b00647922a9204a99b023ac884440162e2b51b66:None (for external modules, the --download-external-modules flag is required)
2024-05-20 11:02:27,578 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee:None (for external modules, the --download-external-modules flag is required)
2024-05-20 11:02:27,578 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-ec2-instance?ref=edc55b4005b7039e5b54ad7805e89a473fe3c3dd:None (for external modules, the --download-external-modules flag is required)
2024-05-20 11:02:27,579 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239:None (for external modules, the --download-external-modules flag is required)
2024-05-20 11:02:27,579 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-ec2-autoscaling-group?ref=03913ac182decfc8224923520439d53d7c930661:None (for external modules, the --download-external-modules flag is required)
2024-05-20 11:02:27,579 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=95ed3c3f454e2014a62990aacd5d68c64d026f11:None (for external modules, the --download-external-modules flag is required)
terraform scan results:

Passed checks: 272, Failed checks: 6, Skipped checks: 34

Check: CKV2_AWS_60: "Ensure RDS instance with copy tags to snapshots is enabled"
	FAILED for resource: aws_db_instance.example-rds
	File: /rds.tf:11-48
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-2-60

		11 | resource "aws_db_instance" "example-rds" {
		12 |   #checkov:skip=CKV_AWS_118: "enhanced monitoring is enabled, but optional"
		13 |   #checkov:skip=CKV_AWS_157: "multi-az enabled, but optional"
		14 |   #checkov:skip=CKV_AWS_133: "backup_retention enabled, can be edited it application_variables.json"
		15 |   #checkov:skip=CKV_AWS_161: "iam auth enabled, but optional"
		16 |   #checkov:skip=CKV_AWS_293: "Deletion protection not required for example"
		17 |   #checkov:skip=CKV_AWS_354: "Performance insights don't need encryption for example"
		18 |   engine                     = "mysql"
		19 |   engine_version             = "5.7"
		20 |   auto_minor_version_upgrade = true
		21 |   instance_class             = local.application_data.accounts[local.environment].db_instance_class
		22 |   db_name                    = "${local.application_name}${local.environment}database"
		23 |   identifier                 = "${local.application_name}-${local.environment}-database"
		24 |   username                   = local.application_data.accounts[local.environment].db_user
		25 |   password                   = aws_secretsmanager_secret_version.db_password.secret_string
		26 |   # tflint-ignore: aws_db_instance_default_parameter_group
		27 |   parameter_group_name                = "default.mysql5.7"
		28 |   skip_final_snapshot                 = local.application_data.accounts[local.environment].skip_final_snapshot
		29 |   allocated_storage                   = local.application_data.accounts[local.environment].db_allocated_storage
		30 |   max_allocated_storage               = local.application_data.accounts[local.environment].db_max_allocated_storage
		31 |   maintenance_window                  = local.application_data.accounts[local.environment].maintenance_window
		32 |   allow_major_version_upgrade         = local.application_data.accounts[local.environment].allow_major_version_upgrade
		33 |   backup_window                       = local.application_data.accounts[local.environment].backup_window
		34 |   backup_retention_period             = local.application_data.accounts[local.environment].retention_period
		35 |   iam_database_authentication_enabled = local.application_data.accounts[local.environment].db_iam_database_authentication_enabled
		36 |   multi_az                            = local.application_data.accounts[local.environment].db_multi_az
		37 |   monitoring_interval                 = local.application_data.accounts[local.environment].db_monitoring_interval
		38 |   monitoring_role_arn                 = local.application_data.accounts[local.environment].db_monitoring_interval == 0 ? "" : aws_iam_role.rds_enhanced_monitoring[0].arn
		39 |   storage_encrypted                   = true
		40 |   db_subnet_group_name                = aws_db_subnet_group.example.name
		41 |   vpc_security_group_ids              = [aws_security_group.rds-example.id]
		42 |   performance_insights_enabled        = local.application_data.accounts[local.environment].db_performance_insights_enabled
		43 |   performance_insights_kms_key_id     = "" #tfsec:ignore:aws-rds-enable-performance-insights-encryption Left empty so that it will run, however should be populated with real key in scenario.
		44 |   enabled_cloudwatch_logs_exports     = local.application_data.accounts[local.environment].db_enabled_cloudwatch_logs_exports
		45 |   tags = merge(local.tags,
		46 |     { Name = lower(format("%s-%s-example", local.application_name, local.environment)) }
		47 |   )
		48 | }

Check: CKV2_AWS_57: "Ensure Secrets Manager secrets should have automatic rotation enabled"
	FAILED for resource: aws_secretsmanager_secret.db_password
	File: /rds.tf:92-102
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-2-57

		92  | resource "aws_secretsmanager_secret" "db_password" {
		93  |   #checkov:skip=CKV_AWS_149
		94  |   name                    = "${var.networking[0].application}-db-password"
		95  |   recovery_window_in_days = 0
		96  |   tags = merge(
		97  |     local.tags,
		98  |     {
		99  |       Name = "${var.networking[0].application}-db-password"
		100 |     },
		101 |   )
		102 | }

Check: CKV2_AWS_28: "Ensure public facing ALB are protected by WAF"
	FAILED for resource: aws_lb.certificate_example_lb
	File: /certificates.tf:63-83
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-public-facing-alb-are-protected-by-waf

		63 | resource "aws_lb" "certificate_example_lb" {
		64 |   name               = "certificate-example-loadbalancer"
		65 |   load_balancer_type = "application"
		66 |   subnets            = data.aws_subnets.shared-public.ids
		67 |   #checkov:skip=CKV_AWS_150:Short-lived example environment, hence no need for deletion protection
		68 |   enable_deletion_protection = false
		69 |   # allow 60*4 seconds before 504 gateway timeout for long-running DB operations
		70 |   idle_timeout               = 240
		71 |   drop_invalid_header_fields = true
		72 | 
		73 |   security_groups = [aws_security_group.certificate_example_load_balancer_sg.id]
		74 | 
		75 |   access_logs {
		76 |     bucket  = module.s3-bucket-lb.bucket.id
		77 |     prefix  = "test-lb"
		78 |     enabled = true
		79 |   }
		80 | 
		81 |   tags       = { Name = "${local.application_name}-external-loadbalancer" }
		82 |   depends_on = [aws_security_group.certificate_example_load_balancer_sg]
		83 | }

Check: CKV2_AWS_5: "Ensure that Security Groups are attached to another resource"
	FAILED for resource: aws_security_group.example_ec2_autoscale_sg
	File: /ec2_autoscaling_group.tf:77-82
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-that-security-groups-are-attached-to-ec2-instances-or-elastic-network-interfaces-enis

		77 | resource "aws_security_group" "example_ec2_autoscale_sg" {
		78 |   name        = "example_ec2_autoscale_sg"
		79 |   description = "Controls access to EC2"
		80 |   vpc_id      = data.aws_vpc.shared.id
		81 |   tags        = { Name = lower(format("sg-%s-%s-example", local.application_name, local.environment)) }
		82 | }

Check: CKV2_AWS_5: "Ensure that Security Groups are attached to another resource"
	FAILED for resource: aws_security_group.complete_example_ec2_sg
	File: /ec2_complete.tf:209-214
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-that-security-groups-are-attached-to-ec2-instances-or-elastic-network-interfaces-enis

		209 | resource "aws_security_group" "complete_example_ec2_sg" {
		210 |   name        = "complete_ec2_sg"
		211 |   description = "Ingress and Egress Access Controls for EC2"
		212 |   vpc_id      = data.aws_vpc.shared.id
		213 |   tags        = { Name = lower(format("sg-%s-%s-example", local.application_name, local.environment)) }
		214 | }

Check: CKV2_AWS_5: "Ensure that Security Groups are attached to another resource"
	FAILED for resource: aws_security_group.cluster_ec2
	File: /ecs.tf:186-214
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-that-security-groups-are-attached-to-ec2-instances-or-elastic-network-interfaces-enis

		186 | resource "aws_security_group" "cluster_ec2" {
		187 |   #checkov:skip=CKV_AWS_23
		188 |   name        = "cluster_ec2"
		189 |   description = "controls access to the cluster ec2 instance"
		190 |   vpc_id      = data.aws_vpc.shared.id
		191 |   dynamic "ingress" {
		192 |     for_each = local.ec2_ingress_rules
		193 |     content {
		194 |       description     = lookup(ingress.value, "description", null)
		195 |       from_port       = lookup(ingress.value, "from_port", null)
		196 |       to_port         = lookup(ingress.value, "to_port", null)
		197 |       protocol        = lookup(ingress.value, "protocol", null)
		198 |       cidr_blocks     = lookup(ingress.value, "cidr_blocks", null)
		199 |       security_groups = lookup(ingress.value, "security_groups", null)
		200 |     }
		201 |   }
		202 |   dynamic "egress" {
		203 |     for_each = local.ec2_egress_rules
		204 |     content {
		205 |       description     = lookup(egress.value, "description", null)
		206 |       from_port       = lookup(egress.value, "from_port", null)
		207 |       to_port         = lookup(egress.value, "to_port", null)
		208 |       protocol        = lookup(egress.value, "protocol", null)
		209 |       cidr_blocks     = lookup(egress.value, "cidr_blocks", null)
		210 |       security_groups = lookup(egress.value, "security_groups", null)
		211 |     }
		212 |   }
		213 |   tags = { Name = lower(format("sg-%s-%s-example", local.application_name, local.environment)) }
		214 | }


checkov_exitcode=2

*****************************

Running Checkov in terraform/environments/sprinkler
Excluding the following checks: CKV_GIT_1,CKV_AWS_126,CKV2_AWS_38,CKV2_AWS_39
2024-05-20 11:02:31,090 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.1:None (for external modules, the --download-external-modules flag is required)
2024-05-20 11:02:31,091 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-pagerduty-integration?ref=v2.0.0:None (for external modules, the --download-external-modules flag is required)
2024-05-20 11:02:31,091 [MainThread  ] [WARNI]  Failed to download module github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0:None (for external modules, the --download-external-modules flag is required)
terraform scan results:

Passed checks: 185, Failed checks: 17, Skipped checks: 22

Check: CKV_TF_1: "Ensure Terraform module sources use a commit hash"
	FAILED for resource: bastion_linux
	File: /bastion_linux.tf:6-37
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/supply-chain-policies/terraform-policies/ensure-terraform-module-sources-use-git-url-with-commit-hash-revision

		6  | module "bastion_linux" {
		7  |   source = "github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.1"
		8  | 
		9  |   providers = {
		10 |     aws.share-host   = aws.core-vpc # core-vpc-(environment) holds the networking for all accounts
		11 |     aws.share-tenant = aws          # The default provider (unaliased, `aws`) is the tenant
		12 |   }
		13 | 
		14 |   # s3 - used for logs and user ssh public keys
		15 |   bucket_name          = "bastion"
		16 |   bucket_versioning    = true
		17 |   bucket_force_destroy = true
		18 |   # public keys
		19 |   public_key_data = local.public_key_data.keys[local.environment]
		20 |   # logs
		21 |   log_auto_clean       = "Enabled"
		22 |   log_standard_ia_days = 30  # days before moving to IA storage
		23 |   log_glacier_days     = 60  # days before moving to Glacier
		24 |   log_expiry_days      = 180 # days before log expiration
		25 |   # bastion
		26 |   allow_ssh_commands = false
		27 | 
		28 |   app_name      = var.networking[0].application
		29 |   business_unit = local.vpc_name
		30 |   subnet_set    = local.subnet_set
		31 |   environment   = "sandbox"
		32 |   region        = "eu-west-2"
		33 | 
		34 |   # Tags
		35 |   tags_common = local.tags
		36 |   tags_prefix = terraform.workspace
		37 | }

Check: CKV_AWS_356: "Ensure no IAM policies documents allow "*" as a statement's resource for restrictable actions"
	FAILED for resource: aws_iam_policy_document.ebs-kms
	File: /db_manager.tf:184-207
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-356

		184 | data "aws_iam_policy_document" "ebs-kms" {
		185 |   #checkov:skip=CKV_AWS_111
		186 |   #checkov:skip=CKV_AWS_109
		187 |   statement {
		188 |     effect    = "Allow"
		189 |     actions   = ["kms:*"]
		190 |     resources = ["*"]
		191 | 
		192 |     principals {
		193 |       type        = "Service"
		194 |       identifiers = ["ec2.amazonaws.com"]
		195 |     }
		196 |   }
		197 |   statement {
		198 |     effect    = "Allow"
		199 |     actions   = ["kms:*"]
		200 |     resources = ["*"]
		201 | 
		202 |     principals {
		203 |       type        = "AWS"
		204 |       identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
		205 |     }
		206 |   }
		207 | }

Check: CKV_AWS_289: "Ensure IAM policies does not allow permissions management / resource exposure without constraints"
	FAILED for resource: aws_iam_policy.db_mgmt_policy
	File: /db_manager.tf:94-124
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-289

		94  | resource "aws_iam_policy" "db_mgmt_policy" {
		95  |   name        = "${local.application_name}-db_mgmt-ec2-policy"
		96  |   description = "${local.application_name} ec2-policy"
		97  | 
		98  |   policy = <<EOF
		99  | {
		100 |     "Version": "2012-10-17",
		101 |     "Statement": [
		102 |       {
		103 |         "Effect": "Allow",
		104 |         "Action": "s3:*",
		105 |         "Resource": "*"
		106 |       },
		107 |       {
		108 |         "Effect": "Allow",
		109 |         "Action": [
		110 |           "s3:GetEncryptionConfiguration"
		111 |         ],
		112 |         "Resource": "*"
		113 |       },
		114 |       {
		115 |         "Effect": "Allow",
		116 |         "Action": [
		117 |           "kms:Decrypt"
		118 |         ],
		119 |         "Resource": "arn:aws:kms:eu-west-2:322518575883:key/c1b9e987-29e2-458f-b5bd-2e9c2b57f049"
		120 |       }
		121 |     ]
		122 | }
		123 | EOF
		124 | }

Check: CKV_AWS_355: "Ensure no IAM policies documents allow "*" as a statement's resource for restrictable actions"
	FAILED for resource: aws_iam_policy.db_mgmt_policy
	File: /db_manager.tf:94-124
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-355

		94  | resource "aws_iam_policy" "db_mgmt_policy" {
		95  |   name        = "${local.application_name}-db_mgmt-ec2-policy"
		96  |   description = "${local.application_name} ec2-policy"
		97  | 
		98  |   policy = <<EOF
		99  | {
		100 |     "Version": "2012-10-17",
		101 |     "Statement": [
		102 |       {
		103 |         "Effect": "Allow",
		104 |         "Action": "s3:*",
		105 |         "Resource": "*"
		106 |       },
		107 |       {
		108 |         "Effect": "Allow",
		109 |         "Action": [
		110 |           "s3:GetEncryptionConfiguration"
		111 |         ],
		112 |         "Resource": "*"
		113 |       },
		114 |       {
		115 |         "Effect": "Allow",
		116 |         "Action": [
		117 |           "kms:Decrypt"
		118 |         ],
		119 |         "Resource": "arn:aws:kms:eu-west-2:322518575883:key/c1b9e987-29e2-458f-b5bd-2e9c2b57f049"
		120 |       }
		121 |     ]
		122 | }
		123 | EOF
		124 | }

Check: CKV_AWS_288: "Ensure IAM policies does not allow data exfiltration"
	FAILED for resource: aws_iam_policy.db_mgmt_policy
	File: /db_manager.tf:94-124
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-288

		94  | resource "aws_iam_policy" "db_mgmt_policy" {
		95  |   name        = "${local.application_name}-db_mgmt-ec2-policy"
		96  |   description = "${local.application_name} ec2-policy"
		97  | 
		98  |   policy = <<EOF
		99  | {
		100 |     "Version": "2012-10-17",
		101 |     "Statement": [
		102 |       {
		103 |         "Effect": "Allow",
		104 |         "Action": "s3:*",
		105 |         "Resource": "*"
		106 |       },
		107 |       {
		108 |         "Effect": "Allow",
		109 |         "Action": [
		110 |           "s3:GetEncryptionConfiguration"
		111 |         ],
		112 |         "Resource": "*"
		113 |       },
		114 |       {
		115 |         "Effect": "Allow",
		116 |         "Action": [
		117 |           "kms:Decrypt"
		118 |         ],
		119 |         "Resource": "arn:aws:kms:eu-west-2:322518575883:key/c1b9e987-29e2-458f-b5bd-2e9c2b57f049"
		120 |       }
		121 |     ]
		122 | }
		123 | EOF
		124 | }

Check: CKV_AWS_290: "Ensure IAM policies does not allow write access without constraints"
	FAILED for resource: aws_iam_policy.db_mgmt_policy
	File: /db_manager.tf:94-124
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-290

		94  | resource "aws_iam_policy" "db_mgmt_policy" {
		95  |   name        = "${local.application_name}-db_mgmt-ec2-policy"
		96  |   description = "${local.application_name} ec2-policy"
		97  | 
		98  |   policy = <<EOF
		99  | {
		100 |     "Version": "2012-10-17",
		101 |     "Statement": [
		102 |       {
		103 |         "Effect": "Allow",
		104 |         "Action": "s3:*",
		105 |         "Resource": "*"
		106 |       },
		107 |       {
		108 |         "Effect": "Allow",
		109 |         "Action": [
		110 |           "s3:GetEncryptionConfiguration"
		111 |         ],
		112 |         "Resource": "*"
		113 |       },
		114 |       {
		115 |         "Effect": "Allow",
		116 |         "Action": [
		117 |           "kms:Decrypt"
		118 |         ],
		119 |         "Resource": "arn:aws:kms:eu-west-2:322518575883:key/c1b9e987-29e2-458f-b5bd-2e9c2b57f049"
		120 |       }
		121 |     ]
		122 | }
		123 | EOF
		124 | }

Check: CKV_AWS_356: "Ensure no IAM policies documents allow "*" as a statement's resource for restrictable actions"
	FAILED for resource: aws_iam_policy_document.sprinkler_ebs_encryption_policy_doc
	File: /kms.tf:29-98
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-356

		Code lines for this resource are too many. Please use IDE of your choice to review the file.
Check: CKV_AWS_336: "Ensure ECS containers are limited to read-only access to root filesystems"
	FAILED for resource: aws_ecs_task_definition.app
	File: /main.tf:183-247
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-336

		Code lines for this resource are too many. Please use IDE of your choice to review the file.
Check: CKV_AWS_355: "Ensure no IAM policies documents allow "*" as a statement's resource for restrictable actions"
	FAILED for resource: aws_iam_role_policy.app_execution
	File: /main.tf:276-312
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-355

		276 | resource "aws_iam_role_policy" "app_execution" {
		277 |   name = "execution-${var.networking[0].application}"
		278 |   role = aws_iam_role.app_execution.id
		279 | 
		280 |   policy = <<-EOF
		281 |   {
		282 |     "Version": "2012-10-17",
		283 |     "Statement": [
		284 |       {
		285 |            "Action": [
		286 |                "logs:CreateLogStream",
		287 |                "logs:PutLogEvents",
		288 |                "ecr:GetAuthorizationToken"
		289 |            ],
		290 |            "Resource": "*",
		291 |            "Effect": "Allow"
		292 |       },
		293 |       {
		294 |             "Action": [
		295 |               "ecr:BatchCheckLayerAvailability",
		296 |               "ecr:GetDownloadUrlForLayer",
		297 |               "ecr:BatchGetImage"
		298 |             ],
		299 |               "Resource": "arn:aws:ecr:*:${local.environment_management.account_ids[terraform.workspace]}:repository/testlab",
		300 |             "Effect": "Allow"
		301 |       },
		302 |       {
		303 |           "Action": [
		304 |                "secretsmanager:GetSecretValue"
		305 |            ],
		306 |           "Resource": "arn:aws:secretsmanager:*:${local.environment_management.account_ids[terraform.workspace]}:secret:${var.networking[0].application}-db-master-*",
		307 |           "Effect": "Allow"
		308 |       }
		309 |     ]
		310 |   }
		311 |   EOF
		312 | }

Check: CKV_AWS_290: "Ensure IAM policies does not allow write access without constraints"
	FAILED for resource: aws_iam_role_policy.app_execution
	File: /main.tf:276-312
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-iam-policies/bc-aws-290

		276 | resource "aws_iam_role_policy" "app_execution" {
		277 |   name = "execution-${var.networking[0].application}"
		278 |   role = aws_iam_role.app_execution.id
		279 | 
		280 |   policy = <<-EOF
		281 |   {
		282 |     "Version": "2012-10-17",
		283 |     "Statement": [
		284 |       {
		285 |            "Action": [
		286 |                "logs:CreateLogStream",
		287 |                "logs:PutLogEvents",
		288 |                "ecr:GetAuthorizationToken"
		289 |            ],
		290 |            "Resource": "*",
		291 |            "Effect": "Allow"
		292 |       },
		293 |       {
		294 |             "Action": [
		295 |               "ecr:BatchCheckLayerAvailability",
		296 |               "ecr:GetDownloadUrlForLayer",
		297 |               "ecr:BatchGetImage"
		298 |             ],
		299 |               "Resource": "arn:aws:ecr:*:${local.environment_management.account_ids[terraform.workspace]}:repository/testlab",
		300 |             "Effect": "Allow"
		301 |       },
		302 |       {
		303 |           "Action": [
		304 |                "secretsmanager:GetSecretValue"
		305 |            ],
		306 |           "Resource": "arn:aws:secretsmanager:*:${local.environment_management.account_ids[terraform.workspace]}:secret:${var.networking[0].application}-db-master-*",
		307 |           "Effect": "Allow"
		308 |       }
		309 |     ]
		310 |   }
		311 |   EOF
		312 | }

Check: CKV_AWS_293: "Ensure that AWS database instances have deletion protection enabled"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:771-800
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-293

		771 | resource "aws_db_instance" "app" {
		772 |   # checkov:skip=CKV_AWS_118: "sprinkler does not need enhanced monitoring"
		773 |   # checkov:skip=CKV_AWS_129: "export to cloudwatch for logs is unneeded here"
		774 |   # checkov:skip=CKV_AWS_157: "multi-AZ deployment excessive for sprinkler"
		775 |   # checkov:skip=CKV_AWS_161: "IAM authentication excessive for sprinkler"
		776 |   # checkov:skip=CKV_AWS_226: "auto_upgrade_minor_version true by default"
		777 |   identifier                      = var.networking[0].application
		778 |   allocated_storage               = local.application_data.accounts[local.environment].rds_storage
		779 |   engine                          = "postgres"
		780 |   engine_version                  = local.application_data.accounts[local.environment].rds_postgresql_version
		781 |   instance_class                  = local.application_data.accounts[local.environment].rds_instance_class
		782 |   db_name                         = var.networking[0].application
		783 |   username                        = "dbmain"
		784 |   parameter_group_name            = aws_db_parameter_group.app.name
		785 |   password                        = random_password.db_master_password.result
		786 |   performance_insights_enabled    = true
		787 |   performance_insights_kms_key_id = data.aws_kms_key.rds.arn
		788 |   vpc_security_group_ids          = [aws_security_group.rds.id]
		789 |   db_subnet_group_name            = aws_db_subnet_group.app.id
		790 |   skip_final_snapshot             = true
		791 |   storage_encrypted               = true
		792 |   allow_major_version_upgrade     = false
		793 | 
		794 |   tags = merge(
		795 |     local.tags,
		796 |     {
		797 |       Name = var.networking[0].application
		798 |     }
		799 |   )
		800 | }

Check: CKV_AWS_338: "Ensure CloudWatch log groups retains logs for at least 1 year"
	FAILED for resource: aws_cloudwatch_log_group.app
	File: /main.tf:806-817
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/bc-aws-338

		806 | resource "aws_cloudwatch_log_group" "app" {
		807 |   #checkov:skip=CKV_AWS_158
		808 |   name              = var.networking[0].application
		809 |   retention_in_days = 90
		810 | 
		811 |   tags = merge(
		812 |     local.tags,
		813 |     {
		814 |       Name = var.networking[0].application
		815 |     },
		816 |   )
		817 | }

Check: CKV_AWS_233: "Ensure Create before destroy for ACM certificates"
	FAILED for resource: aws_acm_certificate.us_east_1_test
	File: /main.tf:819-825
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-aws-acm-certificate-enables-create-before-destroy

		819 | resource "aws_acm_certificate" "us_east_1_test" {
		820 |   domain_name       = "test.modernisation-platform.service.justice.gov.uk"
		821 |   validation_method = "DNS"
		822 |   provider          = aws.us-east-1
		823 | 
		824 |   tags = local.tags
		825 | }

Check: CKV_TF_1: "Ensure Terraform module sources use a commit hash"
	FAILED for resource: pagerduty_core_alerts
	File: /monitoring.tf:44-51
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/supply-chain-policies/terraform-policies/ensure-terraform-module-sources-use-git-url-with-commit-hash-revision

		44 | module "pagerduty_core_alerts" {
		45 |   depends_on = [
		46 |     aws_sns_topic.sprinkler_ddos_alarm
		47 |   ]
		48 |   source                    = "github.com/ministryofjustice/modernisation-platform-terraform-pagerduty-integration?ref=v2.0.0"
		49 |   sns_topics                = [aws_sns_topic.sprinkler_ddos_alarm.name]
		50 |   pagerduty_integration_key = local.pagerduty_integration_keys["ddos_cloudwatch"]
		51 | }

Check: CKV_TF_1: "Ensure Terraform module sources use a commit hash"
	FAILED for resource: ssm-auto-patching
	File: /ssm.tf:1-17
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/supply-chain-policies/terraform-policies/ensure-terraform-module-sources-use-git-url-with-commit-hash-revision

		1  | module "ssm-auto-patching" {
		2  |   source = "github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0"
		3  |   providers = {
		4  |     aws.bucket-replication = aws
		5  |   }
		6  | 
		7  | 
		8  |   account_number   = local.environment_management.account_ids[terraform.workspace]
		9  |   application_name = local.application_name
		10 |   patch_schedule   = "cron(30 17 ? * MON *)"
		11 |   tags = merge(
		12 |     local.tags,
		13 |     {
		14 |       Name = "ssm-patching"
		15 |     },
		16 |   )
		17 | }

Check: CKV2_AWS_60: "Ensure RDS instance with copy tags to snapshots is enabled"
	FAILED for resource: aws_db_instance.app
	File: /main.tf:771-800
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-2-60

		771 | resource "aws_db_instance" "app" {
		772 |   # checkov:skip=CKV_AWS_118: "sprinkler does not need enhanced monitoring"
		773 |   # checkov:skip=CKV_AWS_129: "export to cloudwatch for logs is unneeded here"
		774 |   # checkov:skip=CKV_AWS_157: "multi-AZ deployment excessive for sprinkler"
		775 |   # checkov:skip=CKV_AWS_161: "IAM authentication excessive for sprinkler"
		776 |   # checkov:skip=CKV_AWS_226: "auto_upgrade_minor_version true by default"
		777 |   identifier                      = var.networking[0].application
		778 |   allocated_storage               = local.application_data.accounts[local.environment].rds_storage
		779 |   engine                          = "postgres"
		780 |   engine_version                  = local.application_data.accounts[local.environment].rds_postgresql_version
		781 |   instance_class                  = local.application_data.accounts[local.environment].rds_instance_class
		782 |   db_name                         = var.networking[0].application
		783 |   username                        = "dbmain"
		784 |   parameter_group_name            = aws_db_parameter_group.app.name
		785 |   password                        = random_password.db_master_password.result
		786 |   performance_insights_enabled    = true
		787 |   performance_insights_kms_key_id = data.aws_kms_key.rds.arn
		788 |   vpc_security_group_ids          = [aws_security_group.rds.id]
		789 |   db_subnet_group_name            = aws_db_subnet_group.app.id
		790 |   skip_final_snapshot             = true
		791 |   storage_encrypted               = true
		792 |   allow_major_version_upgrade     = false
		793 | 
		794 |   tags = merge(
		795 |     local.tags,
		796 |     {
		797 |       Name = var.networking[0].application
		798 |     }
		799 |   )
		800 | }

Check: CKV2_AWS_57: "Ensure Secrets Manager secrets should have automatic rotation enabled"
	FAILED for resource: aws_secretsmanager_secret.master_password
	File: /main.tf:739-749
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-2-57

		739 | resource "aws_secretsmanager_secret" "master_password" {
		740 |   # checkov:skip=CKV_AWS_149
		741 |   name = "${var.networking[0].application}-db-master-${random_string.secret_name_suffix.result}"
		742 | 
		743 |   tags = merge(
		744 |     local.tags,
		745 |     {
		746 |       Name = "${var.networking[0].application}-db-master-${random_string.secret_name_suffix.result}"
		747 |     },
		748 |   )
		749 | }


checkov_exitcode=3

CTFLint Scan Failed

Show Output
*****************************

Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version: 0.5.0)
tflint will check the following folders:
terraform/environments/cooker terraform/environments/example terraform/environments/sprinkler

*****************************

Running tflint in terraform/environments/cooker
Excluding the following checks: terraform_unused_declarations
1 issue(s) found:

Warning: Missing version constraint for provider "random" in `required_providers` (terraform_required_providers)

  on terraform/environments/cooker/main.tf line 681:
 681: resource "random_string" "secret_name_suffix" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.5.0/docs/rules/terraform_required_providers.md

tflint_exitcode=2

*****************************

Running tflint in terraform/environments/example
Excluding the following checks: terraform_unused_declarations
tflint_exitcode=2

*****************************

Running tflint in terraform/environments/sprinkler
Excluding the following checks: terraform_unused_declarations
1 issue(s) found:

Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)

  on terraform/environments/sprinkler/db_manager.tf line 50:
  50: data "template_cloudinit_config" "cloudinit-db-mgmt" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.5.0/docs/rules/terraform_required_providers.md

tflint_exitcode=4

Trivy Scan Failed

Show Output
*****************************

Trivy will check the following folders:
terraform/environments/cooker terraform/environments/example terraform/environments/sprinkler

*****************************

Running Trivy in terraform/environments/cooker
2024-05-20T11:02:06Z	INFO	Need to update DB
2024-05-20T11:02:06Z	INFO	Downloading DB...	repository="ghcr.io/aquasecurity/trivy-db:2"
2024-05-20T11:02:08Z	INFO	Vulnerability scanning is enabled
2024-05-20T11:02:08Z	INFO	Misconfiguration scanning is enabled
2024-05-20T11:02:08Z	INFO	Need to update the built-in policies
2024-05-20T11:02:08Z	INFO	Downloading the built-in policies...
50.41 KiB / 50.41 KiB [-----------------------------------------------------------] 100.00% ? p/s 0s2024-05-20T11:02:09Z	INFO	Secret scanning is enabled
2024-05-20T11:02:09Z	INFO	If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-05-20T11:02:09Z	INFO	Please see also https://aquasecurity.github.io/trivy/v0.51/docs/scanner/secret/#recommendation for faster secret detection
2024-05-20T11:02:09Z	INFO	Number of language-specific files	num=0
2024-05-20T11:02:09Z	INFO	Detected config files	num=2

main.tf (terraform)
===================
Tests: 20 (SUCCESSES: 13, FAILURES: 6, EXCEPTIONS: 1)
Failures: 6 (HIGH: 4, CRITICAL: 2)

HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise. 

By setting drop_invalid_header_fields to true, anything that doe not conform to well known, defined headers will be removed by the load balancer.

See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
 main.tf:408-423
────────────────────────────────────────
 408resource "aws_lb" "external" {
 409410name                       = "external-${var.networking[0].application}"
 411internal                   = false
 412load_balancer_type         = "application"
 413security_groups            = [aws_security_group.external_lb.id]
 414subnets                    = data.aws_subnets.shared-public.ids
 415enable_deletion_protection = false
 416...   
────────────────────────────────────────


HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise. 

By setting drop_invalid_header_fields to true, anything that doe not conform to well known, defined headers will be removed by the load balancer.

See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
 main.tf:548-563
────────────────────────────────────────
 548resource "aws_lb" "inner" {
 549550name                       = "inner-${var.networking[0].application}"
 551internal                   = true
 552load_balancer_type         = "application"
 553security_groups            = [aws_security_group.inner_lb.id]
 554subnets                    = data.aws_subnets.shared-private.ids
 555enable_deletion_protection = false
 556...   
────────────────────────────────────────


HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.

See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
 main.tf:411
   via main.tf:408-423 (aws_lb.external)
────────────────────────────────────────
 408   resource "aws_lb" "external" {
 ...   
 411 [   internal                   = false
 ...   
 423   }
────────────────────────────────────────


HIGH: Instance does not have storage encryption enabled.
════════════════════════════════════════
Encryption should be enabled for an RDS Database instances. 

When enabling encryption by setting the kms_key_id.

See https://avd.aquasec.com/misconfig/avd-aws-0080
────────────────────────────────────────
 main.tf:703-723
────────────────────────────────────────
 703resource "aws_db_instance" "app" {
 704705 │   identifier             = var.networking[0].application
 706 │   allocated_storage      = local.application_data.accounts[local.environment].rds_storage
 707 │   engine                 = "postgres"
 708 │   engine_version         = local.application_data.accounts[local.environment].rds_postgresql_version
 709 │   instance_class         = local.application_data.accounts[local.environment].rds_instance_class
 710 │   db_name                = var.networking[0].application
 711 └   username               = "dbmain"
 ...   
────────────────────────────────────────


CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
 main.tf:97
   via main.tf:90-98 (aws_security_group_rule.app_egress_1)
────────────────────────────────────────
  90   resource "aws_security_group_rule" "app_egress_1" {
  91   
  92     security_group_id = aws_security_group.app.id
  93     type              = "egress"
  94     from_port         = 0
  95     to_port           = 0
  96     protocol          = -1
  97 [   cidr_blocks       = ["0.0.0.0/0"]
  98   }
────────────────────────────────────────


CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
 main.tf:657
   via main.tf:650-658 (aws_security_group_rule.rds_egress_1)
────────────────────────────────────────
 650   resource "aws_security_group_rule" "rds_egress_1" {
 651   
 652     security_group_id = aws_security_group.rds.id
 653     type              = "egress"
 654     from_port         = 0
 655     to_port           = 0
 656     protocol          = -1
 657 [   cidr_blocks       = ["0.0.0.0/0"]
 658   }
────────────────────────────────────────


trivy_exitcode=1

*****************************

Running Trivy in terraform/environments/example
2024-05-20T11:02:10Z	INFO	Vulnerability scanning is enabled
2024-05-20T11:02:10Z	INFO	Misconfiguration scanning is enabled
2024-05-20T11:02:10Z	INFO	Secret scanning is enabled
2024-05-20T11:02:10Z	INFO	If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-05-20T11:02:10Z	INFO	Please see also https://aquasecurity.github.io/trivy/v0.51/docs/scanner/secret/#recommendation for faster secret detection
2024-05-20T11:02:17Z	INFO	Number of language-specific files	num=0
2024-05-20T11:02:17Z	INFO	Detected config files	num=16

ec2.tf (terraform)
==================
Tests: 8 (SUCCESSES: 5, FAILURES: 0, EXCEPTIONS: 3)
Failures: 0 (HIGH: 0, CRITICAL: 0)


ec2_autoscaling_group.tf (terraform)
====================================
Tests: 2 (SUCCESSES: 0, FAILURES: 0, EXCEPTIONS: 2)
Failures: 0 (HIGH: 0, CRITICAL: 0)


ec2_complete.tf (terraform)
===========================
Tests: 3 (SUCCESSES: 2, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (HIGH: 0, CRITICAL: 1)

CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
 ec2_complete.tf:235
   via ec2_complete.tf:227-236 (aws_security_group_rule.complete_egress_traffic["TCP_ALL"])
────────────────────────────────────────
 227   resource "aws_security_group_rule" "complete_egress_traffic" {
 228     for_each          = local.complete_ec2_sg_egress_rules
 229     description       = format("Outbound traffic for %s %d", each.value.protocol, each.value.from_port)
 230     from_port         = each.value.from_port
 231     protocol          = each.value.protocol
 232     security_group_id = aws_security_group.example_ec2_sg.id
 233     to_port           = each.value.to_port
 234     type              = "egress"
 235 [   cidr_blocks       = [each.value.cidr_block]
 236   }
────────────────────────────────────────



ecs.tf (terraform)
==================
Tests: 5 (SUCCESSES: 3, FAILURES: 1, EXCEPTIONS: 1)
Failures: 1 (HIGH: 0, CRITICAL: 1)

CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
 ecs.tf:209
   via ecs.tf:204-211 (content)
    via ecs.tf:202-212 (dynamic.egress["cluster_ec2_lb_egress"])
     via ecs.tf:186-214 (aws_security_group.cluster_ec2)
────────────────────────────────────────
 186   resource "aws_security_group" "cluster_ec2" {
 ...   
 209 [       cidr_blocks     = lookup(egress.value, "cidr_blocks", null)
 ...   
 214   }
────────────────────────────────────────



github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=95ed3c3f454e2014a62990aacd5d68c64d026f11/main.tf (terraform)
============================================================================================================================================
Tests: 7 (SUCCESSES: 5, FAILURES: 0, EXCEPTIONS: 2)
Failures: 0 (HIGH: 0, CRITICAL: 0)


github.com/ministryofjustice/modernisation-platform-terraform-ec2-autoscaling-group?ref=03913ac182decfc8224923520439d53d7c930661/main.tf (terraform)
====================================================================================================================================================
Tests: 2 (SUCCESSES: 1, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (HIGH: 1, CRITICAL: 0)

HIGH: Launch template does not require IMDS access to require a token
════════════════════════════════════════

IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional. 
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.


See https://avd.aquasec.com/misconfig/avd-aws-0130
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-ec2-autoscaling-group?ref=03913ac182decfc8224923520439d53d7c930661/main.tf:44
   via github.com/ministryofjustice/modernisation-platform-terraform-ec2-autoscaling-group?ref=03913ac182decfc8224923520439d53d7c930661/main.tf:40-45 (metadata_options)
    via github.com/ministryofjustice/modernisation-platform-terraform-ec2-autoscaling-group?ref=03913ac182decfc8224923520439d53d7c930661/main.tf:1-99 (aws_launch_template.this)
     via ec2_autoscaling_group.tf:1-29 (module.ec2_test_autoscaling_group["dev-rh-rhel79"])
────────────────────────────────────────
   1   resource "aws_launch_template" "this" {
   .   
  44 [     http_tokens = coalesce(var.instance.metadata_options_http_tokens, "required")
  ..   
  99   }
────────────────────────────────────────



github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf (terraform)
================================================================================================================================================================================================================================================================
Tests: 14 (SUCCESSES: 12, FAILURES: 2, EXCEPTIONS: 0)
Failures: 2 (HIGH: 2, CRITICAL: 0)

HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179
   via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:9-64 (module.s3-bucket[0])
    via ecs.tf:115-134 (module.ecs_lb_access_logs_enabled)
────────────────────────────────────────
 171 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
 172 │   bucket = aws_s3_bucket.default.id
 173 │   rule {
 174 │     apply_server_side_encryption_by_default {
 175 │       sse_algorithm     = var.sse_algorithm
 176 │       kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
 177 │     }
 178 │   }
 179 └ }
────────────────────────────────────────


HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179
   via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:9-64 (module.s3-bucket[0])
    via loadbalancer_module.tf:2-21 (module.lb_access_logs_enabled)
────────────────────────────────────────
 171 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
 172 │   bucket = aws_s3_bucket.default.id
 173 │   rule {
 174 │     apply_server_side_encryption_by_default {
 175 │       sse_algorithm     = var.sse_algorithm
 176 │       kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
 177 │     }
 178 │   }
 179 └ }
────────────────────────────────────────



github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf (terraform)
===========================================================================================================================================
Tests: 16 (SUCCESSES: 10, FAILURES: 4, EXCEPTIONS: 2)
Failures: 4 (HIGH: 2, CRITICAL: 2)

HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.

See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:148
   via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:144-175 (aws_lb.loadbalancer)
    via ecs.tf:115-134 (module.ecs_lb_access_logs_enabled)
────────────────────────────────────────
 144   resource "aws_lb" "loadbalancer" {
 ...   
 148 [   internal                         = var.internal_lb
 ...   
 175   }
────────────────────────────────────────


HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.

See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:148
   via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:144-175 (aws_lb.loadbalancer)
    via loadbalancer_module.tf:2-21 (module.lb_access_logs_enabled)
────────────────────────────────────────
 144   resource "aws_lb" "loadbalancer" {
 ...   
 148 [   internal                         = var.internal_lb
 ...   
 175   }
────────────────────────────────────────


CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:202
   via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:197-204 (content)
    via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:195-205 (dynamic.egress["cluster_ec2_lb_egress"])
     via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:177-213 (aws_security_group.lb[0])
      via ecs.tf:115-134 (module.ecs_lb_access_logs_enabled)
────────────────────────────────────────
 177   resource "aws_security_group" "lb" {
 ...   
 202 [       cidr_blocks     = lookup(egress.value, "cidr_blocks", null)
 ...   
 213   }
────────────────────────────────────────


CRITICAL: Security group rule allows egress to multiple public internet addresses.
════════════════════════════════════════
Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0104
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:202
   via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:197-204 (content)
    via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:195-205 (dynamic.egress["cluster_ec2_lb_egress"])
     via github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer?ref=6f59e1ce47df66bc63ee9720b7c58993d1ee64ee/main.tf:177-213 (aws_security_group.lb[0])
      via loadbalancer_module.tf:2-21 (module.lb_access_logs_enabled)
────────────────────────────────────────
 177   resource "aws_security_group" "lb" {
 ...   
 202 [       cidr_blocks     = lookup(egress.value, "cidr_blocks", null)
 ...   
 213   }
────────────────────────────────────────



github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf (terraform)
========================================================================================================================================
Tests: 14 (SUCCESSES: 12, FAILURES: 2, EXCEPTIONS: 0)
Failures: 2 (HIGH: 2, CRITICAL: 0)

HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179
   via s3.tf:8-72 (module.s3-bucket)
────────────────────────────────────────
 171 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
 172 │   bucket = aws_s3_bucket.default.id
 173 │   rule {
 174 │     apply_server_side_encryption_by_default {
 175 │       sse_algorithm     = var.sse_algorithm
 176 │       kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
 177 │     }
 178 │   }
 179 └ }
────────────────────────────────────────


HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179
   via loadbalancer.tf:185-248 (module.s3-bucket-lb)
────────────────────────────────────────
 171 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
 172 │   bucket = aws_s3_bucket.default.id
 173 │   rule {
 174 │     apply_server_side_encryption_by_default {
 175 │       sse_algorithm     = var.sse_algorithm
 176 │       kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
 177 │     }
 178 │   }
 179 └ }
────────────────────────────────────────



loadbalancer.tf (terraform)
===========================
Tests: 7 (SUCCESSES: 5, FAILURES: 1, EXCEPTIONS: 1)
Failures: 1 (HIGH: 1, CRITICAL: 0)

HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.

See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
 loadbalancer.tf:328-345
────────────────────────────────────────
 328 ┌ resource "aws_instance" "lb_example_instance" {
 329#checkov:skip=CKV2_AWS_41:"IAM role is not implemented for this example EC2. SSH/AWS keys are not used either."
 330#checkov:skip=CKV_AWS_8: "Encryption not required for example instance"
 331# Specify the instance type and ami to be used (this is the Amazon free tier option)
 332 │   instance_type          = local.application_data.accounts[local.environment].instance_type
 333 │   ami                    = local.application_data.accounts[local.environment].ami_image_id
 334 │   vpc_security_group_ids = [aws_security_group.example_load_balancer_sg.id]
 335 │   subnet_id              = data.aws_subnet.private_subnets_a.id
 336 └   monitoring             = true
 ...   
────────────────────────────────────────


trivy_exitcode=2

*****************************

Running Trivy in terraform/environments/sprinkler
2024-05-20T11:02:17Z	INFO	Vulnerability scanning is enabled
2024-05-20T11:02:17Z	INFO	Misconfiguration scanning is enabled
2024-05-20T11:02:17Z	INFO	Secret scanning is enabled
2024-05-20T11:02:17Z	INFO	If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-05-20T11:02:17Z	INFO	Please see also https://aquasecurity.github.io/trivy/v0.51/docs/scanner/secret/#recommendation for faster secret detection
2024-05-20T11:02:21Z	INFO	Number of language-specific files	num=0
2024-05-20T11:02:21Z	INFO	Detected config files	num=9

db_manager.tf (terraform)
=========================
Tests: 9 (SUCCESSES: 4, FAILURES: 0, EXCEPTIONS: 5)
Failures: 0 (HIGH: 0, CRITICAL: 0)


github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.1/main.tf (terraform)
==========================================================================================================
Tests: 7 (SUCCESSES: 5, FAILURES: 0, EXCEPTIONS: 2)
Failures: 0 (HIGH: 0, CRITICAL: 0)


github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.0.0/main.tf (terraform)
================================================================================================================================================================================================
Tests: 7 (SUCCESSES: 6, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (HIGH: 1, CRITICAL: 0)

HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
 github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.0.0/main.tf:157-165
   via github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0/main.tf:3-57 (module.s3-bucket[0])
    via ssm.tf:1-17 (module.ssm-auto-patching)
────────────────────────────────────────
 157 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
 158 │   bucket = aws_s3_bucket.default.id
 159 │   rule {
 160 │     apply_server_side_encryption_by_default {
 161 │       sse_algorithm     = var.sse_algorithm
 162 │       kms_master_key_id = (var.custom_kms_key != "") ? var.custom_kms_key : ""
 163 │     }
 164 │   }
 165 └ }
────────────────────────────────────────



github.com/ministryofjustice/modernisation-platform-terraform-ssm-patching.git?ref=v1.0.0/main.tf (terraform)
=============================================================================================================
Tests: 2 (SUCCESSES: 0, FAILURES: 0, EXCEPTIONS: 2)
Failures: 0 (HIGH: 0, CRITICAL: 0)


main.tf (terraform)
===================
Tests: 20 (SUCCESSES: 17, FAILURES: 0, EXCEPTIONS: 3)
Failures: 0 (HIGH: 0, CRITICAL: 0)

trivy_exitcode=3

@dms1981 dms1981 had a problem deploying to example-development May 20, 2024 11:03 — with GitHub Actions Failure
@dms1981 dms1981 had a problem deploying to example-development May 20, 2024 11:05 — with GitHub Actions Failure
@dms1981 dms1981 merged commit acbd01f into main May 20, 2024
35 of 41 checks passed
@dms1981 dms1981 deleted the feature/upgrade-mp-ssl-policies branch May 20, 2024 11:09
@dms1981 dms1981 had a problem deploying to example-development May 20, 2024 11:10 — with GitHub Actions Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
environments-repository Used to exclude PRs from this repo in our Slack PR update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants