Solution |
One reason is that the datasource could not be assessed because the data are missing. This may be for the following reasons:
- The rate-limit was reached during the data query. Lacework ingestion data has a retry mechanism, but the rate-limit can be hit.
- Security groups configured on AWS may prevent Lacework to access some data.
Another possible reason is that the policy may not be able to assess the compliance policy. For example, if Lacework hit a problem listing all S3 buckets, Lacework will be able to assess a policy only for the S3 buckets that were collected, but not for the others. Consequently, therefore Lacework will be unable to globally assess the policy.
These 'primary' data sources (s3 buckets, for instance) represent the top-level list of 'all the resources'. But when a policy's query does not use the primary data source, Lacework cannot apply that logic that determines whether or not the policy itself is assess-able across all the resources. This is why Lacework validates that the policy does use a primary source. If the administrator is not using a primary source in the query, the administrator will encounter the 'Datasource cannot be used by compliance policy' error.
To fix this error, the administrator will need to link the non-primary source with a primary source.
Example when not using a primary source, which will lead to the 'Datasource cannot be used by compliance policy' error:
{
source {
LW_CFG_AWS_EC2_IMAGES image,
array_to_rows(image.RESOURCE_CONFIG:BlockDeviceMappings) as (volume)
}
filter {
volume:Ebs.Encrypted = "false"
and image.RESOURCE_CONFIG:OwnerId = image.ACCOUNT_ID
}
return distinct {
image.ACCOUNT_ALIAS,
image.ACCOUNT_ID,
image.RESOURCE_CONFIG:ImageId as RESOURCE_KEY,
image.RESOURCE_REGION,
image.RESOURCE_TYPE,
image.SERVICE,
'AMIUnencrypted' as COMPLIANCE_FAILURE_REASON
}
}
As LW_CFG_AWS_EC2_IMAGES is not a primary source, the Lacework administrator will have to include the primary source LW_CFG_AWS_EC2_INSTANCES:
{
source {
LW_CFG_AWS_EC2_INSTANCES instance
with LW_CFG_AWS_EC2_IMAGES image,
array_to_rows(image.RESOURCE_CONFIG:BlockDeviceMappings) as (volume)
}
filter {
volume:Ebs.Encrypted = "false"
and image.RESOURCE_CONFIG:OwnerId = image.ACCOUNT_ID
}
return distinct {
instance.ACCOUNT_ALIAS,
instance.ACCOUNT_ID,
instance.RESOURCE_CONFIG:ImageId as RESOURCE_KEY,
instance.RESOURCE_REGION,
"ec2:image" as RESOURCE_TYPE,
instance.SERVICE,
'AMIUnencrypted' as COMPLIANCE_FAILURE_REASON
}
}
|