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
#!/bin/bash | |
WORKING_DIR=/mnt/debug | |
UPLOAD_CMD="/usr/local/bin/s3cmd --debug put" | |
DELETE_CMD="/usr/local/bin/s3cmd del" | |
DEST_BUCKET=s3://your-bucket-name-here | |
cd $WORKING_DIR | |
TIMESTAMP=`date +%s` |
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
AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider()); | |
ListObjectsRequest listObjectsRequest = new ListObjectsRequest() | |
.withBucketName(bucketName) | |
.withPrefix("bob") | |
.withEncodingType("url"); | |
ObjectListing objectListing; | |
do { | |
objectListing = s3client.listObjects(listObjectsRequest); | |
for (S3ObjectSummary objectSummary : | |
objectListing.getObjectSummaries()) { |
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 autoscaling describe-scaling-activities --auto-scaling-group-name web-asg --query 'Activities[*].{Description:Description,StartTime:StartTime,Cause:Cause}' | |
[ | |
{ | |
"Cause": "At 2015-06-16T14:59:31Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 2 to 3.", | |
"Description": "Launching a new EC2 instance: i-751c4edf", | |
"StartTime": "2015-06-16T14:59:32.927Z" | |
}, | |
{ | |
"Cause": "At 2015-06-16T14:59:01Z an instance was taken out of service in response to a EC2 health check indicating it has been terminated or stopped.", | |
"Description": "Terminating EC2 instance: i-74194bde", |
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 autoscaling describe-auto-scaling-groups --auto-scaling-group-names vpc-web-asg --query 'AutoScalingGroups[*].{ASG:AutoScalingGroupName,Desired:DesiredCapacity,Min:MinSize,Max:MaxSize}' | |
[ | |
{ | |
"Desired": 3, | |
"Max": 3, | |
"ASG": "vpc-web-asg", | |
"Min": 3 | |
} | |
] | |
$ aws autoscaling update-auto-scaling-group --auto-scaling-group-name vpc-web-asg --min-size 0 --desired-capacity 0 |
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
$ for name in \ | |
> $(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names vpc-web-asg --query 'AutoScalingGroups[*].Instances[*].{instance:InstanceId}' --output text); \ | |
> do \ | |
> aws autoscaling terminate-instance-in-auto-scaling-group --instance-id $name --no-should-decrement-desired-capacity;\ | |
> done | |
{ | |
"Activity": { | |
"Description": "Terminating EC2 instance: i-0c48b6df", | |
"ActivityId": "aad0f260-dbd1-42c0-9320-7f1b07ff1a23", | |
"Details": "{\"Availability Zone\":\"us-east-1b\",\"Subnet ID\":\"subnet-67f89410\"}", |
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 calc_max_data_len(chunk_size, key_length=0, cas_enabled=True): | |
max_data = chunk_size - (key_length + 1) # less null terminated key | |
max_data -= 48 # item overhead | |
if cas_enabled: | |
max_data -= 8 # bytes for cas | |
max_data -= 2 # data termination \r\n | |
max_data -= len(" 0 %d\r\n" % max_data) # max header with flags 0 | |
return max_data |
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
#!/bin/bash | |
for bucket in $(aws s3api list-buckets --query 'Buckets[*].{Name:Name}' --output text) | |
do | |
region=$(aws s3api get-bucket-location --bucket $bucket --query 'LocationConstraint' --output text | awk '{sub(/None/,"us-east-1")}; 1') | |
parts=$(aws s3api list-multipart-uploads --bucket $bucket --region $region --query 'Uploads[*].{Key:Key,Initiated:Initiated}' --output text) | |
echo "$bucket : $parts" | |
done |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "dynamodb:UpdateItem", | |
"Resource": "arn:aws:dynamodb:REGION:ACCOUNT_ID:table/S3EventAggregator" | |
} | |
] | |
} |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "sqs:SendMessage", | |
"Resource": "arn:aws:sqs:REGION:ACCOUNT:S3EventAggregatorActionQueue" | |
} | |
] | |
} |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "lambda.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} |
OlderNewer