Skip to content

Commit 3bf5ed5

Browse files
author
awstools
committed
feat(client-cloudwatch-logs): Add support for account level subscription filter policies to PutAccountPolicy, DescribeAccountPolicies, and DeleteAccountPolicy APIs. Additionally, PutAccountPolicy has been modified with new optional "selectionCriteria" parameter for resource selection.
1 parent f7bd277 commit 3bf5ed5

File tree

6 files changed

+170
-30
lines changed

6 files changed

+170
-30
lines changed

clients/client-cloudwatch-logs/src/commands/DeleteAccountPolicyCommand.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@ export interface DeleteAccountPolicyCommandOutput extends __MetadataBearer {}
2828

2929
/**
3030
* @public
31-
* <p>Deletes a CloudWatch Logs account policy.</p>
32-
* <p>To use this operation, you must be signed on with the <code>logs:DeleteDataProtectionPolicy</code> and
33-
* <code>logs:DeleteAccountPolicy</code> permissions.</p>
31+
* <p>Deletes a CloudWatch Logs account policy. This stops the policy from applying to all log groups
32+
* or a subset of log groups in the account. Log-group level policies will still be in effect.</p>
33+
* <p>To use this operation, you must be signed on with the correct permissions depending on the type of policy
34+
* that you are deleting.</p>
35+
* <ul>
36+
* <li>
37+
* <p>To delete a data protection policy, you must have the <code>logs:DeleteDataProtectionPolicy</code> and
38+
* <code>logs:DeleteAccountPolicy</code> permissions.</p>
39+
* </li>
40+
* <li>
41+
* <p>To delete a subscription filter policy, you must have the <code>logs:DeleteSubscriptionFilter</code> and
42+
* <code>logs:DeleteAccountPolicy</code> permissions.</p>
43+
* </li>
44+
* </ul>
3445
* @example
3546
* Use a bare-bones client and the command you need to make an API call.
3647
* ```javascript
@@ -39,7 +50,7 @@ export interface DeleteAccountPolicyCommandOutput extends __MetadataBearer {}
3950
* const client = new CloudWatchLogsClient(config);
4051
* const input = { // DeleteAccountPolicyRequest
4152
* policyName: "STRING_VALUE", // required
42-
* policyType: "DATA_PROTECTION_POLICY", // required
53+
* policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY", // required
4354
* };
4455
* const command = new DeleteAccountPolicyCommand(input);
4556
* const response = await client.send(command);

clients/client-cloudwatch-logs/src/commands/DescribeAccountPoliciesCommand.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface DescribeAccountPoliciesCommandOutput extends DescribeAccountPol
3636
* // const { CloudWatchLogsClient, DescribeAccountPoliciesCommand } = require("@aws-sdk/client-cloudwatch-logs"); // CommonJS import
3737
* const client = new CloudWatchLogsClient(config);
3838
* const input = { // DescribeAccountPoliciesRequest
39-
* policyType: "DATA_PROTECTION_POLICY", // required
39+
* policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY", // required
4040
* policyName: "STRING_VALUE",
4141
* accountIdentifiers: [ // AccountIds
4242
* "STRING_VALUE",
@@ -50,8 +50,9 @@ export interface DescribeAccountPoliciesCommandOutput extends DescribeAccountPol
5050
* // policyName: "STRING_VALUE",
5151
* // policyDocument: "STRING_VALUE",
5252
* // lastUpdatedTime: Number("long"),
53-
* // policyType: "DATA_PROTECTION_POLICY",
53+
* // policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY",
5454
* // scope: "ALL",
55+
* // selectionCriteria: "STRING_VALUE",
5556
* // accountId: "STRING_VALUE",
5657
* // },
5758
* // ],

clients/client-cloudwatch-logs/src/commands/PutAccountPolicyCommand.ts

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,20 @@ export interface PutAccountPolicyCommandOutput extends PutAccountPolicyResponse,
2828

2929
/**
3030
* @public
31-
* <p>Creates an account-level data protection policy that applies to all log groups in the account. A data protection policy can help safeguard sensitive
31+
* <p>Creates an account-level data protection policy or subscription filter policy that applies to all log groups
32+
* or a subset of log groups in the account.</p>
33+
* <p>
34+
* <b>Data protection policy</b>
35+
* </p>
36+
* <p>A data protection policy can help safeguard sensitive
3237
* data that's ingested by your log groups by auditing and masking the sensitive log data. Each account can have only
33-
* one account-level policy.</p>
38+
* one account-level data protection policy.</p>
3439
* <important>
3540
* <p>Sensitive data is detected and masked when it is ingested into a log group. When you set a
3641
* data protection policy, log events ingested into the log groups before that time are not masked.</p>
3742
* </important>
3843
* <p>If you use <code>PutAccountPolicy</code> to create a data protection policy for your whole account, it applies to both existing log groups
39-
* and all log groups that are created later in this account. The account policy is applied to existing log groups
44+
* and all log groups that are created later in this account. The account-level policy is applied to existing log groups
4045
* with eventual consistency. It might take up to 5 minutes before sensitive data in existing log groups begins to be masked.</p>
4146
* <p>By default, when a user views a log event that includes masked data, the sensitive data is replaced by asterisks.
4247
* A user who has the <code>logs:Unmask</code> permission can use a
@@ -47,14 +52,43 @@ export interface PutAccountPolicyCommandOutput extends PutAccountPolicyResponse,
4752
* console by running a CloudWatch Logs Insights query with the <code>unmask</code> query command.</p>
4853
* <p>For more information, including a list of types of data that can be audited and masked, see
4954
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/mask-sensitive-log-data.html">Protect sensitive log data with masking</a>.</p>
50-
* <p>To use the <code>PutAccountPolicy</code> operation, you must be signed on with the <code>logs:PutDataProtectionPolicy</code>
55+
* <p>To use the <code>PutAccountPolicy</code> operation for a data protection policy, you must be signed on with
56+
* the <code>logs:PutDataProtectionPolicy</code>
5157
* and <code>logs:PutAccountPolicy</code> permissions.</p>
52-
* <p>The <code>PutAccountPolicy</code> operation applies to all log groups in the account. You can also use
58+
* <p>The <code>PutAccountPolicy</code> operation applies to all log groups in the account. You can use
5359
* <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDataProtectionPolicy.html">PutDataProtectionPolicy</a>
5460
* to create a data protection policy that applies to just one log group.
5561
* If a log group has its own data protection policy and
5662
* the account also has an account-level data protection policy, then the two policies are cumulative. Any sensitive term
5763
* specified in either policy is masked.</p>
64+
* <p>
65+
* <b>Subscription filter policy</b>
66+
* </p>
67+
* <p>A subscription filter policy sets up a real-time feed of log events from CloudWatch Logs to other Amazon Web Services services.
68+
* Account-level subscription filter policies apply to both existing log groups and log groups that are created later in
69+
* this account. Supported destinations are Kinesis Data Streams, Kinesis Data Firehose, and
70+
* Lambda. When log events are sent to the receiving service, they are Base64 encoded and
71+
* compressed with the GZIP format.</p>
72+
* <p>The following destinations are supported for subscription filters:</p>
73+
* <ul>
74+
* <li>
75+
* <p>An Kinesis Data Streams data stream in the same account as the subscription policy, for same-account delivery.</p>
76+
* </li>
77+
* <li>
78+
* <p>An Kinesis Data Firehose data stream in the same account as the subscription policy, for same-account delivery.</p>
79+
* </li>
80+
* <li>
81+
* <p>A Lambda function in the same account as the subscription policy, for same-account delivery.</p>
82+
* </li>
83+
* <li>
84+
* <p>A logical destination in a different account created with <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDestination.html">PutDestination</a>, for cross-account
85+
* delivery. Kinesis Data Streams and Kinesis Data Firehose are supported as logical destinations.</p>
86+
* </li>
87+
* </ul>
88+
* <p>Each account can have one account-level subscription filter policy.
89+
* If you are updating an existing filter, you must specify the correct name in <code>PolicyName</code>.
90+
* To perform a <code>PutAccountPolicy</code> subscription filter operation for any destination except a Lambda
91+
* function, you must also have the <code>iam:PassRole</code> permission.</p>
5892
* @example
5993
* Use a bare-bones client and the command you need to make an API call.
6094
* ```javascript
@@ -64,8 +98,9 @@ export interface PutAccountPolicyCommandOutput extends PutAccountPolicyResponse,
6498
* const input = { // PutAccountPolicyRequest
6599
* policyName: "STRING_VALUE", // required
66100
* policyDocument: "STRING_VALUE", // required
67-
* policyType: "DATA_PROTECTION_POLICY", // required
101+
* policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY", // required
68102
* scope: "ALL",
103+
* selectionCriteria: "STRING_VALUE",
69104
* };
70105
* const command = new PutAccountPolicyCommand(input);
71106
* const response = await client.send(command);
@@ -74,8 +109,9 @@ export interface PutAccountPolicyCommandOutput extends PutAccountPolicyResponse,
74109
* // policyName: "STRING_VALUE",
75110
* // policyDocument: "STRING_VALUE",
76111
* // lastUpdatedTime: Number("long"),
77-
* // policyType: "DATA_PROTECTION_POLICY",
112+
* // policyType: "DATA_PROTECTION_POLICY" || "SUBSCRIPTION_FILTER_POLICY",
78113
* // scope: "ALL",
114+
* // selectionCriteria: "STRING_VALUE",
79115
* // accountId: "STRING_VALUE",
80116
* // },
81117
* // };

clients/client-cloudwatch-logs/src/commands/StartLiveTailCommand.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export interface StartLiveTailCommandOutput extends StartLiveTailResponse, __Met
7070
* <p>You can end a session before it times out by closing the session stream or by closing the client that is receiving the
7171
* stream. The session also ends if the established connection between the client and the server breaks.</p>
7272
* </important>
73+
* <p>For examples of using an SDK to start a Live Tail session, see
74+
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/example_cloudwatch-logs_StartLiveTail_section.html">
75+
* Start a Live Tail session using an Amazon Web Services SDK</a>.</p>
7376
* @example
7477
* Use a bare-bones client and the command you need to make an API call.
7578
* ```javascript

clients/client-cloudwatch-logs/src/models/models_0.ts

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class AccessDeniedException extends __BaseException {
2929
*/
3030
export const PolicyType = {
3131
DATA_PROTECTION_POLICY: "DATA_PROTECTION_POLICY",
32+
SUBSCRIPTION_FILTER_POLICY: "SUBSCRIPTION_FILTER_POLICY",
3233
} as const;
3334

