AWS CodeDeploy + Github

Preview:

Citation preview

AWS CodeDeploy + GitHub

2016-03-21차현진 (gump.cha@gmail.com)

Demo

https://github.com/gumpcha/aws-codedeploy-demo

Github -> CodeDeploy -> Auto Scaling / Load Balancer

Deploy trigger - git push

Deployment Types

1.In-place deployment2.Blue/green deployment

In-place lifecycle event

Blue/green lifecycle event

appspec.ymlversion: 0.0os: linuxfiles: - source: /index.html destination: /var/www/html/hooks: ApplicationStop: - location: scripts/stop_server timeout: 300 runas: root BeforeInstall: - location: scripts/install_dependencies timeout: 300 runas: root - location: scripts/start_server timeout: 300 runas: root

#!/bin/bashyum install -y httpd

#!/bin/bashservice httpd start

#!/bin/bashisExistApp=`pgrep httpd`if [[ -n $isExistApp ]]; then service httpd stopfi

Setup - Manual- Application- Deployment group

- staging/production/…- Auto Scaling group- Load balancer- Service role

- AWSCodeDeployRole- Trust Relationships

- Key pair name- AMI

- IAM instance profile: AmazonEC2RoleforAWSCodeDeploy

- install codedeploy-agent

Setup - Deployment Wizard

Github 연동 (1/4)

1. AWS CodeDeploy 에 deployment group 까지 미리 생성2. github 에서 CodeDeploy 에 접근할 수 있는 IAM User 생성

1. AWSCodeDeployDeployerAccess Policy

Github 연동 (2/4)“AWS CodeDeploy” Service 추가 (1/2)

Github 연동 (2/4)“AWS CodeDeploy” Service 추가 (2/2)

Github 연동 (3/4)github 계정 설정에서 Github Personal Access Token 생성

Github 연동 (4/4)“GitHub Auto-Deployment” Service 추가 (1/2)

Github 연동 (4/4)“GitHub Auto-Deployment” Service 추가 (2/2)

Recommended