This file contains hidden or 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
{ | |
"Records": [ | |
{ | |
"EventSource": "aws:sns", | |
"EventVersion": "1.0", | |
"EventSubscriptionArn": "arn:aws:sns:eu-west-1:000000000000:cloudwatch-alarms:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | |
"Sns": { | |
"Type": "Notification", | |
"MessageId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | |
"TopicArn": "arn:aws:sns:eu-west-1:000000000000:cloudwatch-alarms", |
This file contains hidden or 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 sys | |
import boto3 | |
import re | |
def lambda_handler(event, context): | |
cloudformation = boto3.client('cloudformation') | |
stacks = cloudformation.describe_stacks()['Stacks'] | |
for s in stacks: | |
if re.match(REGEX, s['StackName'], flags=0): |
This file contains hidden or 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
#!/usr/bin/env python | |
import boto3 | |
import requests | |
def main(argv): | |
instance_id = requests.get('http://169.254.169.254/latest/meta-data/instance-id').text | |
allocation_id = argv[1] | |
client = boto3.client('ec2') | |
response = client.associate_address(InstanceId=instance_id,AllocationId=allocation_id) |
This file contains hidden or 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
#!/usr/bin/env python | |
import boto3 | |
client = boto3.client('s3') | |
Bucket = 'a-bucket' | |
Prefix = 'a-prefix' # leave blank to delete the entire contents | |
IsTruncated = True | |
MaxKeys = 1000 | |
KeyMarker = None |
This file contains hidden or 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
#!/usr/bin/env python | |
import boto3 | |
client = boto3.client('s3') | |
bucket = 'your-bucket' | |
prefix = 'a-path-in-s3' | |
NextContinuationToken = True | |
while NextContinuationToken: | |
if NextContinuationToken == True: |
This file contains hidden or 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
#!/usr/bin/env python | |
import boto3 | |
client = boto3.client('s3') | |
bucket = 'you-s3-bucket' | |
prefix = 'a-prefix' | |
NextContinuationToken = True | |
while NextContinuationToken: | |
if NextContinuationToken == True: |
This file contains hidden or 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
# https://www.tensorflow.org/versions/r0.10/tutorials/mnist/beginners/index.html#softmax-regressions | |
# download and read in the data automatically: | |
from tensorflow.examples.tutorials.mnist import input_data | |
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) | |
import tensorflow as tf | |
# model for handwritten digit [0-9] | |
# y = softmax(Wx + b) |
This file contains hidden or 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
#!/usr/bin/env python | |
import sys | |
import boto3 | |
def main(argv): | |
autoscaling = boto3.client('autoscaling') | |
auto_scaling_groups = autoscaling.describe_auto_scaling_groups()['AutoScalingGroups'] | |
for asg in auto_scaling_groups: | |
break |
This file contains hidden or 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
{ | |
"Version": "2012-10-17", | |
"Id": "Policy1469359009696", | |
"Statement": [ | |
{ | |
"Sid": "Stmt1469359007124", | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": "s3:*", | |
"Resource": "arn:aws:s3:::<BUCKET_NAME>/*", |
This file contains hidden or 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
#!/usr/bin/env python | |
import sys | |
import boto3 | |
def main(argv): | |
ec2 = boto3.resource('ec2') | |
instances = ec2.instances.all() | |
elb = boto3.client('elb') | |
autoscaling = boto3.client('autoscaling') | |
auto_scaling_groups = autoscaling.describe_auto_scaling_groups()['AutoScalingGroups'] |
NewerOlder