From 95589ffcc20ea9a5c7a21e5c858b1063dcc9dec5 Mon Sep 17 00:00:00 2001 From: shukawam Date: Wed, 28 Feb 2024 09:53:34 +0900 Subject: [PATCH] Add sample of boto3 on oci functions --- boto3-quickstart/func.py | 20 ++++++++++++++++++++ boto3-quickstart/func.yaml | 12 ++++++++++++ boto3-quickstart/requirements.txt | 19 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 boto3-quickstart/func.py create mode 100644 boto3-quickstart/func.yaml create mode 100644 boto3-quickstart/requirements.txt diff --git a/boto3-quickstart/func.py b/boto3-quickstart/func.py new file mode 100644 index 0000000..316af7d --- /dev/null +++ b/boto3-quickstart/func.py @@ -0,0 +1,20 @@ +import io +import json +import logging +import boto3 + +from fdk import response + +s3 = boto3.resource("s3") + +def handler(ctx, data: io.BytesIO = None): + for b in s3.buckets.all(): + print(b.name) + return response.Response( + ctx, response_data=json.dumps( + {"message": "Hello world"}), + headers={"Content-Type": "application/json"} + ) + +if __name__ == "__main__": + print() diff --git a/boto3-quickstart/func.yaml b/boto3-quickstart/func.yaml new file mode 100644 index 0000000..31a76e8 --- /dev/null +++ b/boto3-quickstart/func.yaml @@ -0,0 +1,12 @@ +schema_version: 20180708 +name: boto3-quickstart +version: 0.0.1 +runtime: python +build_image: fnproject/python:3.9-dev +run_image: fnproject/python:3.9 +entrypoint: /python/bin/fdk /function/func.py handler +memory: 256 +config: + AWS_ACCESS_KEY_ID: "" + AWS_SECRET_ACCESS_KEY: "" + AWS_SESSION_TOKEN: "" diff --git a/boto3-quickstart/requirements.txt b/boto3-quickstart/requirements.txt new file mode 100644 index 0000000..10d2eb6 --- /dev/null +++ b/boto3-quickstart/requirements.txt @@ -0,0 +1,19 @@ +boto3==1.34.50 +botocore==1.34.50 +contextvars==2.4 +Cython==3.0.8 +fdk==0.1.68 +httptools==0.6.1 +immutables==0.20 +iniconfig==2.0.0 +iso8601==0.1.12 +jmespath==1.0.1 +packaging==23.2 +pbr==6.0.0 +pluggy==1.4.0 +pytest==8.0.2 +pytest-asyncio==0.12.0 +python-dateutil==2.8.2 +s3transfer==0.10.0 +six==1.16.0 +urllib3==2.0.7