Skip to content

Instantly share code, notes, and snippets.

View thanakijwanavit's full-sized avatar
🎯
Focusing

Nic Wanavit thanakijwanavit

🎯
Focusing
View GitHub Profile
@thanakijwanavit
thanakijwanavit / presignUploadS3.py
Last active January 19, 2021 11:36
upload file
##### for signor
from s3bz.s3bz import S3
def presign (bucket:str, key:str, expiry:int)->dict:
return S3.presignUpload(bucket=bucket, key = key, expiry = 1000)
```
{'url': 'https://inventory-bucket-dev-manual.s3-accelerate.amazonaws.com/',
'fields': {'key': 'test',
@thanakijwanavit
thanakijwanavit / CloudFrontCors.yaml
Last active March 12, 2021 17:01
apiGateway Cors
AWSTemplateFormatVersion: 2010-09-09
Resources:
CloudFrontCachePolicy:
Type: AWS::CloudFront::CachePolicy
Properties:
CachePolicyConfig:
CachePolicyConfig
cloudfrontdistribution:
Type: AWS::CloudFront::Distribution
Properties:
@thanakijwanavit
thanakijwanavit / parameters.yaml
Created January 5, 2021 23:32
parameters for yaml sam template
Parameters:
BRANCH:
Type: String
Default: dev-blank
@thanakijwanavit
thanakijwanavit / dynamodbCrudApp.yaml
Last active January 5, 2021 14:56
example of dynamodb crud app template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
shortenLink
Sample SAM Template for shortenLink
Globals:
Function:
Timeout: 3
Runtime: python3.8
@thanakijwanavit
thanakijwanavit / s3Accelerate.yaml
Created January 3, 2021 09:38
create an s3 bucket with acceleration
ProductS3:
Type: AWS::S3::Bucket
Properties:
AccelerateConfiguration:
AccelerationStatus: Enabled
BucketName: !Join [ "-" , ["product-bucket", !Ref BRANCH]]
CorsConfiguration:
CorsRules:
- AllowedMethods:
- GET
@thanakijwanavit
thanakijwanavit / createS3Bucket.py
Created January 1, 2021 06:00
create s3 bucket with acceleration settings
import boto3
from botocore.exceptions import ClientError
bucket='filtered-df-sagemaker'
s3 = boto3.client('s3')
try:
s3.create_bucket(
Bucket=bucket,
CreateBucketConfiguration={'LocationConstraint':'ap-southeast-1'})
except ClientError as e:
@thanakijwanavit
thanakijwanavit / cognito.yaml
Created December 27, 2020 15:54 — forked from singledigit/cognito.yaml
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
SNSRole:
@thanakijwanavit
thanakijwanavit / addSwap.config
Created December 21, 2020 01:02
add swap file to centos (aws linux)
https://www.vembu.com/blog/increase-swap-memory-centos-7/
@thanakijwanavit
thanakijwanavit / efsSam.yaml
Last active December 19, 2020 16:26
efs template for demo
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
shortenLink
Sample SAM Template for shortenLink
Globals:
Function:
Timeout: 3
Runtime: python3.8
@thanakijwanavit
thanakijwanavit / pdFormatList.py
Created December 18, 2020 11:01
format a dictionary into list form
import pandas as pd
import json
df = pd.DataFrame({'hello':['1','2','2'], 'world':['1','2','3']})
df
tableDict = df.to_dict(orient='list')
json.dumps(tableDict)