Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29250

Can we gather instance metadata within AWS::CloudFormation::Init

$
0
0

When configuring the AWS cloudwatch agent, you can include in the {instance_id} inside awslogs.conf

[/var/log/cfn-hup.log]file = /var/log/cfn-hup.loglog_group_name = my-log-grouplog_stream_name = {instance_id}/cfn-hup

Is there a way to do this within AWS::CloudFormation::Init?

Specifically I'm looking to add my Instance ID with the files section

Resources:   MyLaunchConfig:    Type: AWS::AutoScaling::LaunchConfiguration    Metadata:       AWS::CloudFormation::Init:         config:          files:             /opt/someconfig.conf:               content: |                INSTANCE_ID={instance_id}              mode: "000644"              owner: "root"              group: "root"

My work around was to append the INSTANCE_ID to my config file after the cfn-init command by running:

echo "INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)">> /opt/someconfig.conf

Is there a better way to do this?


Viewing all articles
Browse latest Browse all 29250

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>