user3216217
user3216217

Reputation: 21

Pointing amazon AWS Elastic Beanstalk to existing EC2

Was wondering if someone can help with below amazon AWS question, seems a basic item but can't find any answers, getting very frustrated.

1) I have an EC2 instance running that has a third party process running in the background, and when called from command line it spits out a number.

2) I have a java web app that runs this command line and uses the output for the web gui etc..

But for the life of me, i cannot figure out how to deploy my java web app on the SAME existing EC2 that's running the process, every time i try to create an elastic beanstalk it creates a new EC2 instance.

How do i make the elastic beanstalk to run off the same existing EC2 i already have? I understand there are other workaround to pass the data remotely but this seems a fundamental requirement that is missing from AWS - that you cannot run your web app with backend/batch processes on the same EC2 instance?

Thank you

Upvotes: 2

Views: 1678

Answers (2)

kukido
kukido

Reputation: 10601

You can use custom AMI with Elastic Beanstalk.

AWS documentation has a guide on how to create and use a customized AMI: Using Custom AMIs

But then again, nobody's stopping you from running your background processes on the standard Elastic Beanstalk instance. I run background cron jobs and Flask application on one Elastic Beanstalk instance.

files:
    "/tmp/cronjob-for-foobar" :
        mode: "000777"
        owner: ec2-user
        group: ec2-user
        content: |
            # skip
            # clean up files created by above cronjob
            30 23 * * * rm $HOME/cron*.log

container_commands:
    70-foobar-cronjobs:
        command: crontab /tmp/cronjob-for-foobar

Obviously, you can have anything scheduled in cron, as long as you stay within your instance limits.

Upvotes: 1

Rico
Rico

Reputation: 61551

Elastic Beanstalk is basically a higher abstraction layer on EC2 and it's tightly coupled with it. That means at a minimum every time you deploy your application it will spin up an EC2 server.

The advantage is that you don't need to manage your EC2 instances, for example it will autoscale automatically depending on your traffic demand.

The disadvantage is that it theoretically doesn't allow you to tweak little things in the EC2 instance because you may mess up how the Elastic Beanstalk interprets your app. Also, I believe you cannot force your Elastic Beanstalk deployment to use a specific AMI.

If you want more flexibility in your app (which sounds like your do) I recommend do your own deployment for your application (No Elastic Beanstalk). That way you can run the your app and your jobs on the same EC2 Instance.

Upvotes: 1

Related Questions