Skip to content

Commit

Permalink
Merge pull request #23 from iriusrisk/DE-174
Browse files Browse the repository at this point in the history
DE-174: Check if instance is IMSDv1 or IMSDv2 to get ec2 metadata
  • Loading branch information
adrian-iriusrisk authored Jun 16, 2023
2 parents 4da9317 + 53ace8c commit 0b99069
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {
}

group 'com.continuumsecurity.elasticagent'
version '2.2.1'
version '2.2.2'

// these values that go into plugin.xml
project.ext.pluginDesc = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,18 @@ public static Ec2Instance create(CreateAgentRequest request, PluginSettings sett
"echo \"wrapper.app.parameter.103=NONE\" >> /usr/share/go-agent/wrapper-config/wrapper-properties.conf\n" +
"mkdir -p /var/lib/go-agent/config\n" +
"echo \"agent.auto.register.key=" + request.autoRegisterKey() + "\" > /var/lib/go-agent/config/autoregister.properties\n" +
"echo \"agent.auto.register.hostname=EA_$(curl http://169.254.169.254/latest/meta-data/instance-id)\" >> /var/lib/go-agent/config/autoregister.properties\n" +
"echo \"agent.auto.register.elasticAgent.agentId=$(curl http://169.254.169.254/latest/meta-data/instance-id)\" >> /var/lib/go-agent/config/autoregister.properties\n" +

"HTTP_CODE=`curl -I http://169.254.169.254 | head -n 1 | cut -d$' ' -f2`\n" +
"if [[ HTTP_CODE -eq 200 ]];\n" +
"then\n" +
"INSTANCE_ID=`curl http://169.254.169.254/latest/meta-data/instance-id`\n" +
"else\n" +
"TOKEN=`curl -X PUT 'http://169.254.169.254/latest/api/token' -H 'X-aws-ec2-metadata-token-ttl-seconds: 21600'`\n" +
"INSTANCE_ID=`curl -H \"X-aws-ec2-metadata-token: $TOKEN\" http://169.254.169.254/latest/meta-data/instance-id`\n" +
"fi\n" +

"echo \"agent.auto.register.hostname=EA_$INSTANCE_ID\" >> /var/lib/go-agent/config/autoregister.properties\n" +
"echo \"agent.auto.register.elasticAgent.agentId=$INSTANCE_ID\" >> /var/lib/go-agent/config/autoregister.properties\n" +
"echo \"agent.auto.register.elasticAgent.pluginId=" + Constants.PLUGIN_ID + "\" >> /var/lib/go-agent/config/autoregister.properties\n" +
"chown -R go:go /var/log/go-agent/\n" +
"chown -R go:go /var/lib/go-agent/\n" +
Expand Down

0 comments on commit 0b99069

Please sign in to comment.