Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Conversation

Copy link
Contributor

Copilot AI commented Oct 26, 2025

Lambda functions create log groups with indefinite retention by default. This adds a CloudFormation parameter to control log retention period with a default of 14 days.

Changes

  • New parameter: LogRetentionInDays with default value of 14, accepting all CloudFormation-supported retention periods (1-3653 days)
  • New resource: LambdaLogGroup explicitly creates the log group with configurable retention before Lambda initialization
  • Updated: .aws/README.md with parameter documentation and deployment examples

Usage

Parameters:
  LogRetentionInDays:
    Type: Number
    Default: 14
    Description: 'CloudWatch Logs retention period in days'

Deploy with custom retention:

aws cloudformation create-stack \
  --stack-name hono-lambda-poc-service \
  --template-body file://cfn-service.yml \
  --parameters \
    ParameterKey=ImageUri,ParameterValue=<ECR_IMAGE_URI> \
    ParameterKey=LogRetentionInDays,ParameterValue=30 \
  --capabilities CAPABILITY_NAMED_IAM

The explicit log group resource ensures CloudFormation manages the full lifecycle, including retention settings and cleanup on stack deletion.

Original prompt

This section details on the original issue you should resolve

<issue_title>cfn-serviceでCloudWatch Logsのretentionを指定するようにしたい</issue_title>
<issue_description>- CFnのパラメータにできると良い

  • デフォルトは14日 (2週間) としたい。</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: oyakodon <16263307+oyakodon@users.noreply.github.com>
Copilot AI changed the title [WIP] Add parameter for CloudWatch Logs retention in CFn feat(cfn): Add CloudWatch Logs retention parameter Oct 26, 2025
Copilot AI requested a review from oyakodon October 26, 2025 16:27
@oyakodon oyakodon marked this pull request as ready for review October 26, 2025 16:27
@oyakodon oyakodon merged commit 179a88f into main Oct 26, 2025
2 checks passed
@oyakodon oyakodon deleted the copilot/add-cloudwatch-logs-retention branch October 26, 2025 16:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cfn-serviceでCloudWatch Logsのretentionを指定するようにしたい

2 participants