is the order code deploy?

17
Is the order CodeDeploy? Yoichi TOYOTA (@rs_wisteria) Xtone Ltd.

Upload: yoichi-toyota

Post on 14-Apr-2017

297 views

Category:

Technology


0 download

TRANSCRIPT

Isthe order

CodeDeploy?Yoichi TOYOTA (@rs_wisteria)

Xtone Ltd.

agenda● What is AWS CodeDeploy?● CodeDeploy example

○ rails application

What is AWS CodeDeploy● Automates code deployment to…

○ EC2 Instances○ Instances running on-premises

● A File and Command-line based deployment○ deploy any applicaton○ reuse existing setup code

● and more issue○ Healthcheck after deployment○ rolling update○ rollback

● https://aws.amazon.com/codedeploy/

example: rails application● Deploy ruby on rails application from github

○ EC2 (Amazon linux)○ Auto Scaling

example: rails application (cont.)● Configure appspec.yml in Application● Configure IAM Role

○ for CodeDeploy○ for AutoScale

● Configure AutoScale Settings○ create AMI

■ install rails prerequisite■ install CodeDeploy Agent

○ create AutoScale group

● Create CodeDeploy Application○ application○ deploy group (for production, staging, etc.)

● Create deploy○ configure github repository and revision

Configure appspec.yml in Application● files

○ source-destination file mappings

● permissions○ permission specification

● hooks○ deployment lifecycle event mappings

■ ApplicationStop■ BeforeInstall■ AfterInstall■ ApplicationStart■ ValidateService

version: 0.0os: linuxfiles: - source: / destination: /var/www/codedeploy-testpermissions: - object: /var/www/codedeploy-test/logs pattern: '**' mode: 775 - object: /var/www/codedeploy-test/tmp pattern: '**' mode: 775hooks: AfterInstall: - location: bin/bundle-install.sh timeout: 300 runas: root

Create IAM Role● for CodeDeploy

○ Attach “CodeDeployRole” policy○ Trust ‘ec2.amazonaws.com’ and ‘codedeploy.amazonaws.com’

● for AutoScale○ Attach custom policy allows ‘s3::Get’ and ‘s3::List’○ Trust ‘ec2.amazonaws.com’

Configure AutoScale Settings● Create AMI

○ install rails prerequisites○ install CodeDeploy Agent

● Create AutoScale Launch Configuration○ select AMI○ select Instance Type○ configure IAM Role for EC2 instance under AutoScale○ other configurations for EC2 instance (security group, storage, etc.)

● Create AutoScale Group○ select launch configuration○ configure instance count○ configure network○ configure scaling policy

Create CodeDeploy application● configure deploy target

○ Amazon EC2○ Auto Scaling Group○ On-premises Instance

Create CodeDeploy application (cont.)● Configure deploy settings

○ OneAtTime○ HalfAtTime○ AllAtTime

● Configure IAM Role for CodeDeploy

Create Deploy● select application and deploy group● configure source repository

○ github○ S3

● select deploy settings● and do deployment!

Deployment Completed!● Gotcha!

Deploy on commit● Create IAM user for github

○ allows CodeDeploy operations

● Configure github service○ CodeDeploy Service○ Github Auto-Deployment

Configure CodeDeploy Service on Github● Project -> ‘Webhooks & services’

○ ‘AddService’ -> ‘AWS CodeDeploy’

● Configure below○ CodeDeploy Application name○ CodeDeploy deploy group○ access key○ secret access key○ region

Configure Github Auto-Deployment● Project -> ‘Webhooks & services’

○ ‘AddService’ -> ‘Github Auto-Deployment’

● Github token for deployment● Deploy group as Environments

Done!● Create deploy automatically!

And more● We can deploy...

○ any application■ php, nodejs, python, etc.

○ to On-premises Instances■ independent of AWS EC2

○ from S3■ independent of github