Ignore unmanaged resources
The .snyk
policy file can be used to exclude unmanaged resources from being detected by snyk iac describe
. See the .snyk
policy file doc for general information.
If you need to exclude only a set of resources, use .snyk
. If you have more complex requirements, consider using filter rules. For more information see Filter rules.
Create the .snyk
file in the directory where you launch the snyk iac describe
command, typically the root of your IaC repo.
Each line must be structured as follows:
resource_type.resource_id
, whereresource_id
is a wildcard to exclude all resources of a given typeresource_type.resource_id.path.to.field_name
, whereresource_id
is a wildcard to ignore a drift on a given field for a given type andpath,
can also contain wildcards.
Examples of IaC ignores
Ignore a single IAM user (aws_iam_user) named "tfc-demo".
Ignore all unmanaged resource in S3 buckets.
The .snyk
policy file also supports the negation of rules. This allows you to ignore everything except certain types. In this example, only S3 buckets will not be ignored:
Ignore a specific IAM Policy Attachment (AWSServiceRoleForRDS) using its ARN (arn:aws:iam::aws:policy/aws-service-role/AmazonRDSServiceRolePolicy
).
Ignore the S3 bucket called my-bucket
and so on, as shown.
Precedence over filter rules
You can use the means to ignore resources explained on this page in combination with filter rules.
Note: If the same resource is included by a filter rule and excluded inside the .snyk
file, snyk iac describe
ignores this resource.
Automatically generate unmanaged resource exclusion rules
For details, run snyk iac update-exclude-policy --help
.
This command helps to generate a .snyk
policy file, adding all the detected drifts to it in order to ignore them all.
For example, to ignore all the unmanaged resources at once, run the following command:
Last updated
Was this helpful?