Heyo, on destroying a stack that had Lambda functi...
# aws
t
Heyo, on destroying a stack that had Lambda functions created as described in the Crosswalk for AWS section, how can I make it so the implicitly generated Cloudwatch log groups for these Lambdas are destroyed as well?
b
someone else may know something i don't here, but since those log groups aren't created until the function executes i don't believe Pulumi would have any way of knowing they exist or what they're named
t
Ah, hm, so it's entirely an AWS thing
Thanks for the answer!
b
sure thing
p
You have to create the log group after the Lambda function and explicitly set a dependency. In Python:
Copy code
my_lambda_log_group = aws.cloudwatch.LogGroup(
    "my-lambda",
    retention_in_days=30,
    name=my_lambda.name.apply(
        lambda name: f'/aws/lambda/{name}'
    ),
    opts=pulumi.ResourceOptions(depends_on=[my_lambda])
)
This way it's also possible to set e.g. retention which would otherwise be 1 month by default.
🙌 1
The only downside is that you can't come with your own name for the log group, it has to follow the standard naming (i.e.
/aws/lambda/...
)