3435
/**
@@ -85,6 +86,12 @@ export interface AccountPolicy {
8586
*/
8687
scope?: Scope;
8788

89+
/**
90+
* @public
91+
* <p>The log group selection criteria for this subscription filter policy.</p>
92+
*/
93+
selectionCriteria?: string;
94+
8895
/**
8996
* @public
9097
* <p>The Amazon Web Services account ID that the policy applies to.</p>
@@ -970,7 +977,7 @@ export interface CreateLogGroupRequest {
970977
* </ul>
971978
* <p>If you omit this parameter, the default of <code>STANDARD</code> is used.</p>
972979
* <important>
973-
* <p>After a log group is created, its class can't be changed.</p>
980+
* <p>The value of <code>logGroupClass</code> can't be changed after a log group is created.</p>
974981
* </important>
975982
* <p>For details about the features supported by each class, see
976983
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch_Logs_Log_Classes.html">Log classes</a>
@@ -1053,7 +1060,7 @@ export interface DeleteAccountPolicyRequest {
10531060

10541061
/**
10551062
* @public
1056-
* <p>The type of policy to delete. Currently, the only valid value is <code>DATA_PROTECTION_POLICY</code>.</p>
1063+
* <p>The type of policy to delete.</p>
10571064
*/
10581065
policyType: PolicyType | undefined;
10591066
}
@@ -1431,7 +1438,7 @@ export interface DescribeAccountPoliciesRequest {
14311438
/**
14321439
* @public
14331440
* <p>Use this parameter to limit the returned policies to only the policies that match the policy type that you
1434-
* specify. Currently, the only valid value is <code>DATA_PROTECTION_POLICY</code>.</p>
1441+
* specify.</p>
14351442
*/
14361443
policyType: PolicyType | undefined;
14371444

@@ -3885,8 +3892,11 @@ export interface PutAccountPolicyRequest {
38853892

38863893
/**
38873894
* @public
3888-
* <p>Specify the data protection policy, in JSON.</p>
3889-
* <p>This policy must include two JSON blocks:</p>
3895+
* <p>Specify the policy, in JSON.</p>
3896+
* <p>
3897+
* <b>Data protection policy</b>
3898+
* </p>
3899+
* <p>A data protection policy must include two JSON blocks:</p>
38903900
* <ul>
38913901
* <li>
38923902
* <p>The first block must include both a <code>DataIdentifer</code> array and an
@@ -3919,13 +3929,57 @@ export interface PutAccountPolicyRequest {
39193929
* <code>Description</code>, and <code>Version</code> fields. The <code>Name</code> is different than the
39203930
* operation's <code>policyName</code> parameter, and is used as a dimension when
39213931
* CloudWatch Logs reports audit findings metrics to CloudWatch.</p>
3922-
* <p>The JSON specified in <code>policyDocument</code> can be up to 30,720 characters.</p>
3932+
* <p>The JSON specified in <code>policyDocument</code> can be up to 30,720 characters long.</p>
3933+
* <p>
3934+
* <b>Subscription filter policy</b>
3935+
* </p>
3936+
* <p>A subscription filter policy can include the following attributes in a JSON block:</p>
3937+
* <ul>
3938+
* <li>
3939+
* <p>
3940+
* <b>DestinationArn</b> The ARN of the destination
3941+
* to deliver log events to. Supported destinations are:</p>
3942+
* <ul>
3943+
* <li>
3944+
* <p>An Kinesis Data Streams data stream in the same account as the subscription policy, for same-account delivery.</p>
3945+
* </li>
3946+
* <li>
3947+
* <p>An Kinesis Data Firehose data stream in the same account as the subscription policy, for same-account delivery.</p>
3948+
* </li>
3949+
* <li>
3950+
* <p>A Lambda function in the same account as the subscription policy, for same-account delivery.</p>
3951+
* </li>
3952+
* <li>
3953+
* <p>A logical destination in a different account created with <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDestination.html">PutDestination</a>, for cross-account
3954+
* delivery. Kinesis Data Streams and Kinesis Data Firehose are supported as logical destinations.</p>
3955+
* </li>
3956+
* </ul>
3957+
* </li>
3958+
* <li>
3959+
* <p>
3960+
* <b>RoleArn</b> The ARN of an IAM role that grants CloudWatch Logs permissions to deliver ingested log
3961+
* events to the destination stream. You don't need to provide the ARN when you are working with
3962+
* a logical destination for cross-account delivery.</p>
3963+
* </li>
3964+
* <li>
3965+
* <p>
3966+
* <b>FilterPattern</b> A filter pattern for subscribing to a
3967+
* filtered stream of log events.</p>
3968+
* </li>
3969+
* <li>
3970+
* <p>
3971+
* <b>Distribution</b>The method used to distribute log data to the destination.
3972+
* By default, log data is
3973+
* grouped by log stream, but the grouping can be set to <code>Random</code> for a more even distribution.
3974+
* This property is only applicable when the destination is an Kinesis Data Streams data stream.</p>
3975+
* </li>
3976+
* </ul>
39233977
*/
39243978
policyDocument: string | undefined;
39253979

39263980
/**
39273981
* @public
3928-
* <p>Currently the only valid value for this parameter is <code>DATA_PROTECTION_POLICY</code>.</p>
3982+
* <p>The type of policy that you're creating or updating.</p>
39293983
*/
39303984
policyType: PolicyType | undefined;
39313985

@@ -3936,6 +3990,18 @@ export interface PutAccountPolicyRequest {
39363990
* of <code>ALL</code> is used.</p>
39373991
*/
39383992
scope?: Scope;
3993+
3994+
/**
3995+
* @public
3996+
* <p>Use this parameter to apply the subscription filter policy to a subset of log groups in the account.
3997+
* Currently, the only supported filter is <code>LogGroupName NOT IN []</code>. The <code>selectionCriteria</code>
3998+
* string can be up to 25KB in length. The length is determined by using its UTF-8 bytes.</p>
3999+
* <p>Using the <code>selectionCriteria</code> parameter is useful to help prevent infinite loops.
4000+
* For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Subscriptions-recursion-prevention.html">Log recursion prevention</a>.</p>
4001+
* <p>Specifing <code>selectionCriteria</code> is valid only when you specify <code> SUBSCRIPTION_FILTER_POLICY</code>
4002+
* for <code>policyType</code>.</p>
4003+
*/
4004+
selectionCriteria?: string;
39394005
}
39404006

39414007
/**
@@ -4585,6 +4651,7 @@ export interface StartLiveTailRequest {
45854651
* @public
45864652
* <p>If you specify this parameter, then only log events in the log streams that you specify here are
45874653
* included in the Live Tail session.</p>
4654+
* <p>If you specify this field, you can't also specify the <code>logStreamNamePrefixes</code> field.</p>
45884655
* <note>
45894656
* <p>You can specify this parameter only if you specify only one log group in <code>logGroupIdentifiers</code>.</p>
45904657
* </note>
@@ -4596,6 +4663,7 @@ export interface StartLiveTailRequest {
45964663
* <p>If you specify this parameter, then only log events in the log streams that have names that start with the
45974664
* prefixes that you specify here are
45984665
* included in the Live Tail session.</p>
4666+
* <p>If you specify this field, you can't also specify the <code>logStreamNames</code> field.</p>
45994667
* <note>
46004668
* <p>You can specify this parameter only if you specify only one log group in <code>logGroupIdentifiers</code>.</p>
46014669
* </note>

0 commit comments

Comments
 (0)