title: AWS Cloudfront provisioning - lambda_function_association
body: <p>Using Terraform, I am provisioning CloudFront. One of the attribute is <code>lambda_function_association</code> where we associate a lambda to the CloudFront.</p>
  <p>I get the following error message complaining about lambda function memory size</p>
  <pre><code>  Error: error updating CloudFront Distribution (ENLY37UZ3CJCF): 
       InvalidLambdaFunctionAssociation: The function memory size is larger than the maximum 
       allowed size for functions that are triggered by a CloudFront event: 1024 
       Max allowed: 128 Function: arn:aws:lambda:us-eas-1-myaccount:function:myaccount- 
      dev-cloudfrontheaders1:2  
  
  resource &quot;aws_cloudfront_distribution&quot; &quot;clientcloudfrontdistrotest&quot; {
  
  
    default_cache_behavior {
        forwarded_values {
        query_string = true
        cookies {
            forward = &quot;none&quot;
        }
     }
  
  
     lambda_function_association {
        event_type   = &quot;viewer-response&quot;
       include_body = false
       lambda_arn =  var.lambda_arn
    
     } 
     target_origin_id       = var.targetoriginid
     viewer_protocol_policy = var.viewerprotocolpolicy
    }
   }
    resource &quot;aws_cloudfront_origin_access_identity&quot; &quot;origin_access_identity&quot; {
    comment = &quot;Origin Access ID for admin UI&quot;
  
  }
  </code></pre>