Skip to content

Instantly share code, notes, and snippets.

View mda590's full-sized avatar
☁️
Feeling cloudy

Matt Adorjan mda590

☁️
Feeling cloudy
View GitHub Profile
@mda590
mda590 / ssm-secrets-03.sh
Created March 22, 2017 12:40
Create Secure String in EC2 Parameter Store - Example Value
{ "AccessKey": "ABCDE43235132D", "SecretKey": "ACBDEFGHIJKL123456789ABCDEF" }
@mda590
mda590 / ssm-secrets-02.sh
Created March 22, 2017 12:39
Create Secure String in EC2 Parameter Store - Example
aws --region=us-east-2 ssm put-parameter --name "secret-password" --value 'password1234' --type SecureString --key-id alias/secret-strings
@mda590
mda590 / ssm-secrets-01.sh
Created March 22, 2017 12:38
Create Secure String in EC2 Parameter Store
aws --region=us-east-2 ssm put-parameter --name "<string-name>" --value '<secure data>' --type SecureString --key-id alias/<kms-key-name>
@mda590
mda590 / gist:9404128f5157f38098189616a56070f6
Created March 20, 2017 22:33
Install Docker on RHEL AWS
sudo yum-config-manager --enable "Red Hat Enterprise Linux Server 7 Extra(RPMs)"
sudo yum install docker -y
@mda590
mda590 / ec2-schedule-example.py
Created February 7, 2017 19:39
Example EC2 Scheduler Script based on a tag value
import boto3
from datetime import datetime, timedelta
def lambda_handler(event, context):
try:
# Create connection to the EC2 using Boto3 resources interface
ec2 = boto3.resource('ec2', region_name='us-east-1')
# Get the current time
timeOffset = datetime.utcnow() + timedelta(hours=defaultTimeZone)
@mda590
mda590 / boto3_get-ssm-parameter.py
Last active July 7, 2022 12:23
Get a Secure String parameter stored in the EC2 Systems Manager
def getParameter(param_name):
"""
This function reads a secure parameter from AWS' SSM service.
The request must be passed a valid parameter name, as well as
temporary credentials which can be used to access the parameter.
The parameter's value is returned.
"""
# Create the SSM Client
@mda590
mda590 / boto3_listinstances_example.py
Last active May 29, 2024 09:08
Example using boto3 to list running EC2 instances
import boto3
ec2 = boto3.resource('ec2')
def lambda_handler(event, context):
# create filter for instances in running state
filters = [
{
'Name': 'instance-state-name',
'Values': ['running']