Repository navigation
fix(aws-cloudwatchlogs): data protection and account policies - #1700
Merged
Merged
Conversation
This was referenced Oct 23, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds CloudWatch Logs data protection policies and account policies. Until now these six operations returned UnknownOperationException, so
aws_cloudwatch_log_data_protection_policy,aws_cloudwatch_log_account_policyand any CLI or SDK code that masks sensitive log data failed against cloudemu.Data protection (
PutDataProtectionPolicy,GetDataProtectionPolicy,DeleteDataProtectionPolicy, on the optionaldriver.AWSLogginginterface; the wire handler only translates)logGroupIdentifiertakes a log group name or ARN, with the API's length and pattern rules.Versionmust be2021-06-01when present;Auditstatement with aFindingsDestinationand oneDeidentifystatement with an emptyMaskConfig;DataIdentifierarray;arn:aws:dataprotection::aws:data-identifier/<Name>) or custom identifiers fromConfiguration.CustomDataIdentifier;*, and every egress sees the masked text:GetLogEvents,FilterLogEvents, Logs Insights, metric filters, subscription filters and export tasks.unmask: trueonGetLogEvents,FilterLogEventsandGetLogRecordreturns the original text, which the provider keeps alongside the masked event.EmailAddress,IpAddress(IPv4 and IPv6),AwsSecretKey(keyword plus a 40-character key) andCreditCardNumber(Luhn-checked), plus any custom regex. Every regex runs on Go's RE2 engine, which is linear-time, so a hostile custom pattern cannot backtrack.GetDataProtectionPolicyon a group without a policy returns nopolicyDocument, which Terraform reads as gone.DescribeLogGroupsreportsdataProtectionStatus: ACTIVATEDwhile a policy is set.Account policies (
PutAccountPolicy,DescribeAccountPolicies,DeleteAccountPolicy)DATA_PROTECTION_POLICY,SUBSCRIPTION_FILTER_POLICY,FIELD_INDEX_POLICY,TRANSFORMER_POLICYandMETRIC_EXTRACTION_POLICY.scopeisALL(the default), and policies are keyed by type and name.selectionCriteriais parsed and checked per type:LogGroupName NOT IN [...]for subscription filters;LogGroupNamePrefixfor transformers;LogGroupNamePrefix, orDataSourceName AND DataSourceType, for field indexes;IN/NOT INon names or prefixes for metric extraction;NOT INpolicy;NOT IN.policyNamecan't start withaws/.DescribeAccountPoliciesrequirespolicyTypeand acceptspolicyNameandaccountIdentifiers(another account returns an empty list). Deleting an unknown policy returns ResourceNotFoundException.Persistence: snapshots keep group policies, account policies and the original text of masked events, and restored policies keep masking.
Not modelled (written to
docs/coverage/nongoals/logging.md):LogEventsWithFindingsmetric;logs:Unmaskenforcement;unmaskcommand;Tests
dataprotectionpackage: every validation rule, each detector (including non-matches such as clock times and Luhn failures), cumulative masking, and a linear-time check on a(a+)+bcustom regex.NOT INexclusion on account subscription delivery;data_protection_sdk_test.goandaccount_policy_sdk_test.go.E2E against
cloudemu serve, all checks passedaws_secret_access_key;--unmaskshowed the originals; an event from before the policy stayed unmasked;NOT IN, FIELD_INDEX and TRANSFORMER;aws_cloudwatch_log_data_protection_policyand twoaws_cloudwatch_log_account_policyresources (DATA_PROTECTION_POLICY and SUBSCRIPTION_FILTER_POLICY):Part of #1476