This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo yum-config-manager --enable "Red Hat Enterprise Linux Server 7 Extra(RPMs)" | |
sudo yum install docker -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws --region=us-east-2 ssm put-parameter --name "<string-name>" --value '<secure data>' --type SecureString --key-id alias/<kms-key-name> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws --region=us-east-2 ssm put-parameter --name "secret-password" --value 'password1234' --type SecureString --key-id alias/secret-strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "AccessKey": "ABCDE43235132D", "SecretKey": "ACBDEFGHIJKL123456789ABCDEF" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws --region=us-east-2 ssm get-parameters --names "<string-name>" --with-decryption |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws --region=us-east-2 ssm get-parameters --names "secret-password" --with-decryption |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Print all S3 buckets and objects | |
# Warning: If you have a lot of S3 objects, this could potentially incur a large cost. | |
# | |
import boto3 | |
client = boto3.client('s3') | |
buckets = client.list_buckets() |
OlderNewer