This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################ | |
# Instance info | |
############################################ | |
INSTANCE_ID=$(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
EC2_AVAIL_ZONE=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone` | |
REGION="`echo \"$EC2_AVAIL_ZONE\" | /bin/sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`" | |
ENI_ID="${ENI_ID}" # have terraform or whatever you're using provide this | |
ENI_IP=$(/usr/bin/aws ec2 describe-network-interfaces --region=${REGION} | \ | |
/usr/bin/jq -cr --arg i "${ENI_ID}" '.NetworkInterfaces[]|select(.NetworkInterfaceId==$i).PrivateIpAddress') | |
NETCIDR="${ENI_IP%.*}.0/24" # yeah, it's defaults for my network, put in whatever it is for you |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Demonstrate Bash | |
[Service] | |
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment MYVAR=$(( 2 + 2 ))" | |
ExecStart=/usr/bin/echo "2 + 2 = ${MYVAR}" |