Skip to content

Instantly share code, notes, and snippets.

View quiver's full-sized avatar

George Yoshida quiver

View GitHub Profile
Resources:
QueueForLambda:
Type: 'AWS::SQS::Queue'
LambdaServiceRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: 'sts:AssumeRole'
Effect: Allow
---
Resources:
QueueForPipe:
Type: AWS::SQS::Queue
LambdaServiceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
@quiver
quiver / coros_get_activity_list.py
Last active January 8, 2023 15:33
Python Script to get data from COROS Training Hub
'''
Python PoC to interact with COROS Training Hub.
URL : https://training.coros.com/
This script retrieves COROS's activity list for 2022/12.
$ python3 coros_activity_list.py
date,name,sportType,totalTime,distance,calorie,trainingLoad
20221230,Foo Run,100,9538,14651.11,1266085,117
@quiver
quiver / set-retention-for-lambda-at-edge-logs.sh
Created May 9, 2020 19:16
Bash Script to set retention periods for Lambda@Edge CloudWatch Logs in all regions.
#!/bin/bash
# L@E logs are displayed or stored in the Region closest to the location where the function executed.
# This Bash script sets retention periods for CloudWatch Log in all regions.
FUNCTION_NAME=LambdaAtEdgeFunctionName
LOG_GROUP=/aws/lambda/us-east-1.${FUNCTION_NAME}
# Possible Values: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653.
RETENTION_IN_DAYS=30
@quiver
quiver / boto3_cloudfront_create_invalidation.py
Created March 14, 2020 12:31
Sample script to create CloudFront invalidation
'''
Invalidate Amazon CloudFront paths
API
- https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateInvalidation.html
- https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront.html#CloudFront.Client.create_invalidation
'''
import random
import time
import boto3
@quiver
quiver / cloudformation-template-for-aws-backup-thin-backups.yaml
Created July 20, 2019 17:18
CloudFormation template to configure thin backup rules for AWS Backup
AWSTemplateFormatVersion: "2010-09-09"
Description: "Backup Plan template for thin backups"
Resources:
BackupVaultWithThinBackups:
Type: "AWS::Backup::BackupVault"
Properties:
BackupVaultName: "BackupVaultWithThinBackups"
BackupPlanWithThinBackups:
Type: "AWS::Backup::BackupPlan"
@quiver
quiver / eic-cli.sh
Last active June 15, 2022 21:23
simple shell script to demonstrate how EC2 Instance Connect CLI is implemented
#!/bin/bash
# simple shell script to demonstrate how EC2 Instance Connect CLI is implemented.
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html
#
# Usage
# $ bash eic-cli.sh i-1234
if [ $# -ne 1 ]; then
echo "Usage"
echo "$ bash eic-cli.sh i-1234"
@quiver
quiver / iam-policy.json
Last active April 23, 2024 07:02
How to connect to Amazon RDS PostgreSQL with IAM credentials
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"rds-db:connect"
],
"Resource": [
"arn:aws:rds-db:region:account-id:dbuser:dbi-resource-id/database-user-name"
@quiver
quiver / athena.py
Last active August 19, 2022 11:19
query SQL to Amazon Athena and save its results from Amazon S3 Raw
#!/usr/bin/env python
# vim: set fileencoding=utf8 :
```
$ pip install -U boto3 retrying
$ export AWS_DEFAULT_PROFILE=test
$ cat foo.sql
select count(*)
from bar
$ python athena.py foo.sql
$ ls -1
@quiver
quiver / kinesis-stream-state-diagram.dot
Last active May 8, 2016 05:03
AWS Kinesis Stream Status Diagram created with Graphviz
// $ dot -Tpng kinesis-stream-state-diagram.dot -o kinesis-stream-state-diagram.png
digraph kinesis_stream_status {
labelloc="t";
label="AWS Kinesis Streams : Stream State Diagram";
CreateStream[shape=box];
DeleteStream[shape=box];
MergeShards[shape=box];
SplitShards[shape=box];
IncreaseStreamRetentionPeriod[shape=box];