26

Knowing that eb deploy will deploy anything in your git repo, what is the best way to include files in that are included in .gitignore? I.e. config scripts with credentials etc.

Thanks in advance!

Manuel
  • 14,274
  • 6
  • 57
  • 130
pete
  • 1,023
  • 1
  • 10
  • 15

1 Answers1

42

The answer is creating an .ebignore file. Here is how it works:

If you have my_keys.php in your .gitignore because you don't want to commit it because of sensitive info, create an .ebignore file and only add files that you don't want to be distributed to your instances.

If you don't add my_keys.php to your .ebignore, it will compile it and distribute while .gitignore will keep it out of your remote repo.

This behavior is explained in AWS docs:

If .ebignore isn't present, but .gitignore is, the EB CLI ignores files specified in .gitignore. If .ebignore is present, the EB CLI doesn't read .gitignore.

Manuel
  • 14,274
  • 6
  • 57
  • 130
pete
  • 1,023
  • 1
  • 10
  • 15
  • Does this mean that if a file is not in the .ebignore it will be pushed to the elastic beanstalk instance even if it is in the .gitignore? – Michael Jun 20 '17 at 17:05
  • 15
    And I quote (from AWS), "If no .ebignore is present, but a .gitignore is, the EB CLI will ignore files specified in the .gitignore. If an .ebignore file is present, the EB CLI will not read the .gitignore." (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html#eb-cli3-ebignore) – Ryan Sep 23 '17 at 23:01
  • @Ryan comment should be added to that response as is. – KeitelDOG Sep 06 '19 at 00:30