Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Send EC2 launch notification to Slack webhook complete with connection command
# This functionality uses
# Replace the 3 hashes in the next line with those from your webhook
slack(){ curl -d 'payload={"text": "'"$@"'"}'; }
msg_string='Instance \\"hack\\" came online. To connect:\n`%s`\nor:\n`%s`\n'
key="$(curl -s | awk -F '=' 'NR=1{print $2}')"
user="$(id -nu 1000)"
con_string="ssh -i ~/.ssh/$key.pem $user@%s"
private_host="$(hostname -f)"
public_host="$(curl -s"
slack "$(printf "$msg_string" "$(printf "$con_string" "$private_host")" "$(printf "$con_string" "$public_host")")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.