You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-11-28T12:52:57Z INFO [vulndb] Need to update DB
2024-11-28T12:52:57Z INFO [vulndb] Downloading vulnerability DB...
2024-11-28T12:52:57Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T12:53:00Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T12:53:00Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T12:53:00Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T12:53:00Z INFO [misconfig] Need to update the built-in checks
2024-11-28T12:53:00Z INFO [misconfig] Downloading the built-in checks...
2024-11-28T12:53:00Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 906.318µs, allowed: 44000/minute\n\n"
2024-11-28T12:53:00Z INFO [secret] Secret scanning is enabled
2024-11-28T12:53:00Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T12:53:00Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-28T12:53:01Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-28T12:53:01Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-28T12:53:01Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T12:53:01Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T12:53:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-11-28T12:53:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-11-28T12:53:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-11-28T12:53:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-11-28T12:53:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-11-28T12:53:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-11-28T12:53:02Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T12:53:02Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T12:53:02Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-11-28T12:53:02Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T12:53:02Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-11-28T12:53:02Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T12:53:03Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:210-234"
2024-11-28T12:53:03Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-11-28T12:53:03Z INFO Number of language-specific files num=0
2024-11-28T12:53:03Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 123:123: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 177:177: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-11-28T12:52:57Z INFO [vulndb] Need to update DB
2024-11-28T12:52:57Z INFO [vulndb] Downloading vulnerability DB...2024-11-28T12:52:57Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T12:53:00Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T12:53:00Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T12:53:00Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T12:53:00Z INFO [misconfig] Need to update the built-in checks
2024-11-28T12:53:00Z INFO [misconfig] Downloading the built-in checks...2024-11-28T12:53:00Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 906.318µs, allowed: 44000/minute\n\n"2024-11-28T12:53:00Z INFO [secret] Secret scanning is enabled
2024-11-28T12:53:00Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T12:53:00Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-11-28T12:53:01Z INFO [terraformscanner] Scanning root module file_path="."2024-11-28T12:53:01Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-28T12:53:01Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T12:53:01Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T12:53:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-11-28T12:53:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-11-28T12:53:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-11-28T12:53:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-11-28T12:53:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-11-28T12:53:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-11-28T12:53:02Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T12:53:02Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T12:53:02Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-11-28T12:53:02Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T12:53:02Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-11-28T12:53:02Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T12:53:03Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:210-234"2024-11-28T12:53:03Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-11-28T12:53:03Z INFO Number of language-specific files num=02024-11-28T12:53:03Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:241-245
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...241 ┌ viewer_certificate {
242 │ acm_certificate_arn=aws_acm_certificate.cloudfront.arn243 │ ssl_support_method="sni-only"244 │ minimum_protocol_version="TLSv1.2_2018"245 └ }
...267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket=aws_s3_bucket.cloudfront.id133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource"aws_instance""apex_db_instance" {
7 │ ami=local.application_data.accounts[local.environment].ec2amiid8 │ associate_public_ip_address=false9 │ availability_zone="eu-west-2a"10 │ ebs_optimized=true11 │ instance_type=local.application_data.accounts[local.environment].ec2instancetype12 │ vpc_security_group_ids=[aws_security_group.database.id]
13 │ monitoring=true14 └ subnet_id=data.aws_subnet.data_subnets_a.id..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""backup_lambda" {
102 │ bucket="${local.application_name}-${local.environment}-backup-lambda"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""backup_lambda" {
102 │ bucket="${local.application_name}-${local.environment}-backup-lambda"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:119-123
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107resource"aws_launch_template""ec2-launch-template" {
...119 ┌ metadata_options {
120 │ http_endpoint="enabled"121 │ http_tokens="optional"122 │ http_put_response_hop_limit="2"123 └ }
...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-11-28T12:53:55Z INFO [vulndb] Need to update DB
2024-11-28T12:53:55Z INFO [vulndb] Downloading vulnerability DB...
2024-11-28T12:53:55Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T12:53:59Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T12:53:59Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T12:53:59Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T12:53:59Z INFO [misconfig] Need to update the built-in checks
2024-11-28T12:53:59Z INFO [misconfig] Downloading the built-in checks...
160.25 KiB / 160.25 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-11-28T12:53:59Z INFO [secret] Secret scanning is enabled
2024-11-28T12:53:59Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T12:53:59Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-28T12:54:00Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-28T12:54:00Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-28T12:54:00Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T12:54:00Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T12:54:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-11-28T12:54:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-11-28T12:54:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-11-28T12:54:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-11-28T12:54:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-11-28T12:54:01Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-11-28T12:54:01Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T12:54:01Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T12:54:01Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-11-28T12:54:01Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T12:54:01Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-11-28T12:54:01Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T12:54:02Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-11-28T12:54:02Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:214"
2024-11-28T12:54:03Z INFO Number of language-specific files num=0
2024-11-28T12:54:03Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource "aws_cloudfront_distribution" "external" {
...
244 [ minimum_protocol_version = "TLSv1.2_2018"
...
267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template" "ec2-launch-template" {
...
121 [ http_tokens = "optional"
...
164 }
────────────────────────────────────────
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 123:123: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 177:177: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-11-28T12:53:55Z INFO [vulndb] Need to update DB
2024-11-28T12:53:55Z INFO [vulndb] Downloading vulnerability DB...2024-11-28T12:53:55Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T12:53:59Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T12:53:59Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T12:53:59Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T12:53:59Z INFO [misconfig] Need to update the built-in checks
2024-11-28T12:53:59Z INFO [misconfig] Downloading the built-in checks...160.25 KiB /160.25 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-11-28T12:53:59Z INFO [secret] Secret scanning is enabled
2024-11-28T12:53:59Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T12:53:59Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-11-28T12:54:00Z INFO [terraformscanner] Scanning root module file_path="."2024-11-28T12:54:00Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-28T12:54:00Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T12:54:00Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T12:54:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-11-28T12:54:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-11-28T12:54:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-11-28T12:54:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-11-28T12:54:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-11-28T12:54:01Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-11-28T12:54:01Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T12:54:01Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T12:54:01Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-11-28T12:54:01Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T12:54:01Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-11-28T12:54:01Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T12:54:02Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-11-28T12:54:02Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:214"2024-11-28T12:54:03Z INFO Number of language-specific files num=02024-11-28T12:54:03Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...244 [ minimum_protocol_version = "TLSv1.2_2018"...267 }
────────────────────────────────────────
AVD-AWS-0132 (HIGH):Bucketdoesnotencryptdatawithacustomermanagedkey.
════════════════════════════════════════
EncryptionusingAWSkeysprovidesprotectionforyourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.Seehttps://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm ="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource "aws_instance""apex_db_instance" {
7 │ ami = local.application_data.accounts[local.environment].ec2amiid
8 │ associate_public_ip_address =false9 │ availability_zone ="eu-west-2a"10 │ ebs_optimized =true11 │ instance_type = local.application_data.accounts[local.environment].ec2instancetype
12 │ vpc_security_group_ids = [aws_security_group.database.id]
13 │ monitoring =true14 └ subnet_id = data.aws_subnet.data_subnets_a.id
..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""backup_lambda" {
102 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""backup_lambda" {
102 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template""ec2-launch-template" {
...121 [ http_tokens ="optional"...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-11-28T13:09:06Z INFO [vulndb] Need to update DB
2024-11-28T13:09:06Z INFO [vulndb] Downloading vulnerability DB...
2024-11-28T13:09:06Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T13:09:08Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T13:09:08Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T13:09:08Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T13:09:08Z INFO [misconfig] Need to update the built-in checks
2024-11-28T13:09:08Z INFO [misconfig] Downloading the built-in checks...
160.25 KiB / 160.25 KiB [---------------------------------------------------------] 100.00% ? p/s 0s2024-11-28T13:09:08Z INFO [secret] Secret scanning is enabled
2024-11-28T13:09:08Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T13:09:08Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-28T13:09:09Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-28T13:09:09Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-28T13:09:09Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T13:09:09Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T13:09:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-11-28T13:09:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-11-28T13:09:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-11-28T13:09:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-11-28T13:09:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-11-28T13:09:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-11-28T13:09:10Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T13:09:10Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T13:09:10Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-11-28T13:09:10Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T13:09:10Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-11-28T13:09:10Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T13:09:11Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-11-28T13:09:11Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:214"
2024-11-28T13:09:12Z INFO Number of language-specific files num=0
2024-11-28T13:09:12Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource "aws_cloudfront_distribution" "external" {
...
244 [ minimum_protocol_version = "TLSv1.2_2018"
...
267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template" "ec2-launch-template" {
...
121 [ http_tokens = "optional"
...
164 }
────────────────────────────────────────
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 119:119: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 173:173: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-11-28T13:09:06Z INFO [vulndb] Need to update DB
2024-11-28T13:09:06Z INFO [vulndb] Downloading vulnerability DB...2024-11-28T13:09:06Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T13:09:08Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T13:09:08Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T13:09:08Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T13:09:08Z INFO [misconfig] Need to update the built-in checks
2024-11-28T13:09:08Z INFO [misconfig] Downloading the built-in checks...160.25 KiB /160.25 KiB [---------------------------------------------------------] 100.00%? p/s 0s2024-11-28T13:09:08Z INFO [secret] Secret scanning is enabled
2024-11-28T13:09:08Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T13:09:08Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-11-28T13:09:09Z INFO [terraformscanner] Scanning root module file_path="."2024-11-28T13:09:09Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-28T13:09:09Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T13:09:09Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T13:09:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-11-28T13:09:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-11-28T13:09:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-11-28T13:09:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-11-28T13:09:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-11-28T13:09:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-11-28T13:09:10Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T13:09:10Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T13:09:10Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-11-28T13:09:10Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T13:09:10Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-11-28T13:09:10Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T13:09:11Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-11-28T13:09:11Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:214"2024-11-28T13:09:12Z INFO Number of language-specific files num=02024-11-28T13:09:12Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...244 [ minimum_protocol_version = "TLSv1.2_2018"...267 }
────────────────────────────────────────
AVD-AWS-0132 (HIGH):Bucketdoesnotencryptdatawithacustomermanagedkey.
════════════════════════════════════════
EncryptionusingAWSkeysprovidesprotectionforyourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.Seehttps://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm ="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource "aws_instance""apex_db_instance" {
7 │ ami = local.application_data.accounts[local.environment].ec2amiid
8 │ associate_public_ip_address =false9 │ availability_zone ="eu-west-2a"10 │ ebs_optimized =true11 │ instance_type = local.application_data.accounts[local.environment].ec2instancetype
12 │ vpc_security_group_ids = [aws_security_group.database.id]
13 │ monitoring =true14 └ subnet_id = data.aws_subnet.data_subnets_a.id
..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""backup_lambda" {
102 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""backup_lambda" {
102 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template""ec2-launch-template" {
...121 [ http_tokens ="optional"...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-11-28T14:12:43Z INFO [vulndb] Need to update DB
2024-11-28T14:12:43Z INFO [vulndb] Downloading vulnerability DB...
2024-11-28T14:12:43Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T14:12:46Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T14:12:46Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T14:12:46Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T14:12:46Z INFO [misconfig] Need to update the built-in checks
2024-11-28T14:12:46Z INFO [misconfig] Downloading the built-in checks...
2024-11-28T14:12:46Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 831.067µs, allowed: 44000/minute\n\n"
2024-11-28T14:12:46Z INFO [secret] Secret scanning is enabled
2024-11-28T14:12:46Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T14:12:46Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-28T14:12:47Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-28T14:12:47Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-28T14:12:47Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T14:12:47Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T14:12:47Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-11-28T14:12:47Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-11-28T14:12:47Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-11-28T14:12:47Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-11-28T14:12:47Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-11-28T14:12:47Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-11-28T14:12:48Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T14:12:48Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T14:12:48Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-11-28T14:12:48Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T14:12:48Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-11-28T14:12:48Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T14:12:49Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:210-234"
2024-11-28T14:12:49Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-11-28T14:12:49Z INFO Number of language-specific files num=0
2024-11-28T14:12:49Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 119:119: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 173:173: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-11-28T14:12:43Z INFO [vulndb] Need to update DB
2024-11-28T14:12:43Z INFO [vulndb] Downloading vulnerability DB...2024-11-28T14:12:43Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T14:12:46Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T14:12:46Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T14:12:46Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T14:12:46Z INFO [misconfig] Need to update the built-in checks
2024-11-28T14:12:46Z INFO [misconfig] Downloading the built-in checks...2024-11-28T14:12:46Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 831.067µs, allowed: 44000/minute\n\n"2024-11-28T14:12:46Z INFO [secret] Secret scanning is enabled
2024-11-28T14:12:46Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T14:12:46Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-11-28T14:12:47Z INFO [terraformscanner] Scanning root module file_path="."2024-11-28T14:12:47Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-28T14:12:47Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T14:12:47Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T14:12:47Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-11-28T14:12:47Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-11-28T14:12:47Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-11-28T14:12:47Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-11-28T14:12:47Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-11-28T14:12:47Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-11-28T14:12:48Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T14:12:48Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T14:12:48Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-11-28T14:12:48Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T14:12:48Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-11-28T14:12:48Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T14:12:49Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:210-234"2024-11-28T14:12:49Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-11-28T14:12:49Z INFO Number of language-specific files num=02024-11-28T14:12:49Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:241-245
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...241 ┌ viewer_certificate {
242 │ acm_certificate_arn=aws_acm_certificate.cloudfront.arn243 │ ssl_support_method="sni-only"244 │ minimum_protocol_version="TLSv1.2_2018"245 └ }
...267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket=aws_s3_bucket.cloudfront.id133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource"aws_instance""apex_db_instance" {
7 │ ami=local.application_data.accounts[local.environment].ec2amiid8 │ associate_public_ip_address=false9 │ availability_zone="eu-west-2a"10 │ ebs_optimized=true11 │ instance_type=local.application_data.accounts[local.environment].ec2instancetype12 │ vpc_security_group_ids=[aws_security_group.database.id]
13 │ monitoring=true14 └ subnet_id=data.aws_subnet.data_subnets_a.id..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""backup_lambda" {
102 │ bucket="${local.application_name}-${local.environment}-backup-lambda"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""backup_lambda" {
102 │ bucket="${local.application_name}-${local.environment}-backup-lambda"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:119-123
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107resource"aws_launch_template""ec2-launch-template" {
...119 ┌ metadata_options {
120 │ http_endpoint="enabled"121 │ http_tokens="optional"122 │ http_put_response_hop_limit="2"123 └ }
...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-11-28T14:50:48Z INFO [vulndb] Need to update DB
2024-11-28T14:50:48Z INFO [vulndb] Downloading vulnerability DB...
2024-11-28T14:50:48Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T14:50:51Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T14:50:51Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T14:50:51Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T14:50:51Z INFO [misconfig] Need to update the built-in checks
2024-11-28T14:50:51Z INFO [misconfig] Downloading the built-in checks...
2024-11-28T14:50:51Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:16442a4593a0395452e678ef699a880eec94d9211dfc887d52574beb78b95030: TOOMANYREQUESTS: retry-after: 629.901µs, allowed: 44000/minute"
2024-11-28T14:50:51Z INFO [secret] Secret scanning is enabled
2024-11-28T14:50:51Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T14:50:51Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-28T14:50:52Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-28T14:50:52Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-28T14:50:52Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T14:50:52Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T14:50:53Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-11-28T14:50:53Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-11-28T14:50:53Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-11-28T14:50:53Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-11-28T14:50:53Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-11-28T14:50:53Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-11-28T14:50:54Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T14:50:54Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T14:50:54Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-11-28T14:50:54Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T14:50:54Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-11-28T14:50:54Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T14:50:55Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:210-234"
2024-11-28T14:50:55Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-11-28T14:50:55Z INFO Number of language-specific files num=0
2024-11-28T14:50:55Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 119:119: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 173:173: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-11-28T14:50:48Z INFO [vulndb] Need to update DB
2024-11-28T14:50:48Z INFO [vulndb] Downloading vulnerability DB...2024-11-28T14:50:48Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T14:50:51Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T14:50:51Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T14:50:51Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T14:50:51Z INFO [misconfig] Need to update the built-in checks
2024-11-28T14:50:51Z INFO [misconfig] Downloading the built-in checks...2024-11-28T14:50:51Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:16442a4593a0395452e678ef699a880eec94d9211dfc887d52574beb78b95030: TOOMANYREQUESTS: retry-after: 629.901µs, allowed: 44000/minute"2024-11-28T14:50:51Z INFO [secret] Secret scanning is enabled
2024-11-28T14:50:51Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T14:50:51Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-11-28T14:50:52Z INFO [terraformscanner] Scanning root module file_path="."2024-11-28T14:50:52Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-28T14:50:52Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T14:50:52Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T14:50:53Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-11-28T14:50:53Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-11-28T14:50:53Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-11-28T14:50:53Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-11-28T14:50:53Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-11-28T14:50:53Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-11-28T14:50:54Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T14:50:54Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T14:50:54Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-11-28T14:50:54Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T14:50:54Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-11-28T14:50:54Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T14:50:55Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:210-234"2024-11-28T14:50:55Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-11-28T14:50:55Z INFO Number of language-specific files num=02024-11-28T14:50:55Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:241-245
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...241 ┌ viewer_certificate {
242 │ acm_certificate_arn=aws_acm_certificate.cloudfront.arn243 │ ssl_support_method="sni-only"244 │ minimum_protocol_version="TLSv1.2_2018"245 └ }
...267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket=aws_s3_bucket.cloudfront.id133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource"aws_instance""apex_db_instance" {
7 │ ami=local.application_data.accounts[local.environment].ec2amiid8 │ associate_public_ip_address=false9 │ availability_zone="eu-west-2a"10 │ ebs_optimized=true11 │ instance_type=local.application_data.accounts[local.environment].ec2instancetype12 │ vpc_security_group_ids=[aws_security_group.database.id]
13 │ monitoring=true14 └ subnet_id=data.aws_subnet.data_subnets_a.id..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""backup_lambda" {
102 │ bucket="${local.application_name}-${local.environment}-backup-lambda"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""backup_lambda" {
102 │ bucket="${local.application_name}-${local.environment}-backup-lambda"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
106 │ )
107 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:119-123
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107resource"aws_launch_template""ec2-launch-template" {
...119 ┌ metadata_options {
120 │ http_endpoint="enabled"121 │ http_tokens="optional"122 │ http_put_response_hop_limit="2"123 └ }
...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-11-28T15:35:03Z INFO [vulndb] Need to update DB
2024-11-28T15:35:03Z INFO [vulndb] Downloading vulnerability DB...
2024-11-28T15:35:03Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T15:35:06Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T15:35:06Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T15:35:06Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T15:35:06Z INFO [misconfig] Need to update the built-in checks
2024-11-28T15:35:06Z INFO [misconfig] Downloading the built-in checks...
2024-11-28T15:35:06Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:16442a4593a0395452e678ef699a880eec94d9211dfc887d52574beb78b95030: TOOMANYREQUESTS: retry-after: 472.128µs, allowed: 44000/minute"
2024-11-28T15:35:06Z INFO [secret] Secret scanning is enabled
2024-11-28T15:35:06Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T15:35:06Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-28T15:35:08Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-28T15:35:08Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-28T15:35:08Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:35:08Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:35:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-11-28T15:35:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-11-28T15:35:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-11-28T15:35:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-11-28T15:35:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-11-28T15:35:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-11-28T15:35:09Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:35:09Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:35:09Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-11-28T15:35:09Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T15:35:09Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-11-28T15:35:09Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T15:35:10Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:210-234"
2024-11-28T15:35:10Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-11-28T15:35:10Z INFO Number of language-specific files num=0
2024-11-28T15:35:10Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 125:125: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 179:179: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-11-28T15:35:03Z INFO [vulndb] Need to update DB
2024-11-28T15:35:03Z INFO [vulndb] Downloading vulnerability DB...2024-11-28T15:35:03Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T15:35:06Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T15:35:06Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T15:35:06Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T15:35:06Z INFO [misconfig] Need to update the built-in checks
2024-11-28T15:35:06Z INFO [misconfig] Downloading the built-in checks...2024-11-28T15:35:06Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:16442a4593a0395452e678ef699a880eec94d9211dfc887d52574beb78b95030: TOOMANYREQUESTS: retry-after: 472.128µs, allowed: 44000/minute"2024-11-28T15:35:06Z INFO [secret] Secret scanning is enabled
2024-11-28T15:35:06Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T15:35:06Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-11-28T15:35:08Z INFO [terraformscanner] Scanning root module file_path="."2024-11-28T15:35:08Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-28T15:35:08Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:35:08Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:35:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-11-28T15:35:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-11-28T15:35:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-11-28T15:35:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-11-28T15:35:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-11-28T15:35:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-11-28T15:35:09Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:35:09Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:35:09Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-11-28T15:35:09Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T15:35:09Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-11-28T15:35:09Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T15:35:10Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:210-234"2024-11-28T15:35:10Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-11-28T15:35:10Z INFO Number of language-specific files num=02024-11-28T15:35:10Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:241-245
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...241 ┌ viewer_certificate {
242 │ acm_certificate_arn=aws_acm_certificate.cloudfront.arn243 │ ssl_support_method="sni-only"244 │ minimum_protocol_version="TLSv1.2_2018"245 └ }
...267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket=aws_s3_bucket.cloudfront.id133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource"aws_instance""apex_db_instance" {
7 │ ami=local.application_data.accounts[local.environment].ec2amiid8 │ associate_public_ip_address=false9 │ availability_zone="eu-west-2a"10 │ ebs_optimized=true11 │ instance_type=local.application_data.accounts[local.environment].ec2instancetype12 │ vpc_security_group_ids=[aws_security_group.database.id]
13 │ monitoring=true14 └ subnet_id=data.aws_subnet.data_subnets_a.id..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource"aws_s3_bucket""backup_lambda" {
108 │ bucket="${local.application_name}-${local.environment}-backup-lambda"109 │ tags=merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource"aws_s3_bucket""backup_lambda" {
108 │ bucket="${local.application_name}-${local.environment}-backup-lambda"109 │ tags=merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:119-123
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107resource"aws_launch_template""ec2-launch-template" {
...119 ┌ metadata_options {
120 │ http_endpoint="enabled"121 │ http_tokens="optional"122 │ http_put_response_hop_limit="2"123 └ }
...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-11-28T15:46:01Z INFO [vulndb] Need to update DB
2024-11-28T15:46:01Z INFO [vulndb] Downloading vulnerability DB...
2024-11-28T15:46:01Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T15:46:03Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T15:46:03Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T15:46:03Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T15:46:03Z INFO [misconfig] Need to update the built-in checks
2024-11-28T15:46:03Z INFO [misconfig] Downloading the built-in checks...
160.25 KiB / 160.25 KiB [---------------------------------------------------------] 100.00% ? p/s 0s2024-11-28T15:46:04Z INFO [secret] Secret scanning is enabled
2024-11-28T15:46:04Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T15:46:04Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-28T15:46:05Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-28T15:46:05Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-28T15:46:05Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:46:05Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:46:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-11-28T15:46:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-11-28T15:46:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-11-28T15:46:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-11-28T15:46:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-11-28T15:46:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-11-28T15:46:06Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:46:06Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:46:06Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-11-28T15:46:06Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T15:46:06Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-11-28T15:46:06Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T15:46:08Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:214"
2024-11-28T15:46:08Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-11-28T15:46:08Z INFO Number of language-specific files num=0
2024-11-28T15:46:08Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource "aws_cloudfront_distribution" "external" {
...
244 [ minimum_protocol_version = "TLSv1.2_2018"
...
267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template" "ec2-launch-template" {
...
121 [ http_tokens = "optional"
...
164 }
────────────────────────────────────────
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 125:125: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 179:179: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-11-28T15:46:01Z INFO [vulndb] Need to update DB
2024-11-28T15:46:01Z INFO [vulndb] Downloading vulnerability DB...2024-11-28T15:46:01Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T15:46:03Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T15:46:03Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T15:46:03Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T15:46:03Z INFO [misconfig] Need to update the built-in checks
2024-11-28T15:46:03Z INFO [misconfig] Downloading the built-in checks...160.25 KiB /160.25 KiB [---------------------------------------------------------] 100.00%? p/s 0s2024-11-28T15:46:04Z INFO [secret] Secret scanning is enabled
2024-11-28T15:46:04Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T15:46:04Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-11-28T15:46:05Z INFO [terraformscanner] Scanning root module file_path="."2024-11-28T15:46:05Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-28T15:46:05Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:46:05Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:46:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-11-28T15:46:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-11-28T15:46:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-11-28T15:46:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-11-28T15:46:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-11-28T15:46:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-11-28T15:46:06Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:46:06Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:46:06Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-11-28T15:46:06Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T15:46:06Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-11-28T15:46:06Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T15:46:08Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:214"2024-11-28T15:46:08Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-11-28T15:46:08Z INFO Number of language-specific files num=02024-11-28T15:46:08Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...244 [ minimum_protocol_version = "TLSv1.2_2018"...267 }
────────────────────────────────────────
AVD-AWS-0132 (HIGH):Bucketdoesnotencryptdatawithacustomermanagedkey.
════════════════════════════════════════
EncryptionusingAWSkeysprovidesprotectionforyourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.Seehttps://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm ="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource "aws_instance""apex_db_instance" {
7 │ ami = local.application_data.accounts[local.environment].ec2amiid
8 │ associate_public_ip_address =false9 │ availability_zone ="eu-west-2a"10 │ ebs_optimized =true11 │ instance_type = local.application_data.accounts[local.environment].ec2instancetype
12 │ vpc_security_group_ids = [aws_security_group.database.id]
13 │ monitoring =true14 └ subnet_id = data.aws_subnet.data_subnets_a.id
..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource "aws_s3_bucket""backup_lambda" {
108 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"109 │ tags =merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource "aws_s3_bucket""backup_lambda" {
108 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"109 │ tags =merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template""ec2-launch-template" {
...121 [ http_tokens ="optional"...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-11-28T15:48:18Z INFO [vulndb] Need to update DB
2024-11-28T15:48:18Z INFO [vulndb] Downloading vulnerability DB...
2024-11-28T15:48:18Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T15:48:21Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-28T15:48:21Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T15:48:21Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T15:48:21Z INFO [misconfig] Need to update the built-in checks
2024-11-28T15:48:21Z INFO [misconfig] Downloading the built-in checks...
2024-11-28T15:48:21Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:16442a4593a0395452e678ef699a880eec94d9211dfc887d52574beb78b95030: TOOMANYREQUESTS: retry-after: 713.884µs, allowed: 44000/minute"
2024-11-28T15:48:21Z INFO [secret] Secret scanning is enabled
2024-11-28T15:48:21Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T15:48:21Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-28T15:48:22Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-28T15:48:22Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-28T15:48:22Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:48:22Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:48:23Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-11-28T15:48:23Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-11-28T15:48:23Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-11-28T15:48:23Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-11-28T15:48:23Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-11-28T15:48:23Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-11-28T15:48:23Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:48:23Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-11-28T15:48:23Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-11-28T15:48:23Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T15:48:23Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-11-28T15:48:23Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-11-28T15:48:24Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-11-28T15:48:24Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:210-234"
2024-11-28T15:48:25Z INFO Number of language-specific files num=0
2024-11-28T15:48:25Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 125:125: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 179:179: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-11-28T15:48:18Z INFO [vulndb] Need to update DB
2024-11-28T15:48:18Z INFO [vulndb] Downloading vulnerability DB...2024-11-28T15:48:18Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T15:48:21Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-28T15:48:21Z INFO [vuln] Vulnerability scanning is enabled
2024-11-28T15:48:21Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-28T15:48:21Z INFO [misconfig] Need to update the built-in checks
2024-11-28T15:48:21Z INFO [misconfig] Downloading the built-in checks...2024-11-28T15:48:21Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:16442a4593a0395452e678ef699a880eec94d9211dfc887d52574beb78b95030: TOOMANYREQUESTS: retry-after: 713.884µs, allowed: 44000/minute"2024-11-28T15:48:21Z INFO [secret] Secret scanning is enabled
2024-11-28T15:48:21Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-28T15:48:21Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-11-28T15:48:22Z INFO [terraformscanner] Scanning root module file_path="."2024-11-28T15:48:22Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-28T15:48:22Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:48:22Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:48:23Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-11-28T15:48:23Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-11-28T15:48:23Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-11-28T15:48:23Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-11-28T15:48:23Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-11-28T15:48:23Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-11-28T15:48:23Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:48:23Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-11-28T15:48:23Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-11-28T15:48:23Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T15:48:23Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-11-28T15:48:23Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-11-28T15:48:24Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-11-28T15:48:24Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:210-234"2024-11-28T15:48:25Z INFO Number of language-specific files num=02024-11-28T15:48:25Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:241-245
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...241 ┌ viewer_certificate {
242 │ acm_certificate_arn=aws_acm_certificate.cloudfront.arn243 │ ssl_support_method="sni-only"244 │ minimum_protocol_version="TLSv1.2_2018"245 └ }
...267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket=aws_s3_bucket.cloudfront.id133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource"aws_instance""apex_db_instance" {
7 │ ami=local.application_data.accounts[local.environment].ec2amiid8 │ associate_public_ip_address=false9 │ availability_zone="eu-west-2a"10 │ ebs_optimized=true11 │ instance_type=local.application_data.accounts[local.environment].ec2instancetype12 │ vpc_security_group_ids=[aws_security_group.database.id]
13 │ monitoring=true14 └ subnet_id=data.aws_subnet.data_subnets_a.id..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource"aws_s3_bucket""backup_lambda" {
108 │ bucket="${local.application_name}-${local.environment}-backup-lambda"109 │ tags=merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource"aws_s3_bucket""backup_lambda" {
108 │ bucket="${local.application_name}-${local.environment}-backup-lambda"109 │ tags=merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:119-123
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107resource"aws_launch_template""ec2-launch-template" {
...119 ┌ metadata_options {
120 │ http_endpoint="enabled"121 │ http_tokens="optional"122 │ http_put_response_hop_limit="2"123 └ }
...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-12-03T12:31:13Z INFO [vulndb] Need to update DB
2024-12-03T12:31:13Z INFO [vulndb] Downloading vulnerability DB...
2024-12-03T12:31:13Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T12:31:15Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T12:31:15Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T12:31:15Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T12:31:15Z INFO [misconfig] Need to update the built-in checks
2024-12-03T12:31:15Z INFO [misconfig] Downloading the built-in checks...
2024-12-03T12:31:15Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 1.052826ms, allowed: 44000/minute\n\n"
2024-12-03T12:31:15Z INFO [secret] Secret scanning is enabled
2024-12-03T12:31:15Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T12:31:15Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-12-03T12:31:16Z INFO [terraform scanner] Scanning root module file_path="."
2024-12-03T12:31:16Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-12-03T12:31:16Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T12:31:16Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T12:31:16Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-12-03T12:31:16Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-12-03T12:31:16Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-12-03T12:31:16Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-12-03T12:31:16Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-12-03T12:31:16Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-12-03T12:31:17Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T12:31:17Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T12:31:17Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-12-03T12:31:17Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T12:31:17Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-12-03T12:31:17Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T12:31:18Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:210-234"
2024-12-03T12:31:18Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-12-03T12:31:19Z INFO Number of language-specific files num=0
2024-12-03T12:31:19Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 125:125: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 179:179: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-12-03T12:31:13Z INFO [vulndb] Need to update DB
2024-12-03T12:31:13Z INFO [vulndb] Downloading vulnerability DB...2024-12-03T12:31:13Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T12:31:15Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T12:31:15Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T12:31:15Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T12:31:15Z INFO [misconfig] Need to update the built-in checks
2024-12-03T12:31:15Z INFO [misconfig] Downloading the built-in checks...2024-12-03T12:31:15Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 1.052826ms, allowed: 44000/minute\n\n"2024-12-03T12:31:15Z INFO [secret] Secret scanning is enabled
2024-12-03T12:31:15Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T12:31:15Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-12-03T12:31:16Z INFO [terraformscanner] Scanning root module file_path="."2024-12-03T12:31:16Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-12-03T12:31:16Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T12:31:16Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T12:31:16Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-12-03T12:31:16Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-12-03T12:31:16Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-12-03T12:31:16Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-12-03T12:31:16Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-12-03T12:31:16Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-12-03T12:31:17Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T12:31:17Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T12:31:17Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-12-03T12:31:17Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T12:31:17Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-12-03T12:31:17Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T12:31:18Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:210-234"2024-12-03T12:31:18Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-12-03T12:31:19Z INFO Number of language-specific files num=02024-12-03T12:31:19Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:241-245
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...241 ┌ viewer_certificate {
242 │ acm_certificate_arn=aws_acm_certificate.cloudfront.arn243 │ ssl_support_method="sni-only"244 │ minimum_protocol_version="TLSv1.2_2018"245 └ }
...267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket=aws_s3_bucket.cloudfront.id133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource"aws_instance""apex_db_instance" {
7 │ ami=local.application_data.accounts[local.environment].ec2amiid8 │ associate_public_ip_address=false9 │ availability_zone="eu-west-2a"10 │ ebs_optimized=true11 │ instance_type=local.application_data.accounts[local.environment].ec2instancetype12 │ vpc_security_group_ids=[aws_security_group.database.id]
13 │ monitoring=true14 └ subnet_id=data.aws_subnet.data_subnets_a.id..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource"aws_s3_bucket""backup_lambda" {
108 │ bucket="${local.application_name}-${local.environment}-backup-lambda"109 │ tags=merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource"aws_s3_bucket""backup_lambda" {
108 │ bucket="${local.application_name}-${local.environment}-backup-lambda"109 │ tags=merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:119-123
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107resource"aws_launch_template""ec2-launch-template" {
...119 ┌ metadata_options {
120 │ http_endpoint="enabled"121 │ http_tokens="optional"122 │ http_put_response_hop_limit="2"123 └ }
...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-12-03T14:07:13Z INFO [vulndb] Need to update DB
2024-12-03T14:07:13Z INFO [vulndb] Downloading vulnerability DB...
2024-12-03T14:07:13Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T14:07:16Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T14:07:16Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T14:07:16Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T14:07:16Z INFO [misconfig] Need to update the built-in checks
2024-12-03T14:07:16Z INFO [misconfig] Downloading the built-in checks...
2024-12-03T14:07:16Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 845.342µs, allowed: 44000/minute\n\n"
2024-12-03T14:07:16Z INFO [secret] Secret scanning is enabled
2024-12-03T14:07:16Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T14:07:16Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-12-03T14:07:17Z INFO [terraform scanner] Scanning root module file_path="."
2024-12-03T14:07:17Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-12-03T14:07:17Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T14:07:17Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T14:07:18Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-12-03T14:07:18Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-12-03T14:07:18Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-12-03T14:07:18Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-12-03T14:07:18Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-12-03T14:07:18Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-12-03T14:07:18Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T14:07:18Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T14:07:18Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-12-03T14:07:18Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T14:07:18Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-12-03T14:07:18Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T14:07:20Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-12-03T14:07:20Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:210-234"
2024-12-03T14:07:20Z INFO Number of language-specific files num=0
2024-12-03T14:07:20Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 125:125: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 179:179: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-12-03T14:07:13Z INFO [vulndb] Need to update DB
2024-12-03T14:07:13Z INFO [vulndb] Downloading vulnerability DB...2024-12-03T14:07:13Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T14:07:16Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T14:07:16Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T14:07:16Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T14:07:16Z INFO [misconfig] Need to update the built-in checks
2024-12-03T14:07:16Z INFO [misconfig] Downloading the built-in checks...2024-12-03T14:07:16Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 845.342µs, allowed: 44000/minute\n\n"2024-12-03T14:07:16Z INFO [secret] Secret scanning is enabled
2024-12-03T14:07:16Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T14:07:16Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-12-03T14:07:17Z INFO [terraformscanner] Scanning root module file_path="."2024-12-03T14:07:17Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-12-03T14:07:17Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T14:07:17Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T14:07:18Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-12-03T14:07:18Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-12-03T14:07:18Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-12-03T14:07:18Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-12-03T14:07:18Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-12-03T14:07:18Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-12-03T14:07:18Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T14:07:18Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T14:07:18Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-12-03T14:07:18Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T14:07:18Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-12-03T14:07:18Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T14:07:20Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-12-03T14:07:20Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:210-234"2024-12-03T14:07:20Z INFO Number of language-specific files num=02024-12-03T14:07:20Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:241-245
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...241 ┌ viewer_certificate {
242 │ acm_certificate_arn=aws_acm_certificate.cloudfront.arn243 │ ssl_support_method="sni-only"244 │ minimum_protocol_version="TLSv1.2_2018"245 └ }
...267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket=aws_s3_bucket.cloudfront.id133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource"aws_instance""apex_db_instance" {
7 │ ami=local.application_data.accounts[local.environment].ec2amiid8 │ associate_public_ip_address=false9 │ availability_zone="eu-west-2a"10 │ ebs_optimized=true11 │ instance_type=local.application_data.accounts[local.environment].ec2instancetype12 │ vpc_security_group_ids=[aws_security_group.database.id]
13 │ monitoring=true14 └ subnet_id=data.aws_subnet.data_subnets_a.id..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource"aws_s3_bucket""backup_lambda" {
108 │ bucket="${local.application_name}-${local.environment}-backup-lambda"109 │ tags=merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource"aws_s3_bucket""backup_lambda" {
108 │ bucket="${local.application_name}-${local.environment}-backup-lambda"109 │ tags=merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:119-123
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107resource"aws_launch_template""ec2-launch-template" {
...119 ┌ metadata_options {
120 │ http_endpoint="enabled"121 │ http_tokens="optional"122 │ http_put_response_hop_limit="2"123 └ }
...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource"aws_s3_bucket""laa-lambda-backup" {
2 │ bucket=var.bucket_name3 │ tags=var.tags4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-12-03T14:16:26Z INFO [vulndb] Need to update DB
2024-12-03T14:16:26Z INFO [vulndb] Downloading vulnerability DB...
2024-12-03T14:16:26Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T14:16:28Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T14:16:28Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T14:16:28Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T14:16:28Z INFO [misconfig] Need to update the built-in checks
2024-12-03T14:16:28Z INFO [misconfig] Downloading the built-in checks...
160.80 KiB / 160.80 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-12-03T14:16:29Z INFO [secret] Secret scanning is enabled
2024-12-03T14:16:29Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T14:16:29Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-12-03T14:16:31Z INFO [terraform scanner] Scanning root module file_path="."
2024-12-03T14:16:31Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T14:16:31Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T14:16:31Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-12-03T14:16:31Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T14:16:31Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-12-03T14:16:31Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T14:16:33Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:214"
2024-12-03T14:16:33Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-12-03T14:16:33Z INFO Number of language-specific files num=0
2024-12-03T14:16:33Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource "aws_cloudfront_distribution" "external" {
...
244 [ minimum_protocol_version = "TLSv1.2_2018"
...
267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template" "ec2-launch-template" {
...
121 [ http_tokens = "optional"
...
164 }
────────────────────────────────────────
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 42:42: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 125:125: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 179:179: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-12-03T14:16:26Z INFO [vulndb] Need to update DB
2024-12-03T14:16:26Z INFO [vulndb] Downloading vulnerability DB...2024-12-03T14:16:26Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T14:16:28Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T14:16:28Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T14:16:28Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T14:16:28Z INFO [misconfig] Need to update the built-in checks
2024-12-03T14:16:28Z INFO [misconfig] Downloading the built-in checks...160.80 KiB /160.80 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-12-03T14:16:29Z INFO [secret] Secret scanning is enabled
2024-12-03T14:16:29Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T14:16:29Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-12-03T14:16:31Z INFO [terraformscanner] Scanning root module file_path="."2024-12-03T14:16:31Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T14:16:31Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T14:16:31Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-12-03T14:16:31Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T14:16:31Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-12-03T14:16:31Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T14:16:33Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:214"2024-12-03T14:16:33Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-12-03T14:16:33Z INFO Number of language-specific files num=02024-12-03T14:16:33Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...244 [ minimum_protocol_version = "TLSv1.2_2018"...267 }
────────────────────────────────────────
AVD-AWS-0132 (HIGH):Bucketdoesnotencryptdatawithacustomermanagedkey.
════════════════════════════════════════
EncryptionusingAWSkeysprovidesprotectionforyourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.Seehttps://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm ="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-40
────────────────────────────────────────
6 ┌ resource "aws_instance""apex_db_instance" {
7 │ ami = local.application_data.accounts[local.environment].ec2amiid
8 │ associate_public_ip_address =false9 │ availability_zone ="eu-west-2a"10 │ ebs_optimized =true11 │ instance_type = local.application_data.accounts[local.environment].ec2instancetype
12 │ vpc_security_group_ids = [aws_security_group.database.id]
13 │ monitoring =true14 └ subnet_id = data.aws_subnet.data_subnets_a.id
..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource "aws_s3_bucket""backup_lambda" {
108 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"109 │ tags =merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource "aws_s3_bucket""backup_lambda" {
108 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"109 │ tags =merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template""ec2-launch-template" {
...121 [ http_tokens ="optional"...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-12-03T16:02:50Z INFO [vulndb] Need to update DB
2024-12-03T16:02:50Z INFO [vulndb] Downloading vulnerability DB...
2024-12-03T16:02:50Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T16:02:52Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T16:02:52Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T16:02:52Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T16:02:52Z INFO [misconfig] Need to update the built-in checks
2024-12-03T16:02:52Z INFO [misconfig] Downloading the built-in checks...
160.80 KiB / 160.80 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-12-03T16:02:53Z INFO [secret] Secret scanning is enabled
2024-12-03T16:02:53Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T16:02:53Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-12-03T16:02:55Z INFO [terraform scanner] Scanning root module file_path="."
2024-12-03T16:02:55Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-12-03T16:02:55Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T16:02:55Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T16:02:55Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-12-03T16:02:55Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-12-03T16:02:55Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-12-03T16:02:55Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-12-03T16:02:55Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-12-03T16:02:55Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-12-03T16:02:56Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T16:02:56Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T16:02:56Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-12-03T16:02:56Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T16:02:56Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-12-03T16:02:56Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T16:02:58Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-12-03T16:02:58Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:214"
2024-12-03T16:02:58Z INFO Number of language-specific files num=0
2024-12-03T16:02:58Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource "aws_cloudfront_distribution" "external" {
...
244 [ minimum_protocol_version = "TLSv1.2_2018"
...
267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template" "ec2-launch-template" {
...
121 [ http_tokens = "optional"
...
164 }
────────────────────────────────────────
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 45:45: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 125:125: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 179:179: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-12-03T16:02:50Z INFO [vulndb] Need to update DB
2024-12-03T16:02:50Z INFO [vulndb] Downloading vulnerability DB...2024-12-03T16:02:50Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T16:02:52Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T16:02:52Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T16:02:52Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T16:02:52Z INFO [misconfig] Need to update the built-in checks
2024-12-03T16:02:52Z INFO [misconfig] Downloading the built-in checks...160.80 KiB /160.80 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-12-03T16:02:53Z INFO [secret] Secret scanning is enabled
2024-12-03T16:02:53Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T16:02:53Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-12-03T16:02:55Z INFO [terraformscanner] Scanning root module file_path="."2024-12-03T16:02:55Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-12-03T16:02:55Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T16:02:55Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T16:02:55Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-12-03T16:02:55Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-12-03T16:02:55Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-12-03T16:02:55Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-12-03T16:02:55Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-12-03T16:02:55Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-12-03T16:02:56Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T16:02:56Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T16:02:56Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-12-03T16:02:56Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T16:02:56Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-12-03T16:02:56Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T16:02:58Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-12-03T16:02:58Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:214"2024-12-03T16:02:58Z INFO Number of language-specific files num=02024-12-03T16:02:58Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...244 [ minimum_protocol_version = "TLSv1.2_2018"...267 }
────────────────────────────────────────
AVD-AWS-0132 (HIGH):Bucketdoesnotencryptdatawithacustomermanagedkey.
════════════════════════════════════════
EncryptionusingAWSkeysprovidesprotectionforyourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.Seehttps://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm ="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-43
────────────────────────────────────────
6 ┌ resource "aws_instance""apex_db_instance" {
7 │ ami = local.application_data.accounts[local.environment].ec2amiid
8 │ associate_public_ip_address =false9 │ availability_zone ="eu-west-2a"10 │ ebs_optimized =true11 │ instance_type = local.application_data.accounts[local.environment].ec2instancetype
12 │ vpc_security_group_ids = [aws_security_group.database.id]
13 │ monitoring =true14 └ subnet_id = data.aws_subnet.data_subnets_a.id
..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource "aws_s3_bucket""backup_lambda" {
108 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"109 │ tags =merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource "aws_s3_bucket""backup_lambda" {
108 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"109 │ tags =merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template""ec2-launch-template" {
...121 [ http_tokens ="optional"...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-12-03T16:07:48Z INFO [vulndb] Need to update DB
2024-12-03T16:07:48Z INFO [vulndb] Downloading vulnerability DB...
2024-12-03T16:07:48Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T16:07:50Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-03T16:07:50Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T16:07:50Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T16:07:50Z INFO [misconfig] Need to update the built-in checks
2024-12-03T16:07:50Z INFO [misconfig] Downloading the built-in checks...
160.80 KiB / 160.80 KiB [---------------------------------------------------------] 100.00% ? p/s 0s2024-12-03T16:07:51Z INFO [secret] Secret scanning is enabled
2024-12-03T16:07:51Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T16:07:51Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-12-03T16:07:52Z INFO [terraform scanner] Scanning root module file_path="."
2024-12-03T16:07:52Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-12-03T16:07:52Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T16:07:52Z ERROR [terraform evaluator] Failed to expand dynamic block. block="aws_waf_ipset.wafmanualallowset" err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T16:07:52Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_network_services" value="cty.NilVal"
2024-12-03T16:07:52Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_core_vpc" value="cty.NilVal"
2024-12-03T16:07:52Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.aws_route53_record.external_lb_validation_self" value="cty.NilVal"
2024-12-03T16:07:52Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_network_services" value="cty.NilVal"
2024-12-03T16:07:52Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.core_vpc" value="cty.NilVal"
2024-12-03T16:07:52Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.alb.data.aws_route53_zone.self" value="cty.NilVal"
2024-12-03T16:07:53Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T16:07:53Z ERROR [terraform evaluator] Failed to expand dynamic block. block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group" err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"
2024-12-03T16:07:53Z INFO [terraform scanner] Scanning root module file_path="modules/lambdapolicy"
2024-12-03T16:07:53Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T16:07:53Z INFO [terraform scanner] Scanning root module file_path="modules/s3"
2024-12-03T16:07:53Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="tags"
2024-12-03T16:07:55Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="modules/alb/main.tf:214"
2024-12-03T16:07:55Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"
2024-12-03T16:07:55Z INFO Number of language-specific files num=0
2024-12-03T16:07:55Z INFO Detected config files num=12
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting minimum_protocol_version = "TLSv1.2_2021" is only possible when cloudfront_default_certificate is false (eg. you are not using the cloudfront.net domain name).
If cloudfront_default_certificate is true then the Cloudfront API will only allow setting minimum_protocol_version = "TLSv1", and setting it to any other value will result in a perpetual diff in your terraform plan's.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource "aws_cloudfront_distribution" "external" {
...
244 [ minimum_protocol_version = "TLSv1.2_2018"
...
267 }
────────────────────────────────────────
AVD-AWS-0132 (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
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm = "AES256"
136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required
139 └ lifecycle {
...
────────────────────────────────────────
AVD-AWS-0028 (HIGH): Instance 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.
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template" "ec2-launch-template" {
...
121 [ http_tokens = "optional"
...
164 }
────────────────────────────────────────
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
AVD-AWS-0132 (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.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 45:45: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 125:125: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 179:179: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-12-03T16:07:48Z INFO [vulndb] Need to update DB
2024-12-03T16:07:48Z INFO [vulndb] Downloading vulnerability DB...2024-12-03T16:07:48Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T16:07:50Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-03T16:07:50Z INFO [vuln] Vulnerability scanning is enabled
2024-12-03T16:07:50Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-03T16:07:50Z INFO [misconfig] Need to update the built-in checks
2024-12-03T16:07:50Z INFO [misconfig] Downloading the built-in checks...160.80 KiB /160.80 KiB [---------------------------------------------------------] 100.00%? p/s 0s2024-12-03T16:07:51Z INFO [secret] Secret scanning is enabled
2024-12-03T16:07:51Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-03T16:07:51Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection2024-12-03T16:07:52Z INFO [terraformscanner] Scanning root module file_path="."2024-12-03T16:07:52Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-12-03T16:07:52Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T16:07:52Z ERROR [terraformevaluator] Failed to expand dynamic block.block="aws_waf_ipset.wafmanualallowset"err="1 error occurred:\n\t* invalid for-each in aws_waf_ipset.wafmanualallowset.dynamic.ip_set_descriptors block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T16:07:52Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_network_services"value="cty.NilVal"2024-12-03T16:07:52Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_core_vpc"value="cty.NilVal"2024-12-03T16:07:52Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.aws_route53_record.external_lb_validation_self"value="cty.NilVal"2024-12-03T16:07:52Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_network_services"value="cty.NilVal"2024-12-03T16:07:52Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.core_vpc"value="cty.NilVal"2024-12-03T16:07:52Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.alb.data.aws_route53_zone.self"value="cty.NilVal"2024-12-03T16:07:53Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T16:07:53Z ERROR [terraformevaluator] Failed to expand dynamic block.block="module.apex-ecs.aws_autoscaling_group.cluster-scaling-group"err="1 error occurred:\n\t* invalid for-each in aws_autoscaling_group.cluster-scaling-group.dynamic.tag block: cannot use a cty.NilVal value in for_each. An iterable collection is required\n\n"2024-12-03T16:07:53Z INFO [terraformscanner] Scanning root module file_path="modules/lambdapolicy"2024-12-03T16:07:53Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T16:07:53Z INFO [terraformscanner] Scanning root module file_path="modules/s3"2024-12-03T16:07:53Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="tags"2024-12-03T16:07:55Z INFO [terraformexecutor] Ignore finding rule="aws-elb-alb-not-public"range="modules/alb/main.tf:214"2024-12-03T16:07:55Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.1.0/main.tf:171-179"2024-12-03T16:07:55Z INFO Number of language-specific files num=02024-12-03T16:07:55Z INFO Detected config files num=12
cloudfront.tf (terraform)
=========================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0013 (HIGH): Distribution allows unencrypted communications.
════════════════════════════════════════
You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.
Note: that setting *minimum_protocol_version="TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name).
If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version="TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s.
The only option when using the cloudfront.net domain name is to ignore this rule.
See https://avd.aquasec.com/misconfig/avd-aws-0013
────────────────────────────────────────
cloudfront.tf:244
via cloudfront.tf:241-245 (viewer_certificate)
via cloudfront.tf:177-267 (aws_cloudfront_distribution.external)
────────────────────────────────────────
177 resource"aws_cloudfront_distribution""external" {
...244 [ minimum_protocol_version = "TLSv1.2_2018"...267 }
────────────────────────────────────────
AVD-AWS-0132 (HIGH):Bucketdoesnotencryptdatawithacustomermanagedkey.
════════════════════════════════════════
EncryptionusingAWSkeysprovidesprotectionforyourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.Seehttps://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
cloudfront.tf:131-142
────────────────────────────────────────
131 ┌ resource"aws_s3_bucket_server_side_encryption_configuration""cloudfront" {
132 │ bucket = aws_s3_bucket.cloudfront.id
133 │ rule {
134 │ apply_server_side_encryption_by_default {
135 │ sse_algorithm ="AES256"136 │ }
137 │ }
138 │ # TODO Set prevent_destroy to true to stop Terraform destroying this resource in the future if required139 └ lifecycle {
...
────────────────────────────────────────
ec2.tf (terraform)
==================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0028 (HIGH): Instance 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-0028
────────────────────────────────────────
ec2.tf:6-43
────────────────────────────────────────
6 ┌ resource "aws_instance""apex_db_instance" {
7 │ ami = local.application_data.accounts[local.environment].ec2amiid
8 │ associate_public_ip_address =false9 │ availability_zone ="eu-west-2a"10 │ ebs_optimized =true11 │ instance_type = local.application_data.accounts[local.environment].ec2instancetype
12 │ vpc_security_group_ids = [aws_security_group.database.id]
13 │ monitoring =true14 └ subnet_id = data.aws_subnet.data_subnets_a.id
..
────────────────────────────────────────
lambda.tf (terraform)
=====================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource "aws_s3_bucket""backup_lambda" {
108 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"109 │ tags =merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
lambda.tf:107-113
────────────────────────────────────────
107 ┌ resource "aws_s3_bucket""backup_lambda" {
108 │ bucket ="${local.application_name}-${local.environment}-backup-lambda"109 │ tags =merge(
110 │ local.tags,
111 │ { Name ="${local.application_name}-${local.environment}-backup-lambda" }
112 │ )
113 └ }
────────────────────────────────────────
modules/ecs/main.tf (terraform)
===============================
Tests:1 (SUCCESSES:0, FAILURES:1)
Failures:1 (HIGH:1, CRITICAL:0)
AVD-AWS-0130 (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/aws-autoscaling-enforce-http-token-imds
────────────────────────────────────────
modules/ecs/main.tf:121
via modules/ecs/main.tf:119-123 (metadata_options)
via modules/ecs/main.tf:107-164 (aws_launch_template.ec2-launch-template)
via ecs.tf:5-38 (module.apex-ecs)
────────────────────────────────────────
107 resource "aws_launch_template""ec2-launch-template" {
...121 [ http_tokens ="optional"...164 }
────────────────────────────────────────
modules/s3/main.tf (terraform)
==============================
Tests:2 (SUCCESSES:0, FAILURES:2)
Failures:2 (HIGH:2, CRITICAL:0)
AVD-AWS-0088 (HIGH): Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
AVD-AWS-0132 (HIGH): Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
modules/s3/main.tf:1-4
────────────────────────────────────────
1 ┌ resource "aws_s3_bucket""laa-lambda-backup" {
2 │ bucket = var.bucket_name
3 │ tags = var.tags
4 └ }
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/apex
Running Trivy in terraform/environments/apex
2024-12-04T11:48:49Z INFO [vulndb] Need to update DB
2024-12-04T11:48:49Z INFO [vulndb] Downloading vulnerability DB...
2024-12-04T11:48:49Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-04T11:48:51Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-04T11:48:51Z INFO [vuln] Vulnerability scanning is enabled
2024-12-04T11:48:51Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-04T11:48:51Z INFO [misconfig] Need to update the built-in checks
2024-12-04T11:48:51Z INFO [misconfig] Downloading the built-in checks...
160.80 KiB / 160.80 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-12-04T11:48:53Z INFO [secret] Secret scanning is enabled
2024-12-04T11:48:53Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-04T11:48:53Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.58/docs/scanner/secret#recommendation for faster secret detection
2024-12-04T11:48:54Z INFO [terraform scanner] Scanning root module file_path="."
2024-12-04T11:48:54Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
panic: value is null
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/apex
*****************************
Running tflint in terraform/environments/apex
Excluding the following checks: terraform_unused_declarations
7issue(s) found:
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 17:17:"${local.application_data.accounts[local.environment].acm_cert_domain_name}" = {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/alb.tf line 19:19: zone_name ="${local.application_data.accounts[local.environment].acm_cert_domain_name}"
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"template"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/cloudwatch.tf line 401:401: data "template_file""dashboard" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"local"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/ec2.tf line 45:45: data "local_file""cloudwatch_agent" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: [Fixable] Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)
on terraform/environments/apex/event_triggers.tf line 22:22: input =jsonencode({ "appname":"${local.database_ec2_name}" })
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_deprecated_interpolation.md
Warning: Missing version constraint forprovider"time"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 125:125: resource "time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint forprovider"archive"in `required_providers` (terraform_required_providers)
on terraform/environments/apex/lambda.tf line 179:179: data "archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
tflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/apex
*****************************
Running Trivy in terraform/environments/apex
2024-12-04T11:48:49Z INFO [vulndb] Need to update DB
2024-12-04T11:48:49Z INFO [vulndb] Downloading vulnerability DB...2024-12-04T11:48:49Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-04T11:48:51Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-12-04T11:48:51Z INFO [vuln] Vulnerability scanning is enabled
2024-12-04T11:48:51Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-04T11:48:51Z INFO [misconfig] Need to update the built-in checks
2024-12-04T11:48:51Z INFO [misconfig] Downloading the built-in checks...160.80 KiB /160.80 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-12-04T11:48:53Z INFO [secret] Secret scanning is enabled
2024-12-04T11:48:53Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-04T11:48:53Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.58/docs/scanner/secret#recommendation for faster secret detection2024-12-04T11:48:54Z INFO [terraformscanner] Scanning root module file_path="."2024-12-04T11:48:54Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"
panic: value is null
goroutine 1 [running]:
github.com/zclconf/go-cty/cty.Value.AsString({{{0x58f5110?, 0xc00028d2b1?}}, {0x0?, 0x0?}})
/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.15.0/cty/value_ops.go:1390+0x10b
github.com/aquasecurity/trivy/pkg/iac/terraform.postProcessValues(0xc00d6b4700, 0xc00968ce10)
/home/runner/work/trivy/trivy/pkg/iac/terraform/presets.go:52+0x393
github.com/aquasecurity/trivy/pkg/iac/terraform.(*Block).Values(0xc00d6b4700)
/home/runner/work/trivy/trivy/pkg/iac/terraform/block.go:580+0x185
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).getResources(0xc0027a6dc0)
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:581+0x18e
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).evaluateStep(0xc0027a6dc0)
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:99+0x195
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).evaluateSteps(0xc0027a6dc0)
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:246+0x152
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).EvaluateAll(0xc0027a6dc0, {0x58f3078, 0xc002a9c210})
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:135+0x1eb
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).evaluateSubmodule(0xc003111860, {0x58f3078, 0xc002a9c210}, 0xc00c871cc0)
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:228+0x1bc
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).evaluateSubmodules(0xc003111860, {0x58f3078, 0xc002a9c210}, 0xc009572e10)
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:164+0x43f
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).EvaluateAll(0xc003111860, {0x58f3078, 0xc002a9c210})
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:142+0x294
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).evaluateSubmodule(0xc0039240a0, {0x58f3078, 0xc002a9c210}, 0xc00babadc0)
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:228+0x1bc
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).evaluateSubmodules(0xc0039240a0, {0x58f3078, 0xc002a9c210}, 0xc009266cf0)
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:164+0x43f
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*evaluator).EvaluateAll(0xc0039240a0, {0x58f3078, 0xc002a9c210})
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/evaluator.go:142+0x294
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser.(*Parser).EvaluateAll(0xc009ca47e0, {0x58f3078, 0xc002a9c210})
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/parser/parser.go:342+0x90
github.com/aquasecurity/trivy/pkg/iac/scanners/terraform.(*Scanner).ScanFS(0xc000ee7560, {0x58f3078, 0xc002a9c210}, {0x58b12c0, 0xc00354a0f0}, {0x58959e8, 0x1})
/home/runner/work/trivy/trivy/pkg/iac/scanners/terraform/scanner.go:132+0x726
github.com/aquasecurity/trivy/pkg/misconf.(*Scanner).Scan(0xc000c79e00, {0x58f3120, 0xc0005f6ee0}, {0x58b12c0, 0xc001513830})
/home/runner/work/trivy/trivy/pkg/misconf/scanner.go:151+0x297
github.com/aquasecurity/trivy/pkg/fanal/analyzer/config.(*Analyzer).PostAnalyze(0xc0010a8fa0, {0x58f3120?, 0xc0005f6ee0?}, {{0x58b12c0?, 0xc001513830?}, {0x9?, 0x0?}})
/home/runner/work/trivy/trivy/pkg/fanal/analyzer/config/config.go:44+0x46
github.com/aquasecurity/trivy/pkg/fanal/analyzer.AnalyzerGroup.PostAnalyze({0xc001500640, {0xc000bb7400, 0x1f, 0x20}, {0xc0012d0600, 0x16, 0x20}, 0xc0015acd50, {0x47ad91d, 0x7}}, ...)
/home/runner/work/trivy/trivy/pkg/fanal/analyzer/analyzer.go:505+0x2e2
github.com/aquasecurity/trivy/pkg/fanal/artifact/local.Artifact.Inspect({{0x7fff1a15bb5e, 0x2d}, {0x7fe860d59cf8, 0xc0010ae180}, {0x58b11e0, 0x827fc80}, {0xc001500640, {0xc000bb7400, 0x1f, 0x20}, ...}, ...}, ...)
/home/runner/work/trivy/trivy/pkg/fanal/artifact/local/fs.go:121+0x4c9
github.com/aquasecurity/trivy/pkg/scanner.Scanner.ScanArtifact({{_, _}, {_, _}}, {_, _}, {{0xc0010a9c40, 0x2, 0x2}, {0xc000df5680, ...}, ...})
/home/runner/work/trivy/trivy/pkg/scanner/scan.go:156+0x103
github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).scan(_, {_, _}, {{{0x47c4a2d, 0xa}, 0x0, 0x0, 0x0, 0x0, 0x45d964b800, ...}, ...}, ...)
/home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:620+0x32b
github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).scanArtifact(_, {_, _}, {{{0x47c4a2d, 0xa}, 0x0, 0x0, 0x0, 0x0, 0x45d964b800, ...}, ...}, ...)
/home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:259+0xb1
github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).scanFS(_, {_, _}, {{{0x47c4a2d, 0xa}, 0x0, 0x0, 0x0, 0x0, 0x45d964b800, ...}, ...})
/home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:204+0xc5
github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).ScanFilesystem(_, {_, _}, {{{0x47c4a2d, 0xa}, 0x0, 0x0, 0x0, 0x0, 0x45d964b800, ...}, ...})
/home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:184+0x211
github.com/aquasecurity/trivy/pkg/commands/artifact.Run({_, _}, {{{0x47c4a2d, 0xa}, 0x0, 0x0, 0x0, 0x0, 0x45d964b800, {0xc00007d660, ...}, ...}, ...}, ...)
/home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:385+0x8cb
github.com/aquasecurity/trivy/pkg/commands.NewFilesystemCommand.func2(0xc0002e9b08, {0xc00078e460, 0x1, 0xa})
/home/runner/work/trivy/trivy/pkg/commands/app.go:383+0x19c
github.com/spf13/cobra.(*Command).execute(0xc0002e9b08, {0xc00078e0a0, 0xa, 0xa})
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985+0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc00083bb08)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117+0x3ff
github.com/spf13/cobra.(*Command).Execute(0x48176bb?)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041+0x13
main.run()
/home/runner/work/trivy/trivy/cmd/trivy/main.go:39+0x113
main.main()
/home/runner/work/trivy/trivy/cmd/trivy/main.go:19+0x1f
trivy_exitcode=2
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… instead of zipfiles directory