amazon-web-servicesterraformamazon-elastic-beanstalkamazon-elb

How to set client_max_body_size for beanstalk load balancer in terraform?


I am struggling to change max_client_body_size for beanstalk load balancer in terraform. I know that it can be done by .ebextensions like in this thread but I am wondering if it can be easily done inside .tf file? For example I would like to be able to do something like this:

resource "aws_elastic_beanstalk_environment" "eb_env" {
  name                = "${var.app_name}-${var.env_name}"
  application         = data.terraform_remote_state.shared.outputs.eb_application_name
  solution_stack_name = "64bit Amazon Linux 2023 v4.0.1 running Docker"
  
  setting {
    namespace = "aws:elbv2:listener:80"
    name      = "ListenerEnabled"
    value     = "false"
  }
  setting {
    namespace = "aws:elbv2:listener:443"
    name      = "ListenerEnabled"
    value     = "true"
  }
  setting {
    namespace = "aws:elbv2:listener:443"
    name      = "SSLCertificateArns"
    value     = aws_acm_certificate.cert.arn
  }

  setting {
    namespace = "aws:elbv2:listener:443"
    name      = "DefaultProcess"
    value     = "default"
  }

  setting {
    namespace = "aws:elbv2:listener:443"
    name      = "Protocol"
    value     = "HTTPS"
  }
  // here example option that I would like to apply
  setting {
    namespace = "aws:elbv2:listener:443"
    name      = "MaxClientBodySize"
    value     = "30M"
  }

  // more other settings here ...

I know that I can use the docs, but I cannot find the option, but intuition tells me that such an option should exist


Solution

  • AWS Application load balancers do not have a maximum payload size limit. The thread you linked is specifically for setting the Nginx client_max_body_size. Nginx is the web server software that runs on your Elastic Beanstalk EC2 server. Nginx is not the load balancer. To modify the client_max_body_size you have to use the .ebextensions approach to modify the Nginx config file on the EC2 instance.