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
sam build --profile villaaws &&\ | |
sam deploy --profile villaaws --parameter-overrides BRANCH='dev-manual' STACKNAME='dev-manual' |
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 | |
export PKG_DIR="python" | |
rm -rf ${PKG_DIR} &&\ | |
rm package.zip &&\ | |
mkdir -p ${PKG_DIR} | |
docker run --rm -v $(pwd):/foo -w /foo lambci/lambda:build-python3.8 \ | |
pip install -r requirements.txt -t ${PKG_DIR} |
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 pandas as pd | |
from pprint import pprint | |
class Searcher: | |
''' a search class to return search result''' | |
def __init__(self, searchTerm:str, key, pw, region = 'ap-southeast-1', | |
endpoint = 'https://search-villa-cloudsearch-2-4izacsoytzqf6kztcyjhssy2ti.ap-southeast-1.cloudsearch.amazonaws.com' | |
): | |
self.searchTerm = searchTerm | |
self.cloudSearch = boto3.client('cloudsearchdomain' , |
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
NEW_UUID=$(openssl rand -hex 12) | |
STACK_NAME=test-database-dev-test-$NEW_UUID | |
echo $STACK_NAME | |
source testrc&&python ./getSetData/app.py &&\ | |
sam build --profile villaaws &&\ | |
sam deploy --profile villaaws --stack-name $STACK_NAME --parameter-overrides BRANCH=${STACK_NAME} ROOTSTACKNAME=${STACK_NAME}&&\ | |
aws --profile villaaws lambda invoke --function-name $STACK_NAME-topup testResult.log &&\ | |
cat testResult.log &&\ | |
read -p "Press enter to continue" |
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 sys, os | |
# Disable | |
def blockPrint(): | |
sys.stdout = open(os.devnull, 'w') | |
# Restore | |
def enablePrint(): | |
sys.stdout = sys.__stdout__ |
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
df = pd.DataFrame([{'ib_brcode': '9007', | |
'ib_cf_qty': '24', | |
'ib_prcode': '0000009', | |
'new_ib_vs_stock_cv': '24'}, | |
{'ib_brcode': '9007', | |
'ib_cf_qty': '39', | |
'ib_prcode': '0000012', | |
'new_ib_vs_stock_cv': '38'}]) | |
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 requests, bz2, boto3 | |
class S3: | |
@staticmethod | |
def s3(): | |
''' | |
create and return s3 client | |
''' | |
config = Config(s3={"use_accelerate_endpoint": True, | |
"addressing_style": "virtual"}) | |
s3 = boto3.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
# create bucket | |
config = Config(s3={"use_accelerate_endpoint": True, | |
"addressing_style": "virtual"}) | |
s3 = boto3.client( | |
's3', | |
aws_access_key_id= ACCESS_KEY_ID, | |
aws_secret_access_key= SECRET_ACCESS_KEY, | |
region_name = REGION, | |
config = config | |
) |
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 get_secret(secretName = None, accessKey=None, secretKey=None, region = 'ap-southeast-1'): | |
secretManager = boto3.client( | |
service_name='secretsmanager', | |
region_name=region, | |
aws_access_key_id = accessKey, | |
aws_secret_access_key = secretKey | |
) | |
response = secretManager.get_secret_value( | |
SecretId=secretName | |
) |
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 pickle | |
credLocation = 'drive/My Drive/.pynamodbDax' | |
user ='' | |
pw = '' | |
if user and pw: | |
with open (credLocation , 'wb') as f: | |
pickle.dump({ | |
'user': user, | |
'pw': pw | |
}, f) |