Skip to content

Instantly share code, notes, and snippets.

@miztiik
Last active October 11, 2024 16:44
Show Gist options
  • Select an option

  • Save miztiik/e9535944e9e8edcafa69da991b90738c to your computer and use it in GitHub Desktop.

Select an option

Save miztiik/e9535944e9e8edcafa69da991b90738c to your computer and use it in GitHub Desktop.

AWS Systems Manager lets you remotely and securely manage the configuration of your managed instances. It helps you automate management tasks.

  • Create IAM Role - Assign Permissions
  • Create EC2 & Assign IAM Role - "AmazonEC2RoleforSSM" role to an Amazon EC2 instance with "AmazonSSMFullAccess" Permissions
  • Bootstrap with SSM
  • Run Command

User-Data:

#!/bin/bash
cd /tmp
sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
yum install -y amazon-ssm-agent.rpm
sudo systemctl start amazon-ssm-agent
sudo systemctl enable amazon-ssm-agent

Run Commands:

#/bin/bash

echo -e "{
 'Hostname':'`curl http://169.254.169.254/latest/meta-data/local-hostname --silent`', \
\n 'AMI-ID':'`curl http://169.254.169.254/latest/meta-data/ami-id --silent`', \
\n 'Kernel-Version':'`rpm -q kernel`' \
\n 'Instance Type':'`curl http://169.254.169.254/latest/meta-data/instance-type --silent`'
 }"
@jayantm
Copy link

jayantm commented Aug 28, 2018

Can we run this from Lambda? I tried but it times out and never executes

@miztiik
Copy link
Author

miztiik commented Dec 10, 2018

This is instance metadata, What is are you trying to achieve by running this under lambda environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment