Skip to content

Instantly share code, notes, and snippets.

@tal66
tal66 / read s3 in lambda
Last active August 30, 2023 20:22
read s3 json in lambda
# read json from s3 in lambda
s3_client = boto3.client('s3')
resp = s3_client.get_object(
Bucket='<BUCKETNAME>',
Key='<FILENAME>.json',
)
content = resp['Body'] # botocore.response.StreamingBody
json_obj = json.load(content)
@tal66
tal66 / azure blob
Last active August 28, 2023 09:34
view azure blob
# azure blob on win
$ACC_NAME = ""
$CONTAINER_NAME = ""
# last files
az storage blob list --account-name $ACC_NAME -c $CONTAINER_NAME| jq -r '.[].name'| tail
# just cat last one
az storage blob download --account-name $ACC_NAME -c $CONTAINER_NAME -n $(az storage blob list --account-name $ACC_NAME -c $CONTAINER_NAME| jq -r '.[].name'| tail -1)
@tal66
tal66 / update lambda image
Last active August 28, 2023 09:33
lambda image fast update on windows
# build,tag,push,deploy image to lambda on win ps7
$FUNC_NAME = ""
$ACC_ID = ""
$ECR_REPO_NAME = ""
$IMG = ""
$IMG_URI = "$($ACC_ID).dkr.ecr.eu-central-1.amazonaws.com/$($ECR_REPO_NAME):latest"
docker build --platform linux/amd64 -t $IMG . && docker tag $IMG $IMG_URI && docker push $IMG_URI && aws lambda update-function-code --function-name $FUNC_NAME --image-uri $IMG_URI