4

I'm using CodePipeline to deploy whatever is on master branch of the git to Elastic Beanstalk.

I followed this tutorial to extend the default nginx configuration (specifically the max-body-size): https://medium.com/swlh/using-ebextensions-to-extend-nginx-default-configuration-in-aws-elastic-beanstalk-189b844ab6ad

However, because I'm not using the standard eb deploy command, I dont think the CodePipeline flow is going into the .ebextension directory and doing the things its supposed to do.

Is there a way to use code pipeline (so i can have CI/CD from master) as well as utilize the benefits of .ebextension?

yasgur99
  • 756
  • 2
  • 11
  • 32

5 Answers5

3

Does this work if you use the eb deploy command directly? If yes, then I would try using the pipeline execution history to find a recent artifact to download and test with the eb deploy command.

Aaron
  • 1,575
  • 10
  • 18
2

If CodePipeline's Elastic Beanstalk Job Worker does not play well with ebextensions, I would consider it completely useless to deploy to Elastic Beanstalk.

I believe there is some problem with the ebextensions themselves. You can investigate the execution in these log files to see if something is going wrong during deployment:

  • /var/log/eb-activity.log
  • /var/log/eb-commandprocessor.log
  • /var/log/eb-version-deployment.log
shariqmaws
  • 8,152
  • 1
  • 16
  • 35
1

All the config files under .ebextension will be executed based on the order of precedence while deploying on the Elastic Beanstalk. So, it is doesn't matter whether you are using codepipeline or eb deploy, all the file in ebextension directory will be executed. So, you don't have to worry about that.

Mounick
  • 171
  • 5
  • its working with eb deploy, but doesn't seem to be running with code pipeline. any ideas on why this discrepancy? – yasgur99 Oct 23 '19 at 19:11
1

Be careful about the platform you're using, since “64bit Amazon Linux 2 v5.0.2" instead of .ebextension you have to use .platform.

  1. Create .platform directory instead of .ebextension

  2. Create the subfolders and the proxy.conf file like in this path .platform/nginx/conf.d/proxy.conf

  3. In proxy.conf write what you need, in case of req body size just client_max_body_size 20M;

Hoppo
  • 1,130
  • 1
  • 13
  • 32
0

I resolved the problem. You need include .ebextension folder in your deploy. I only copy the dist files, then I need include too: - .ebextensions/**/*

Example:

## Required mapping. Represents the buildspec version. We recommend that you use 0.2.
version: 0.2

phases:
  ## install: install dependencies you may need for your build
  install:
    runtime-versions:
      nodejs: 12
    commands:
      - echo Installing Nest...
      - npm install -g @nestjs/cli
  ## pre_build: final commands to execute before build
  pre_build:
    commands:
      - echo Installing source NPM dependencies...
      - npm install
  ## build: actual build commands
  build:
    commands:
      # Build your app
      - echo Build started on `date`
      - echo Compiling the Node.js code
      - npm run build
      ## Clean up node_modules to keep only production dependencies
      # - npm prune --production

  ## post_build: finishing touches
  post_build:
    commands:
      - echo Build completed on `date`
# Include only the files required for your application to run.
artifacts:
  files:
    - dist/**/*
    - package.json
    - node_modules/**/*
    - .ebextensions/**/*

Ande the config file /.ebextensions/.node-settings.config:

option_settings:
  aws:elasticbeanstalk:container:nodejs:
    NodeCommand: "npm run start:prod"
Sergio
  • 441
  • 9
  • 22