Skip to content

feature: Allow to define LogGroup for function #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 22, 2023

Conversation

whisller
Copy link
Collaborator

This change allows to set Properties for LogGroup which is created for lambda function.

Real use cases for that can be when you want to modify default 30 days of RetentionInDays or add DataProtectionPolicy

Usage:

service.builder.function.generic(
    “my-function”,
    “Handle requests",
    handler=my_module.appsync.handler",
    log_group=dict(Properties=dict(RetentionInDays=3653))
)

This change allows to set `Properties` for `LogGroup` which is created for lambda function.

Real use cases for that can be when you want to modify default `30` days of `RetentionInDays` or add `DataProtectionPolicy`

Usage:

```python
service.builder.function.generic(
    “my-function”,
    “Handle requests",
    handler=“my_module.appsync.handler",
    log_group=dict(Properties=dict(RetentionInDays=3653))
)
```
@whisller whisller requested a review from a team as a code owner September 22, 2023 11:36
Comment on lines 104 to 103
log_group = dict(Type="AWS::Logs::LogGroup", Properties=dict(RetentionInDays=30))
log_group_properties = kwargs.pop("log_group", {}).get("Properties") if kwargs.get("log_group", {}).get("Properties") else dict(RetentionInDays=30)

log_group = dict(Type="AWS::Logs::LogGroup", Properties=log_group_properties)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be a bug here if you have a log_group argument containing an "falsey" Properties value. It wouldn't pop the log_group argument in that case, and then it would get included in the loop at the end of the function.

I think this would achieve basically the same thing:

log_group_properties = kwargs.pop("log_group", {}).get("Properties") or dict(RetentionInDays=30)

@whisller whisller merged commit e24ec69 into master Sep 22, 2023
@whisller whisller deleted the feature/allow-to-override-log-group-for-lambda branch September 22, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants