1 Answer
- Newest
- Most votes
- Most comments
0
To configure the retention period for API Gateway execution and access log groups, you have a few options:
- Using CloudFormation or AWS SAM templates: When creating your resources, you can define the CloudWatch Log Group with a specific retention period. For example, you could add this to your template:
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/apigateway/your-api-name"
RetentionInDays: 14
- Using the CloudFormation console:
- Sign in to the CloudFormation console
- Choose your stack
- Select the "Resources" tab and choose "Flat view"
- Search for "logs" in the search resources box
- Choose the log group you want to edit
- Select "Actions" then "Edit retention setting(s)"
- Choose your desired retention period
- Using AWS Cloud Control API: You can use the AWS CLI to update the retention period:
aws cloudcontrol create-resource --type-name AWS::Logs::LogGroup \
--desired-state '{"LogGroupName": "your-log-group-name","RetentionInDays": 90}'
By default, if you don't specify a retention period, CloudWatch log groups are set to "Never expire," which means you'll store and pay for those logs indefinitely. Setting an appropriate retention period based on your application's needs can help optimize costs.
Sources
Community | 5 ways to cost optimize your Infrastructure as Code
Change the CloudWatch log group retention period - Security Insights on AWS
Log and monitor C# Lambda functions - AWS Lambda
Getting started with Cloud Control API - Cloud Control API
answered a year ago
Relevant content
asked a year ago
asked a year ago
asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
