# AWS Cloudfront provisioning - lambda\_function\_association

**URL:** <https://discuss.hashicorp.com/t/aws-cloudfront-provisioning-lambda-function-association/29121>\
**Category:** Terraform\
**Created:** [September 3, 2021, 5:48pm UTC](https://discuss.hashicorp.com/t/aws-cloudfront-provisioning-lambda-function-association/29121 "2021-09-03T17:48:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bnathreddy1](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/bnathreddy1/32/20101_2.png) [@bnathreddy1](https://discuss.hashicorp.com/u/bnathreddy1)\
**Post date:** [September 3, 2021, 5:48pm UTC](https://discuss.hashicorp.com/t/aws-cloudfront-provisioning-lambda-function-association/29121/1 "2021-09-03T17:48:44Z")

</div>

Using terraform, I am provisioning cloudfront. One of the attribute is “lambda\_function\_association” where we associate a lambda to the cloudfront.

I get the following error message complaining about lambda function memory size

````
    ```

````

```auto
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-east-1:myaccount:function:myaccount- 
    dev-cloudfrontheaders1:2  

resource "aws_cloudfront_distribution" "clientcloudfrontdistrotest" {

  default_cache_behavior {
      forwarded_values {
      query_string = true
      cookies {
          forward = "none"
      }
   }

   lambda_function_association {
      event_type = "viewer-response"
     include_body = false
     lambda_arn = var.lambda_arn
  
   } 
   target_origin_id = var.targetoriginid
   viewer_protocol_policy = var.viewerprotocolpolicy
  }
 }
  resource "aws_cloudfront_origin_access_identity" "origin_access_identity" {
  comment = "Origin Access ID for admin UI"

}

```

```auto

```
