Skip to content

AWS Snippets

Invalidate a cloudfront distribution

aws cloudfront create-invalidation --paths "/pages/about" --distribution-id my-distribution-id

Get EC2 metadata from within the instance

The quickest way to fetch or retrieve EC2 instance metadata from within a running EC2 instance is to log in and run the command:

Fetch metadata from IPv4:

curl -s

You can also download the ec2-metadata tool to get the info:

# Download the ec2-metadata script

# Modify the permission to execute the bash script
chmod +x ec2-metadata

./ec2-metadata --all

Find if external IP belongs to you

You can list the network interfaces that match the IP you're searching for

aws ec2 describe-network-interfaces --filters Name=association.public-ip,Values="{{ your_ip_address}}"