You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: revert deprecation of logRetention properties (#28934)
### Issue
Closes#28919
### Reason for this change
In #28737 and #28783 we have deprecated various `logRetention` properties in favor of the new Logging Configuration feature for Lambda Functions. This new feature provides full control over the Lambda Function log group via the `logGroup` property.
However Logging Configuration is not available yet for all regions. Particularly GovCloud and CN regions (at the time this issue was created). For customers in of these regions there is currently no clear migration path.
We therefore revert the deprecation of previously deprecated properties.
### Description of changes
Revert the deprecation of previously deprecated `logRetention` properties.
Update documentation to be more explicit about the various options customers have.
### Description of how you validated changes
Documentation & annotation change only. This is a partial revert of the PRs linked about, with minor documentation updates.
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy file name to clipboardExpand all lines: packages/aws-cdk-lib/aws-lambda/README.md
+19
Original file line number
Diff line number
Diff line change
@@ -1011,6 +1011,25 @@ new lambda.Function(this, 'Lambda', {
1011
1011
});
1012
1012
```
1013
1013
1014
+
Providing a user-controlled log group was rolled out to commercial regions on 2023-11-16.
1015
+
If you are deploying to another type of region, please check regional availability first.
1016
+
1017
+
### Legacy Log Retention
1018
+
1019
+
As an alternative to providing a custom, user controlled log group, the legacy `logRetention` property can be used to set a different expiration period.
1020
+
This feature uses a Custom Resource to change the log retention of the automatically created log group.
1021
+
1022
+
By default, CDK uses the AWS SDK retry options when creating a log group. The `logRetentionRetryOptions` property
1023
+
allows you to customize the maximum number of retries and base backoff duration.
1024
+
1025
+
*Note* that a [CloudFormation custom
1026
+
resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cfn-customresource.html) is added
1027
+
to the stack that pre-creates the log group as part of the stack deployment, if it already doesn't exist, and sets the
1028
+
correct log retention period (never expire, by default). This Custom Resource will also create a log group to log events of the custom resource. The log retention period for this addtional log group is hard-coded to 1 day.
1029
+
1030
+
*Further note* that, if the log group already exists and the `logRetention` is not set, the custom resource will reset
1031
+
the log retention to never expire even if it was configured with a different value.
1032
+
1014
1033
## FileSystem Access
1015
1034
1016
1035
You can configure a function to mount an Amazon Elastic File System (Amazon EFS) to a
* this property, unsetting it doesn't remove the log retention policy. To
385
385
* remove the retention policy, set the value to `INFINITE`.
386
386
*
387
-
* @default logs.RetentionDays.INFINITE
388
-
*
389
-
* @deprecated instead create a fully customizable log group with `logs.LogGroup` and use the `logGroup` property to instruct the Lambda function to send logs to it.
387
+
* This is a legacy API and we strongly recommend you move away from it if you can.
388
+
* Instead create a fully customizable log group with `logs.LogGroup` and use the `logGroup` property
389
+
* to instruct the Lambda function to send logs to it.
390
390
* Migrating from `logRetention` to `logGroup` will cause the name of the log group to change.
391
391
* Users and code and referencing the name verbatim will have to adjust.
392
392
*
393
393
* In AWS CDK code, you can access the log group name directly from the LogGroup construct:
394
394
* ```ts
395
+
* import * as logs from 'aws-cdk-lib/aws-logs';
396
+
*
395
397
* declare const myLogGroup: logs.LogGroup;
396
398
* myLogGroup.logGroupName;
397
399
* ```
400
+
*
401
+
* @default logs.RetentionDays.INFINITE
398
402
*/
399
403
readonlylogRetention?: logs.RetentionDays;
400
404
401
405
/**
402
406
* The IAM role for the Lambda function associated with the custom resource
403
407
* that sets the retention policy.
404
408
*
405
-
* @default - A new role is created.
409
+
* This is a legacy API and we strongly recommend you migrate to `logGroup` if you can.
410
+
* `logGroup` allows you to create a fully customizable log group and instruct the Lambda function to send logs to it.
406
411
*
407
-
* @deprecated instead use `logGroup` to create a fully customizable log group and instruct the Lambda function to send logs to it.
412
+
* @default - A new role is created.
408
413
*/
409
414
readonlylogRetentionRole?: iam.IRole;
410
415
411
416
/**
412
417
* When log retention is specified, a custom resource attempts to create the CloudWatch log group.
413
418
* These options control the retry policy when interacting with CloudWatch APIs.
414
419
*
415
-
* @default - Default AWS SDK retry options.
420
+
* This is a legacy API and we strongly recommend you migrate to `logGroup` if you can.
421
+
* `logGroup` allows you to create a fully customizable log group and instruct the Lambda function to send logs to it.
416
422
*
417
-
* @deprecated instead use `logGroup` to create a fully customizable log group and instruct the Lambda function to send logs to it.
0 commit comments