This repo contains templates for building/deploying an EB application.
- app/.ebextensions/
- app/.elasticbeanstalk/
- app/sample_service/
- app/.dockerignore
- app/.ebignore
- app/.gitignore
- app/Dockerfile
- aws/cloudformation/EB-CloudWatchPolicy.template
- aws/cloudformation/EB-IAM-Deploy.template
- aws/cloudformation/S3-Configs.template
- aws/cloudformation/S3-RootLogs.template
- deploy/eb_deployment_helper.sh
- deploy/requirements-deploy.txt
- deploy/setup_aws_profile.py
Only need to do it once
$ pip install awsebcli six
# Change to the source directory
$ cd app
$ eb init --profile ${AWS_PROFILE}
# - Region: sydney
# - Application name: SampleService
# - Platform version: Docker 17.03.1-ce (or latest)
# - ssh key: my-sampleservice-key
$ eb create SampleService-dev --cname sampleservice-dev --vpc
# See also http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-getting-started.html
# - Environment Name: SampleService-dev
# - DNS CNAME prefix: sampleservice-dev
# - Load balancer type: application
See also EB CLI Reference: eb config
.
-
To build and test the Docker image for the application. You need to install
docker
if you want to run it locally:$ cd deploy $ ./eb_deployment_helper.sh --build-image
-
To also deploy the application and update settings/configurations within EC2 instances:
$ cd deploy $ ./eb_deployment_helper.sh --build-image \ [--push-image] \ --eb-deploy --eb-env [EB_ENV_NAME]
-
To update Elastic Beanstalk Environment for instant change in After Creation state:
-
Make sure you have the latest EB environment first. Because
aws:elasticbeanstalk:managedactions:platformupdate
is enabled, the Docker/platform version inPlatform:PlatformArn
can be different from the last saved*.cfg.yml
file.$ cd app/ $ eb use [EB_ENV_NAME] # Ensure all operations take effect to a specific EB environment $ eb config delete [EB_ENV_NAME] # Delete the named saved configuration (in EB S3) $ eb config save [EB_ENV_NAME] # Save the environment configuration settings for the current running # environment to .elasticbeanstalk/saved_configs/ with the filename # [EB_ENV_NAME].cfg.yml.
-
Edit
app/.elasticbeanstalk/saved_configs/[EB_ENV_NAME].cfg.yml
. -
Create Pull Request for review.
-
Apply the change
$ cd deploy $ ./eb_deployment_helper.sh --eb-config-update --eb-env [EB_ENV_NAME]
-
eb ssh [EB_ENV_NAME] --profile [profile-name]
eb logs --all
-
opt/elasticbeanstalk/hooks/appdeploy/pre/
00clean_dir.sh
- Clean directory where source will be downloaded, removes docker containers and images.01unzip.sh
- Download source from S3 and unzip it.02loopback-check.sh
- Verify you don't have docker loopback setting set.03build.sh
- Build your docker image from yourDockerfile
orDockerrun.aws.json
.
-
/opt/elasticbeanstalk/hooks/appdeploy/enact/
00run.sh
- Executedocker run
against the image that was generated in the pre stage based on environment variables and settings in yourDockerrun.aws.json
.01flip.sh
- Convert from aws-staging to current-app etc.
-
/opt/elasticbeanstalk/hooks/appdeploy/post/
See also
- elastic-beanstalk docker app not updating upon deploy
- Elastic Beanstalk: Under the Hood
- Elastic Beanstalk: Under the Hood 2โ - Nginx
- /var/log/eb-activity.log
- /var/log/eb-commandprocessor.log
- /var/log/eb-docker/containers/eb-current-app/stdouterr.log
- /var/log/docker
- /var/log/docker-events.log
- /var/log/nginx/access.log
- /var/log/nginx/error.log
- /opt/elasticbeanstalk/tasks/taillogs.d/
- /opt/elasticbeanstalk/tasks/bundlelogs.d/
- /opt/elasticbeanstalk/tasks/publishlogs.d/
- /opt/python/log/
See also
- https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.cloudwatchlogs.html
- https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html
You can use a certificate stored in IAM with Elastic Load Balancing load balancers and CloudFront distributions.
Otherwise create yours:
- Your profile should have the following permissions
iam:UploadServerCertificate
iam:ListServerCertificates
CALL aws iam upload-server-certificate ^
--server-certificate-name elastic-beanstalk-x509 ^
--certificate-body file://example.com.crt ^
--private-key file://example.com.key ^
--certificate-chain file://intermediate.crt ^
--profile k-eb-deploy
:: Show all certificates
CALL aws iam list-server-certificates --profile k-eb-deploy
For details see Update a certificate to IAM.
If no .ebignore is present, but a .gitignore is, the EB CLI will ignore files specified in the .gitignore. If an .ebignore file is present, the EB CLI will not read the .gitignore.
For details see EB .ebignore.