skip to Main Content

I am trying to deploy an app to Elastic Beanstalk using a GitHub action. I tried to compress the file before pushing it to ELB, and it is smaller than 512MB (around 400MB), but I still see this error message when the action finishes. Any clue? Thanks

This is the action:

name: EB deploy
on:
  push:
    branches: [ develop ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DEVELOP_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEVELOP_SECRET_ACCESS_KEY }}
      AWS_DEFAULT_REGION: ${{ secrets.AWS_DEVELOP_DEFAULT_REGION }}
      AWS_APPLICATION_NAME: ${{ secrets.AWS_DEVELOP_APPLICATION_NAME }}
      AWS_ENVIRONMENT_NAME:  ${{ secrets.AWS_DEVELOP_ENVIRONMENT_NAME }}
            
    steps:
      - uses: actions/checkout@v2
      - name: Install Python 3.9
        uses: actions/setup-python@v2
        with:
          python-version: 3.9
      - name: Generate deployment package
        #  run: zip -r deploy.zip * .[^.]* -x "**node_modules, Dockerfile, docker-compose.yml, vendor**"
        # create the zip
        run: zip -r deploy.zip . -x '*.png'  -x '.gitignore'  -x '/plugins/*/webroot/build/*' -x '/plugins/*/webroot/fonts/*'   -x '*.git/*' -x '*.jpeg' -x 'build/*' -x '*.webp' -x 'config-dev-server' -x '*.JPG' -x '*/node_modules/*' -x '.env_example' -x '.htaccess' -x '/plugins/*/webroot/node_modules/*' -x 'webroot/webpack-updater/*' -x '.dockerignore' -x '.vscode' -x '*.gif' -x 'tmp/*' -x 'webroot/cypress/*' -x 'Dockerfile' -x 'docker-compose.yml' -x '*/files/*' -x 'webroot/tests/*' -x '/webroot/node_modules/*' -x '*.jpg' -x '/vendor/*' -x 'webroot/nodeScripts/*' -x '/db/*' -x 'config-dev-server/*' -x 'amplify/*' -x 'amplify_new/*' -x 'webroot/admin/dev/*' -x '/plugins/*/webroot/build/*' -x 'plugins/*/webroot/dev/*' -x '.elasticbeanstalk/app_versions/*'

      - name: Install EB CLI using pip
        run: |
          python -m pip install --upgrade pip
          pip install awsebcli
      - name: Deploy to Elastic Beanstalk
        run: |
          eb init --platform 'PHP 7.4 running on 64bit Amazon Linux 2' --region 'eu-west-2' Develop
          eb deploy

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    Finally I solved using a different code (uploading first to S3 and deploy from there):

    name: EB deploy
    on:
      push:
        branches: [ develop ]
    jobs:
      deploy:
        runs-on: ubuntu-latest
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DEVELOP_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEVELOP_SECRET_ACCESS_KEY }}
          AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
          AWS_APPLICATION_NAME: ${{ secrets.AWS_DEVELOP_APPLICATION_NAME }}
          AWS_ENVIRONMENT_NAME:  ${{ secrets.AWS_DEVELOP_ENVIRONMENT_NAME }}
                
        steps:
          - uses: actions/checkout@v2
          - name: Install Python 3.9
            uses: actions/setup-python@v2
            with:
              python-version: 3.9
          - name: Generate deployment package
            ## create the zip
            run: zip -r deploy-${{ github.sha }}.zip . -x '*.png'  -x '.gitignore'  -x '/plugins/*/webroot/build/*' -x '/plugins/*/webroot/fonts/*'   -x '*.git/*' -x '*.jpeg' -x 'build/*' -x '*.webp' -x 'config-dev-server' -x '*.JPG' -x '*/node_modules/*' -x '.env_example' -x '.htaccess' -x '/plugins/*/webroot/node_modules/*' -x 'webroot/webpack-updater/*' -x '.dockerignore' -x '.vscode' -x '*.gif' -x 'tmp/*' -x 'webroot/cypress/*' -x 'Dockerfile' -x 'docker-compose.yml' -x '*/files/*' -x 'webroot/tests/*' -x '/webroot/node_modules/*' -x '*.jpg' -x 'webroot/assets/*' -x '/vendor/*' -x 'webroot/nodeScripts/*' -x '/db/*' -x 'config-dev-server/*' -x 'amplify/*' -x 'amplify_new/*' -x 'webroot/admin/dev/*' -x '/plugins/*/webroot/build/*' -x 'plugins/*/webroot/dev/*' -x '.elasticbeanstalk/app_versions/*'
          - name: Install EB CLI using pip
            run: |
              python -m pip install --upgrade pip
              pip install awsebcli
          - name: Upload package to S3 bucket
            run: |
              eb init --platform 'PHP 7.4 running on 64bit Amazon Linux 2' --region  ${{ secrets.AWS_DEFAULT_REGION }} Develop
              aws s3 --region  ${{ secrets.AWS_DEFAULT_REGION }} cp deploy-${{ github.sha }}.zip s3://github-tasks/tasks-develop/
          - name: Create new ElasticBeanstalk Application Version on region ${{ secrets.AWS_DEFAULT_REGION }}
            run: |
              aws  elasticbeanstalk create-application-version 
              --application-name Develop 
              --source-bundle S3Bucket="github-tasks",S3Key="tasks-develop/deploy-${{ github.sha }}.zip" 
              --version-label "ver-${{ github.sha }}" 
              --description "commit-sha-${{ github.sha }}"
          - name: Deploy new ElasticBeanstalk Application Version
            run: aws elasticbeanstalk update-environment --environment-name ${{ secrets.AWS_DEVELOP_ENVIRONMENT_NAME }} --version-label "ver-${{ github.sha }}"
    

    1. Try to reproduce all the steps locally. Check the size of the deployment package. If no issues detected locally proceed to remote machine.
    2. Add additional step to your workflow after you generate deployment package to check if size of the package is definitely is lower than 512 MBs.
    - name: Check package size
      run: ls -laSh
    
    1. Check if zip compiled with bzip2 on remote runner for better compression by adding this option to the command: -Z bzip2
    2. Check events in EB Console or via CLI to see any events occured in your env. See reference: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.events.html
    3. If everything is OK, maybe there is an issue with this particular region. Try to use other one.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search