---
title: "Discussion on \"Mastering AWS CDK Aspects\" | Hashnode"
description: "Discussion on \"Mastering AWS CDK Aspects\". AWS CDK Aspects are a powerful tool provided by the AWS Cloud Development Kit (CDK). Learn how to master them by creating various Aspects on your own."
url: "https://hashnode.com/posts/mastering-aws-cdk-aspects/63353bc0697c5665ab7e3ec6"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Mastering AWS CDK Aspects](https://wempe.dev/blog/mastering-aws-cdk-aspects?utm_source=hashnode&utm_medium=feed)

AWS CDK Aspects are a powerful tool provided by the AWS Cloud Development Kit (CDK). Learn how to master them by creating various Aspects on your own.

Sep 29, 2022 · 9 min read · wempe.dev  
Read the article

-   [#aws](https://hashnode.com/tag/aws)
-   [#aws-cdk](https://hashnode.com/tag/aws-cdk)

## Written by

[Jannik Wempe](https://hashnode.com/@JannikWempe)

@JannikWempe · Hamburg, Germany

  
[View profile](https://hashnode.com/@JannikWempe)

Platform Engineering Lead @hashnode | Serverless and Frontend Enthusiast

Platform Engineering Lead @hashnode Serverless and Frontend Enthusiast 🤓 Into AWS, TypeScript, React, Svelte and upcoming trends… ☁️ AWS Community Builder Serverless Coding is not only a job – it's a passion. Based in Hamburg 🇩🇪

## Responses 1

Markdown supported · ⌘↵ to post

[Derek Murawsky](https://hashnode.com/@dmurawsky)

[Feb 24, 2023](https://hashnode.com/posts/mastering-aws-cdk-aspects/63353bc0697c5665ab7e3ec6/comment/63f93a085ebda1e9aa53d2e4)

This is awesome, and was a very helpful writeup in helping me understand aspects. Thank you! Unfortunately, the logging solution does not work for _existing_ lambdas because they already have a log group created. I can't think of a good way of handling that other than changing the settings on the lambda function itself. A custom construct might be a better approach for that?

[Derek Murawsky](https://hashnode.com/@dmurawsky)

[Feb 27, 2023](https://hashnode.com/posts/mastering-aws-cdk-aspects/63353bc0697c5665ab7e3ec6/comment/63f93a085ebda1e9aa53d2e4#reply-63fce7d09bc922223b9061a1)

To answer my own question, and for anyone else that runs into this problem, the LogRetention class is the way to go. [docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.a…](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogRetention.html) "Creates a custom resource to control the retention policy of a CloudWatch Logs log group. The log group is created if it doesn't already exist." This lets you manage the auto-created ones that already exist as well as create new ones that don't. It goes in cleanly and does the job. :)
