Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Deploy to AWS with Elastic Beanstalk

Edited

Hi all,

Am trying to get my head around deploying apps into AWS Beanstalk using BitBucket Piplines.

End goal will be deploying some Django apps.

 

Anyways, I have been giving it a go and following the tutorial linked below:

https://support.atlassian.com/bitbucket-cloud/docs/deploy-to-aws-with-elastic-beanstalk/

I am having issues where its failing after deployment saying:

✖ Deployment failed. Environment "Cvsstaging-env" is Red.

And in AWS:

2021-09-11 15:29:53 UTC+0930
WARN
Environment health has transitioned from Degraded to Severe. 100.0 % of the requests are failing with HTTP 5xx. ELB processes are not healthy on all instances. ELB health is failing or not available for all instances. Impaired services on all instances. One or more TargetGroups associated with the environment are in a reduced health state: - awseb-AWSEB-1KNZ27HWP6PPX - Warning
2021-09-11 15:28:53 UTC+0930
WARN

Environment health has transitioned from Severe to Degraded. 100.0 % of the requests are failing with HTTP 5xx. Application update completed 66 seconds ago and took 14 seconds. Impaired services on all instances. One or more TargetGroups associated with the environment are in a reduced health state: - awseb-AWSEB-1KNZ27HWP6PPX - Warning

 

I assumed this was likely due to an issue with my app, so insead of trying to deploy my own app, i decided to just try deploy the app linked in the tutorial itself:
https://bitbucket.org/bitbucketpipelines/example-aws-elasticbeanstalk-deploy/src/master/

But even this repository with the only changes being, changing it to Python 3.8 in the docker file as my Beanstalk is running Python 3.8, and obviously AWS details and credentials, but even this is having the same error.

I feel like im missing something super basic?

3 answers

0 votes

@Bailey Davis @Denis Kisina  hi. After investigation i found that problem is with wrong Elastic Beanstalk configuration. I also have this errors: Deployment failed. Environment "your-env" is Red.

In logs i found the reason: ModuleNotFoundError: No module named 'application'

This two articles helped me a lot:

https://stackoverflow.com/questions/33467817/how-to-debug-elasticbeanstalk-error-x-of-the-requests-are-failing-with-http-5x

https://stackoverflow.com/questions/68365462/modulenotfounderror-no-module-named-application-error-in-aws

 

After this  i tried to do this as  aws tutorial suggests and everything worked correctly.

Folder structure:

Your app

 - application.py
 - requirements.txt
- bitbucket-pipelines.yml

application.py:

from flask import Flask

# print a nice greeting.
def say_hello(username = "World"):
return '<p>Hello %s!</p>\n' % username

# some bits of text for the page.
header_text = '''
<html>\n<head> <title>EB Flask Test</title> </head>\n<body>'''
instructions = '''
<p><em>Hint</em>: This is a RESTful web service! Append a username
to the URL (for example: <code>/Thelonious</code>) to say hello to
someone specific.</p>\n'''
home_link = '<p><a href="/">Back</a></p>\n'
footer_text = '</body>\n</html>'

# EB looks for an 'application' callable by default.
application = Flask(__name__)

# add a rule for the index page.
application.add_url_rule('/', 'index', (lambda: header_text +
say_hello() + instructions + footer_text))

# add a rule when the page is accessed with a name appended to the site
# URL.
application.add_url_rule('/<username>', 'hello', (lambda username:
header_text + say_hello(username) + home_link + footer_text))

# run the app.
if __name__ == "__main__":
# Setting debug to True enables debug output. This line should be
# removed before deploying a production app.
application.debug = True
application.run()

requirements.txt:

click==8.0.3
Flask==1.1.2
itsdangerous==2.0.1
Jinja2==3.0.3
MarkupSafe==2.0.1
Werkzeug==2.0.2

bitbucket-pipelines.yml:

image: atlassian/default-image:2

pipelines:
default:
- step:
name: "Build and Test"
script:
- echo "Everything is awesome!"
- zip application.zip requirements.txt application.py
- pipe: atlassian/aws-elasticbeanstalk-deploy:0.2.3
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
APPLICATION_NAME: 'application-test'
COMMAND: 'upload-only'
ZIP_FILE: 'application.zip'
S3_BUCKET: 'test-elasticbeanstalk'
VERSION_LABEL: 'deploy-$BITBUCKET_BUILD_NUMBER-multiple'
- step:
name: "Deploy to Staging"
deployment: staging
script:
- echo "Deployment!"
- pipe: atlassian/aws-elasticbeanstalk-deploy:0.2.3
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
APPLICATION_NAME: 'application-test'
COMMAND: 'deploy-only'
VERSION_LABEL: 'deploy-$BITBUCKET_BUILD_NUMBER-multiple'
ENVIRONMENT_NAME: 'test-staging2'
WAIT: 'true'

Elastic Beanstalk configuration:

Platform - Python 3.8 running on 64bit Amazon Linux 2

Tier name - WebServer

Screenshot 2021-12-08 at 11.55.04.png

 

Pipelines result:

Screenshot 2021-12-08 at 11.57.32.png

 

Hope this helps. Regards, Igor.

0 votes

@Bailey Davis Did you get a solution to this?

@Denis Kisina Hi.  We will investigate this issue and notify you about the results.

Regards, Igor

Like Denis Kisina likes this
0 votes

@Bailey Davis  Hi. Thanks for your question. Please, add your pipeline configuration and logs to help you.

Regards, Igor. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

210 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you