Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(misconf): add info about limitations for terraform plan json #7143

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion docs/docs/coverage/iac/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,33 @@ trivy conf --tf-exclude-downloaded-modules ./configs
```

## Secret
The secret scan is performed on plain text files, with no special treatment for Terraform.
The secret scan is performed on plain text files, with no special treatment for Terraform.

## Limitations

### Terraform Plan JSON

#### For each and count objects in expression

The plan created by Terraform does not provide complete information about references in expressions that use `each` or `count` objects. For this reason, in some situations it is not possible to establish references between resources that are needed for checks when detecting misconfigurations. An example of such a configuration is:

```hcl
locals {
buckets = toset(["test"])
}

resource "aws_s3_bucket" "this" {
for_each = local.buckets
bucket = each.key
}

resource "aws_s3_bucket_acl" "this" {
for_each = local.buckets
bucket = aws_s3_bucket.this[each.key].id
acl = "private"
}
```

With this configuration, the plan will not contain information about which attribute of the `aws_s3_bucket` resource is referenced by the `aws_s3_bucket_acl` resource.

See more [here](https://github.com/hashicorp/terraform/issues/30826).