Skip to content

Instantly share code, notes, and snippets.

@statik
Created July 21, 2020 19:43
Show Gist options
  • Save statik/bffe1b97beaf2ffc45ea1cdf449bd8e0 to your computer and use it in GitHub Desktop.
Save statik/bffe1b97beaf2ffc45ea1cdf449bd8e0 to your computer and use it in GitHub Desktop.
setting up ssm access to ec2 instance

Make sure the user roles that need to access the instance have ssm:StartSession and ssm:TerminateSession permissions granted.

#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
apt update
# Install cfn tools
apt install -y python-pip
apt install -y python-setuptools
cd /tmp/ || return
wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
pip install aws-cfn-bootstrap-latest.tar.gz
# Install ssm
mkdir /tmp/ssm
cd /tmp/ssm || return
wget https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb
sudo dpkg -i amazon-ssm-agent.deb
sudo systemctl enable amazon-ssm-agent
sudo systemctl start amazon-ssm-agent
/usr/local/bin/cfn-signal -e $? --resource kindlyInstance \
--stack ${AWS::StackName} \
--region ${AWS::Region}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment