aws / aws/aws-cdk

[aws-ec2] Accidental Log Group creation when creating a VPC

Open
#33,025 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 bug effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When adding a VPC with:
`const vpc = new ec2.Vpc(this, 'SomeVpc');`

a Lambda function is created with the description:
`Lambda function for removing all inbound/outbound rules from the VPC default security group`
and immediately deleted after the deployment is finished.

The main problem this generates is that as a consequence of the Lambda, a Log Group is also created, with retention set to `never expire`.
When the stack is deleted, the Log Group remains.

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Version

_No response_

### Expected Behavior

A way to configure log retention.

### Current Behavior

When the stack is deleted, the Log Group remains.

### Reproduction Steps

`const vpc = new ec2.Vpc(this, 'SomeVpc');`

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.156.0 (build 2966832)

### Framework Version

_No response_

### Node.js Version

v22.9.0

### OS

OSX

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

No source files or tests are mentioned. Start by reproducing the VPC creation with `new ec2.Vpc(this, 'SomeVpc')` and inspect the generated Lambda and Log Group resources; done means log retention is configurable and the Log Group does not remain unexpectedly after stack deletion.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.