3

I am working deploying a Laravel application to the AWS ElasticBeanstalk. I configured the CLI and I could deploy the application to an ElasticBeanstalk environment running the command. This is what I have done so far.

I created an ElasticBeanstalk application and an environment in it.

Then I initialised the application for deployment using "eb init" and deployed it using "eb deploy". But I would like to add some additional commands to be run during the deployment. For example, I might run "gulp build" or other commands. Where and how can I figure it? I know that there is an .elasticextension folder but that does not allow us to add custom commands to be run on deployment.

1 Answer 1

3

I know that there is an .elasticextension folder but that does not allow us to add custom commands to be run on deployment.

Not sure what do you mean that you can't run commands in .ebextensions during deployment. But the extensions are commonly used for running commands or scripts when you are deploying your app. There are special sections for that:

  • commands: You can use the commands key to execute commands on the EC2 instance. The commands run before the application and web server are set up and the application version file is extracted.

  • container_commands: You can use the container_commands key to execute commands that affect your application source code. Container commands run after the application and web server have been set up and the application version archive has been extracted, but before the application version is deployed.

There are also platform hooks on Amazon Linux 2 to further fine tune the deployment of your applications.

Finally, if all of them are not suited, you could create dedicated build step in CodePipleline for you application. The dedicated step could be used to create fully deployment version of your application for EB with minimal amount of work to do at EB instances.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi the last option, "The dedicated step could be used to create fully deployment version of your application for EB with minimal amount of work to do at EB instances". Can you please send me a link to build that one? I am struggling to find material online for that one.
@WaiYanHein When you construct your CodePipepline, you can create a build step with CodeBuild. The CodeBuild would produce your deployment package (artifact) that would be passed to Deply action with ElasticBeanstaslk as a provider.
HI @Marcin, thanks for the reply. I have that one already. I integrated the CodeBuild to run the unit tests. My question is "If I compile the assets in the CodeBuild and run the tests, will the assets compiled in the CodeBuild be deployed?". For example, "npm run production"?
@WaiYanHein You can specify in buildspec.yml the artifacts you want to pass over to deployment action to EB. You may still need to use some initialization commands in ebextenastions on EB. The main idea behind using CB, is that bulk of heavy compilation or tests are done before EB, rather then on EB instances.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.