amazon-web-servicesamazon-elastic-beanstalkbuildspec

How to add .platform in buildspec.yml file artifacts


How I can include the .platform directory in the artifacts of the buildspec.yml file?

Background: I want to change the nginx setting client_max_body_size on Elastic Beanstalk. I am using CodePipeline to deploy my war file on Elastic Beanstalk.

Below is my repo directory structure:

├── .checkstyle
├── .gitignore
├── .platform
│   ├── hooks
│   │   └── postdeploy
│   │       └── 01_nginx.sh
│   └── nginx
│       └── conf.d
│           └── proxy.conf
├── README.md
├── appspec.yml
├── buildspec.yml
├── mvnw
├── mvnw.cmd
├── nginx.sh
├── pom.xml
└── src
    ├── .platform
    │   └── nginx
    │       └── conf.d
    │           ├── hooks
    │           │   └── postdeploy
    │           │       └── 01_nginx.sh
    │           └── proxy.conf
    ├── main
    │   ├── java
    │   │   └── com
    │   │       └── k12
    │   │           └── caap
    │   │               └── service
    │   │                   └── ServiceNAME

Edit: The buildspec.yml is not including the '.platform' directory in the artifact.zip file. The proxy.conf file is not getting added on the server.

buildspec.yml:

version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto11

  pre_build:
    commands:
      - pip3 install awscli --upgrade --user

  build:
    commands:
      - mvn clean compile package
      
artifacts:
  files:
    - target/*.war
    - '.platform'        
  discard-paths: yes

Below are the logs from EC2 /var/log/eb-engine.log

[INFO] Executing instruction: RunAppDeployPostDeployHooks                      
[INFO] Executing platform hooks in .platform/hooks/postdeploy/                 
[INFO] The dir .platform/hooks/postdeploy/ does not exist                      
[INFO] Finished running scripts in /var/app/current/.platform/hooks/postdeploy 

Content of 01_nginx.sh script

echo "client_max_body_size 20M;" > /etc/nginx/conf.d/proxy.conf
systemctl restart nginx.service


Solution

  • There are three misconfigurations and two tips to improve: