-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_to_beanstalk.py
36 lines (27 loc) · 1.12 KB
/
deploy_to_beanstalk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import celery
import ConfigParser
import os
from boto.beanstalk.beanstalk import Beanstalk
settings = ConfigParser.ConfigParser()
with open(os.sep.join((os.getcwd(), 'development.ini')), 'r') as config_file:
settings.readfp(config_file)
AWS_ACCESS_KEY = settings.get('app:main', 'deployer.aws_access_key')
AWS_SECRET_KEY = settings.get('app:main', 'deployer.aws_secret_key')
@celery.task
def create_application_version(key_name, bucket_name, application_name, version_label):
b = Beanstalk(aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY)
res = b.create_application_version(
application_name = application_name,
version_label = version_label,
s3_bucket = bucket_name,
s3_key = key_name
)
return res.application_version.version_label
@celery.task
def update_environment(version_label, environment_name):
b = Beanstalk(aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY)
res = b.update_environment(
environment_name = environment_name,
version_label = version_label
)
return res