From 09dcfc8c1ce8f3d1b46c17c689088759c65a94fd Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Fri, 13 Dec 2024 23:23:44 +0000 Subject: [PATCH] Add a sample python component to the repo --- .../sample-ggLitePython/1.0.0/ggLitePython.py | 21 ++++++++++++++ .../recipes/sample-ggLitePython-1.0.0.yaml | 28 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 docs/examples/sample-ggLitePython/artifacts/sample-ggLitePython/1.0.0/ggLitePython.py create mode 100644 docs/examples/sample-ggLitePython/recipes/sample-ggLitePython-1.0.0.yaml diff --git a/docs/examples/sample-ggLitePython/artifacts/sample-ggLitePython/1.0.0/ggLitePython.py b/docs/examples/sample-ggLitePython/artifacts/sample-ggLitePython/1.0.0/ggLitePython.py new file mode 100644 index 000000000..a30347738 --- /dev/null +++ b/docs/examples/sample-ggLitePython/artifacts/sample-ggLitePython/1.0.0/ggLitePython.py @@ -0,0 +1,21 @@ +import boto3 + + +def fetch_s3_bucket_list(): + # Create an S3 client + s3 = boto3.client('s3') + # List S3 buckets + response = s3.list_buckets() + # Print the names of all buckets + print("S3 Bucket Names:") + for bucket in response['Buckets']: + print(bucket['Name']) + + +def main(): + print("HELLO WORLD") + fetch_s3_bucket_list() + + +if __name__ == "__main__": + main() diff --git a/docs/examples/sample-ggLitePython/recipes/sample-ggLitePython-1.0.0.yaml b/docs/examples/sample-ggLitePython/recipes/sample-ggLitePython-1.0.0.yaml new file mode 100644 index 000000000..abec97ca3 --- /dev/null +++ b/docs/examples/sample-ggLitePython/recipes/sample-ggLitePython-1.0.0.yaml @@ -0,0 +1,28 @@ +--- +RecipeFormatVersion: "2020-01-25" +ComponentName: sample-ggLitePython +ComponentVersion: 1.0.0 +ComponentType: "aws.greengrass.generic" +ComponentDescription: + This example Python component for GGLite that lists all your s3 bucket names +ComponentPublisher: AWS +ComponentDependencies: + aws.greengrass.TokenExchangeService: + VersionRequirement: ">=0.0.0" + DependencyType: "HARD" +Manifests: + - Platform: + os: linux + runtime: "*" + Lifecycle: + install: + RequiresPrivilege: false + Script: "python3 -m venv ./venv && . ./venv/bin/activate && python3 -m + pip install\ + \ boto3" + run: + RequiresPrivilege: false + Script: + ". ./venv/bin/activate && python3 {artifacts:path}/ggLitePython.py" + # Artifacts: + # - Uri: "---"