title: Set expiration of CloudWatch Log Group for Lambda Function
body: <p>By default when I create a Lambda function, the CloudWatch Log Group is set to Never Expire. Is it possible to set the expiration (saying 14 days) so I don't have to set it manually from the console after creation? </p>
  
  <hr>
  
  <p><strong>Updated#1</strong> </p>
  
  <p>Thanks to <a href="https://stackoverflow.com/a/45369668/1480391">@jens walter answer</a> this is a code snippet of how to solve the problem</p>
  
  <pre><code>Resources:
    LambdaFunction:
      Type: AWS::Serverless::Function
      Properties:
        Handler: index.handler
        Runtime: nodejs6.10
        CodeUri: &lt;your code uri&gt;
        Policies: &lt;your policies&gt; 
  
  
    LambdaFunctionLogGroup:
      Type: "AWS::Logs::LogGroup"
      DependsOn: "LambdaFunction"
      Properties: 
        RetentionInDays: 14
        LogGroupName: !Join ["", ["/aws/lambda/", !Ref LambdaFunction]]
  </code></pre>