CfnAccountPolicyPropsMixin
- class aws_cdk.mixins_preview.aws_logs.mixins.CfnAccountPolicyPropsMixin(props, *, strategy=None)
Bases:
MixinCreates or updates an account-level data protection policy or subscription filter policy that applies to all log groups or a subset of log groups in the account.
Data protection policy
A data protection policy can help safeguard sensitive data that’s ingested by your log groups by auditing and masking the sensitive log data. Each account can have only one account-level data protection policy. .. epigraph:
Sensitive data is detected and masked when it is ingested into a log group. When you set a data protection policy, log events ingested into the log groups before that time are not masked.
If you create a data protection policy for your whole account, it applies to both existing log groups and all log groups that are created later in this account. The account policy is applied to existing log groups with eventual consistency. It might take up to 5 minutes before sensitive data in existing log groups begins to be masked.
By default, when a user views a log event that includes masked data, the sensitive data is replaced by asterisks. A user who has the
logs:Unmaskpermission can use a GetLogEvents or FilterLogEvents operation with theunmaskparameter set totrueto view the unmasked log events. Users with thelogs:Unmaskcan also view unmasked data in the CloudWatch Logs console by running a CloudWatch Logs Insights query with theunmaskquery command.For more information, including a list of types of data that can be audited and masked, see Protect sensitive log data with masking .
To create an account-level policy, you must be signed on with the
logs:PutDataProtectionPolicyandlogs:PutAccountPolicypermissions.An account-level policy applies to all log groups in the account. You can also create a data protection policy that applies to just one log group. If a log group has its own data protection policy and the account also has an account-level data protection policy, then the two policies are cumulative. Any sensitive term specified in either policy is masked.
Subscription filter policy
A subscription filter policy sets up a real-time feed of log events from CloudWatch Logs to other AWS services. Account-level subscription filter policies apply to both existing log groups and log groups that are created later in this account. Supported destinations are Kinesis Data Streams , Firehose , and Lambda . When log events are sent to the receiving service, they are Base64 encoded and compressed with the GZIP format.
The following destinations are supported for subscription filters:
An Kinesis Data Streams data stream in the same account as the subscription policy, for same-account delivery.
An Firehose data stream in the same account as the subscription policy, for same-account delivery.
A Lambda function in the same account as the subscription policy, for same-account delivery.
A logical destination in a different account created with PutDestination , for cross-account delivery. Kinesis Data Streams and Firehose are supported as logical destinations.
Each account can have one account-level subscription filter policy. If you are updating an existing filter, you must specify the correct name in
PolicyName. To perform aPutAccountPolicysubscription filter operation for any destination except a Lambda function, you must also have theiam:PassRolepermission.Field index policy
You can use field index policies to create indexes on fields found in log events in the log group. Creating field indexes lowers the scan volume for CloudWatch Logs Insights queries that reference those fields, because these queries attempt to skip the processing of log events that are known to not match the indexed field. Good fields to index are fields that you often need to query for. Common examples of indexes include request ID, session ID, user IDs, or instance IDs. For more information, see Create field indexes to improve query performance and reduce costs
For example, suppose you have created a field index for
requestId. Then, any CloudWatch Logs Insights query on that log group that includesrequestId = *value*orrequestId IN [ *value* , *value* , ...]will attempt to process only the log events where the indexed field matches the specified value.Matches of log events to the names of indexed fields are case-sensitive. For example, an indexed field of
RequestIdwon’t match a log event containingrequestId.You can have one account-level field index policy that applies to all log groups in the account. Or you can create as many as 20 account-level field index policies that are each scoped to a subset of log groups with the
SelectionCriteriaparameter. If you have multiple account-level index policies with selection criteria, no two of them can use the same or overlapping log group name prefixes. For example, if you have one policy filtered to log groups that start withmy-log, you can’t have another field index policy filtered tomy-logpprodormy-logging.Transformer policy
A log transformer policy transforms ingested log events into a different format, making them easier for you to process and analyze. You can also transform logs from different sources into standardized formats that contain relevant, source-specific information. After you have created a transformer, CloudWatch Logs performs this transformation at the time of log ingestion. You can then refer to the transformed versions of the logs during operations such as querying with CloudWatch Logs Insights or creating metric filters or subscription filters.
You can also use a transformer to copy metadata from metadata keys into the log events themselves. This metadata can include log group name, log stream name, account ID and Region.
A transformer for a log group is a series of processors, where each processor applies one type of transformation to the log events ingested into this log group. For more information about the available processors to use in a transformer, see Processors that you can use .
Having log events in standardized format enables visibility across your applications for your log analysis, reporting, and alarming needs. CloudWatch Logs provides transformation for common log types with out-of-the-box transformation templates for major AWS log sources such as VPC flow logs, Lambda , and Amazon RDS . You can use pre-built transformation templates or create custom transformation policies.
You can create transformers only for the log groups in the Standard log class.
You can have one account-level transformer policy that applies to all log groups in the account. Or you can create as many as 20 account-level transformer policies that are each scoped to a subset of log groups with the
selectionCriteriaparameter. If you have multiple account-level transformer policies with selection criteria, no two of them can use the same or overlapping log group name prefixes. For example, if you have one policy filtered to log groups that start withmy-log, you can’t have another field index policy filtered tomy-logpprodormy-logging.You can also set up a transformer at the log-group level. For more information, see AWS::Logs::Transformer . If there is both a log-group level transformer created with
PutTransformerand an account-level transformer that could apply to the same log group, the log group uses only the log-group level transformer. It ignores the account-level transformer.- See:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-accountpolicy.html
- CloudformationResource:
AWS::Logs::AccountPolicy
- Mixin:
true
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview import mixins from aws_cdk.mixins_preview.aws_logs import mixins as logs_mixins cfn_account_policy_props_mixin = logs_mixins.CfnAccountPolicyPropsMixin(logs_mixins.CfnAccountPolicyMixinProps( policy_document="policyDocument", policy_name="policyName", policy_type="policyType", scope="scope", selection_criteria="selectionCriteria" ), strategy=mixins.PropertyMergeStrategy.OVERRIDE )
Create a mixin to apply properties to
AWS::Logs::AccountPolicy.- Parameters:
props (
Union[CfnAccountPolicyMixinProps,Dict[str,Any]]) – L1 properties to apply.strategy (
Optional[PropertyMergeStrategy]) – (experimental) Strategy for merging nested properties. Default: - PropertyMergeStrategy.MERGE
Methods
- apply_to(construct)
Apply the mixin properties to the construct.
- Parameters:
construct (
IConstruct)- Return type:
- supports(construct)
Check if this mixin supports the given construct.
- Parameters:
construct (
IConstruct)- Return type:
bool
Attributes
- CFN_PROPERTY_KEYS = ['policyDocument', 'policyName', 'policyType', 'scope', 'selectionCriteria']
Static Methods
- classmethod is_mixin(x)
(experimental) Checks if
xis a Mixin.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsMixin.- Stability:
experimental