A note that deployed a Python application from Circle CI to Elastic Beanstalk and notified Slack

Preparation

Register with Circle CI as a repository

When you sign up for Circle CI, some repositories are displayed, so select it. Select to run the build.

Set AWS access key

Select the registered repository from BUILDS and select Project Settings in the upper right. Go to PERMISSIONS → AWS Permissions and register your Access Key ID and Secret Access Key ID. This is internally written to ~ / .aws / config and ~ / .aws / credentials at build time. The profile name will be [default], so be careful if you have already edited the .config file under the .elasticbeanstalk directory with a different profile name.

Set up Slack

Get the WebHook URL and go to Circle CI. Check with Test Hook.

Add and edit circle.yml

Maybe I had to put it directly under the repository root directory.

Specify a directory

Not required if the source code is in the root directory of the repository.

general:
  build_dir: src

machine specification

According to the Python3 environment that can be created with Elastic Beanstalk now, as follows.

machine:
  python:
    version: 3.4.3

Setting to put awsebcli

Dependent libraries are also included here.

dependencies:
  pre:
    - pip install -r requirements.txt
    - pip install awsebcli

When you want to run a test at the same time

As below

test:
  override:
    - python test.py

Settings to deploy

The branch name and the environment name on Elastic Beanstalk.

deployment:
  staging:
    branch: develop
    commands:
      - eb deploy eb-environment-name

Add and edit Elastic Beanstalk configuration file

Add .elasticbeanstalk / config.yml to the deploy directory (src this time). Edit as follows. As mentioned above, the profile name is default.

branch-defaults:
  default:
    environment: eb-environment-name
global:
  application_name: eb-app-name
  default_ec2_keyname: null
  default_platform: 64bit Amazon Linux 2016.03 v2.1.0 running Python 3.4
  default_region: ap-northeast-1
  profile: default
  sc: null

If you have already set the profile name other than default

You can overwrite ~ / .aws / credentials with pre in circle.yml. At first, I wrote it out by myself without noticing that ~ / .aws / credentials was written out on the Circle CI side, so this method should be okay.

Try to deploy

Push circle.yml and .elasticbeanstalk / config.yml. It should be deployed after a while.

Recommended Posts

A note that deployed a Python application from Circle CI to Elastic Beanstalk and notified Slack
Send a message from Python to Slack
[AWS] Flask application deployment version that tried to build a Python environment with eb [Elastic Beanstalk]
[AWS] Flask application deployment preparation edition that tried to build a Python environment with eb [Elastic Beanstalk]
Send a message from Slack to a Python server
A python client application that downloads and deletes files from S3 by specifying a bucket
[AWS] Development environment version that tried to build a Python environment with eb [Elastic Beanstalk]
Post from Python to Slack
How to write a metaclass that supports both python2 and python3
A story about everything from data collection to AI development and Web application release in Python (3. AI development)
Post a message from IBM Cloud Functions to Slack in Python
A quick guide to PyFlink that combines Apache Flink and Python
[python] A note that started to understand the behavior of matplotlib.pyplot
I made a web application in Python that converts Markdown to HTML
Migration from Python2 to Python3 (Python2 is rebuilt as a virtual environment and coexists)
(Note) A web application that uses TensorFlow to infer recommended song names.
Connect to postgreSQL from Python and use stored procedures in a loop.
I want to make a web application using React and Python flask
From Python to using MeCab (and CaboCha)
Porting and modifying doublet-solver from python2 to python3.
Note that cibuildwheel builds python bwheel (including C ++ module) in bulk with CI and uploads it to PyPI
[ES Lab] I tried to develop a WEB application with Python and Flask ②
I want to exe and distribute a program that resizes images Python3 + pyinstaller
WEB scraping with python and try to make a word cloud from reviews
C language to see and remember Part 3 Call C language from Python (argument) c = a + b
Create a setting in terraform to send a message from AWS Lambda Python3.8 to Slack
Run a Python script from a C # GUI application
How to open a web browser from python
Image characters and post to slack (python slackbot)
A nice nimporter that connects nim and python
[Python] How to read data from CIFAR-10 and CIFAR-100
How to generate a Python object from JSON
Steps to develop a web application in Python
[Introduction to Udemy Python3 + Application] 64. Namespace and Scope
Python Note: When assigning a value to a string
"Python Kit" that calls a Python script from Swift
[Python] Throw a message to the slack channel
A Python script that crawls RSS in Azure Status and posts it to Hipchat
A program that asks for a few kilograms to reach BMI and standard weight [Python]
(Note) A web application that uses TensorFlow to infer recommended song names [Machine learning]
Use slackbot as a relay and return from bottle to slack in json format.
A note that runs an external program in Python and parses the resulting line
A mechanism to call a Ruby method from Python that can be done in 200 lines