| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,2 +1,2 @@ | |||
| 1 | 1 | name 'codedeploy-agent' | |
| 2 | - recipe 'codedeploy-agent::default', 'Fetches, installs, and starts the AWS CodeDeplot host agent' | ||
| 2 | + recipe 'codedeploy-agent::default', 'Fetches, installs, and starts the AWS CodeDeploy host agent' | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,12 @@ | |||
| 1 | - remote_file "#{Chef::Config[:file_cache_path]}/codedeploy-agent.rpm" do | ||
| 2 | - source "https://s3.amazonaws.com/aws-codedeploy-us-east-1/latest/codedeploy-agent.noarch.rpm" | ||
| 1 | + remote_file "#{Chef::Config[:file_cache_path]}/codedeploy-agent-install" do | ||
| 2 | + source "https://s3.amazonaws.com/aws-codedeploy-us-east-1/latest/install" | ||
| 3 | + mode 0755 | ||
| 3 | 4 | end | |
| 4 | 5 | ||
| 5 | - package "codedeploy-agent" do | ||
| 6 | - action :install | ||
| 7 | - source "#{Chef::Config[:file_cache_path]}/codedeploy-agent.rpm" | ||
| 6 | + bash "install-codedeploy-agent" do | ||
| 7 | + code <<-EOH | ||
| 8 | + #{Chef::Config[:file_cache_path]}/codedeploy-agent-install auto | ||
| 9 | + EOH | ||
| 8 | 10 | end | |
| 9 | 11 | ||
| 10 | 12 | service "codedeploy-agent" do | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,51 @@ | |||
| 1 | + # ALB and ASG lifecycle event scripts | ||
| 2 | + | ||
| 3 | + Often when running a web service, you'll have your instances behind a load balancer. But when | ||
| 4 | + deploying new code to these instances, you don't want the load balancer to continue sending customer | ||
| 5 | + traffic to an instance while the deployment is in progress. Lifecycle event scripts give you the | ||
| 6 | + ability to integrate your AWS CodeDeploy deployments with instances that are behind an ALB Target Group or | ||
| 7 | + in an Auto Scaling group. Simply set the name (or names) of the ALB Target Groups your instances are | ||
| 8 | + a part of, set the scripts in the appropriate lifecycle events, and the scripts will take care of | ||
| 9 | + deregistering the instance, waiting for connection draining, and re-registering after the deployment | ||
| 10 | + finishes. | ||
| 11 | + | ||
| 12 | + ## Requirements | ||
| 13 | + | ||
| 14 | + The register and deregister scripts have a couple of dependencies in order to properly interact with | ||
| 15 | + Application Load Balancing and AutoScaling: | ||
| 16 | + | ||
| 17 | + 1. The [AWS CLI](http://aws.amazon.com/cli/). In order to take advantage of | ||
| 18 | + AutoScaling's Standby feature, the CLI must be at least version 1.10.55. If you | ||
| 19 | + have Python and PIP already installed, the CLI can simply be installed with `pip | ||
| 20 | + install awscli`. Otherwise, follow the [installation instructions](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) | ||
| 21 | + in the CLI's user guide. | ||
| 22 | + 1. An instance profile with a policy that allows, at minimum, the following actions: | ||
| 23 | + | ||
| 24 | + ``` | ||
| 25 | + elasticloadbalancing:Describe* | ||
| 26 | + elasticloadbalancing:DeregisterTargets | ||
| 27 | + elasticloadbalancing:RegisterTargets | ||
| 28 | + autoscaling:Describe* | ||
| 29 | + autoscaling:EnterStandby | ||
| 30 | + autoscaling:ExitStandby | ||
| 31 | + autoscaling:UpdateAutoScalingGroup | ||
| 32 | + ``` | ||
| 33 | + | ||
| 34 | + Note: the AWS CodeDeploy Agent requires that an instance profile be attached to all instances that | ||
| 35 | + are to participate in AWS CodeDeploy deployments. For more information on creating an instance | ||
| 36 | + profile for AWS CodeDeploy, see the [Create an IAM Instance Profile for Your Amazon EC2 Instances]() | ||
| 37 | + topic in the documentation. | ||
| 38 | + 1. All instances are assumed to already have the AWS CodeDeploy Agent installed. | ||
| 39 | + | ||
| 40 | + ## Installing the Scripts | ||
| 41 | + | ||
| 42 | + To use these scripts in your own application: | ||
| 43 | + | ||
| 44 | + 1. Install the AWS CLI on all your instances. | ||
| 45 | + 1. Update the policies on the EC2 instance profile to allow the above actions. | ||
| 46 | + 1. Copy the `.sh` files in this directory into your application source. | ||
| 47 | + 1. Edit your application's `appspec.yml` to run `deregister_from_elb.sh` on the ApplicationStop event, | ||
| 48 | + and `register_with_elb.sh` on the ApplicationStart event. | ||
| 49 | + 1. Edit `common_functions.sh` to set `TARGET_LIST` to contain the name(s) of the Target Group your deployment group is a part of. Make sure the entries in TARGET_LIST are separated by space. | ||
| 50 | + 1. Edit `common_functions.sh` to set `PORT` to the port number your application is running at (if it's different from the default port number set in Target Group) | ||
| 51 | + 1. Deploy! | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,12 @@ | |||
| 1 | + version: 0.0 | ||
| 2 | + os: linux | ||
| 3 | + files: | ||
| 4 | + - source: / | ||
| 5 | + destination: /tmp/elb-test | ||
| 6 | + hooks: | ||
| 7 | + ApplicationStop: | ||
| 8 | + - location: deregister_from_elb.sh | ||
| 9 | + - location: stop_httpd.sh | ||
| 10 | + ApplicationStart: | ||
| 11 | + - location: start_httpd.sh | ||
| 12 | + - location: register_with_elb.sh | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments