Skip to content

Instantly share code, notes, and snippets.

@davecap
Created April 24, 2014 02:20
Show Gist options
  • Save davecap/11239288 to your computer and use it in GitHub Desktop.
Save davecap/11239288 to your computer and use it in GitHub Desktop.
.ebextensions/99datadog.config
# .ebextensions/99datadog.config
container_commands:
01chmod:
command: "chmod +x .ebextensions/datadog/hooks/*"
02mkdir_appdeploy_post:
test: '[ ! -d /opt/elasticbeanstalk/hooks/appdeploy/post ]'
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
02mkdir_configdeploy_post:
test: '[ ! -d /opt/elasticbeanstalk/hooks/configdeploy/post ]'
command: "mkdir /opt/elasticbeanstalk/hooks/configdeploy/post"
10appdeploy_pre_stop:
command: "cp .ebextensions/datadog/hooks/99stop_datadog.sh /opt/elasticbeanstalk/hooks/appdeploy/pre/"
11appdeploy_post_start:
command: "cp .ebextensions/datadog/hooks/99start_datadog.sh /opt/elasticbeanstalk/hooks/appdeploy/post/"
20preinit_stop:
command: "cp .ebextensions/datadog/hooks/99stop_datadog.sh /opt/elasticbeanstalk/hooks/preinit"
21postinit_start:
command: "cp .ebextensions/datadog/hooks/99start_datadog.sh /opt/elasticbeanstalk/hooks/postinit"
30configdeploy_pre_stop:
command: "cp .ebextensions/datadog/hooks/99stop_datadog.sh /opt/elasticbeanstalk/hooks/configdeploy/pre/"
31configdeploy_post_start:
command: "cp .ebextensions/datadog/hooks/99start_datadog.sh /opt/elasticbeanstalk/hooks/configdeploy/post/"
90install_datadog:
command: "cp .ebextensions/datadog/datadog.repo /etc/yum.repos.d/datadog.repo; yum -y makecache; yum -y install datadog-agent; /etc/init.d/datadog-agent stop"
91setup_datadog:
test: '[ ! -e /etc/dd-agent/datadog.conf ]'
command: "sh -c \"sed 's/api_key:.*/api_key: YOUR_API_KEY/' /etc/dd-agent/datadog.conf.example > /etc/dd-agent/datadog.conf\""
@jniesen
Copy link

jniesen commented Aug 6, 2014

Is there a reason for the 99? Just curious.

@jniesen
Copy link

jniesen commented Aug 7, 2014

Nevermind. I found that EB will run the commands in ebextensions based on aplhabetical order.

"You can have multiple configuration files in your .ebextensions directory. These files are executed in alphabetical order." --AWS DOCS

@Korzun
Copy link

Korzun commented Mar 5, 2015

Have you updated this script for the new EC2 Instance version. The one I'm battling changes to the EB deploy hooks under the "64bit Amazon Linux 2014.09 v1.2.0 running PHP 5.5" environment.

@molinto
Copy link

molinto commented Jun 24, 2016

Thanks for this.
Do I actually put in the YOUR_API_KEY in this file please?

Thanks

@ayush
Copy link

ayush commented Oct 14, 2016

Wow, it's 2016 and your post still works exactly as described. Thanks!

@lukas-gitl
Copy link

lukas-gitl commented Jan 26, 2017

This works pretty well! I changed the last section to

        91setup_datadog:
            command: "sh -c \"sed 's/api_key:.*/api_key: {{DATADOG_API_KEY}}/; s/\\# tags:.*/tags: {{ENVIRONMENT}}/' /etc/dd-agent/datadog.conf.example > /etc/dd-agent/datadog.conf\""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment