From 5dcd79d2daad648e43f3e17affa412cf92647d26 Mon Sep 17 00:00:00 2001 From: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> Date: Tue, 6 Feb 2024 15:20:13 -0800 Subject: [PATCH 1/2] chore: cleanup earlier ruby refactor --- ruby2.7/hello-img/.gitignore | 229 ------------ ruby2.7/hello-img/README.md | 20 - ruby2.7/hello-img/cookiecutter.json | 12 - .../{{cookiecutter.project_name}}/.gitignore | 345 ------------------ .../{{cookiecutter.project_name}}/Gemfile | 8 - .../{{cookiecutter.project_name}}/README.md | 112 ------ .../events/event.json | 62 ---- .../hello_world/Dockerfile | 9 - .../hello_world/Gemfile | 5 - .../hello_world/app.rb | 38 -- .../template.yaml | 48 --- .../tests/unit/test_handler.rb | 94 ----- ruby2.7/hello/.gitignore | 229 ------------ ruby2.7/hello/README.md | 20 - ruby2.7/hello/cookiecutter.json | 12 - .../{{cookiecutter.project_name}}/.gitignore | 345 ------------------ .../{{cookiecutter.project_name}}/Gemfile | 8 - .../{{cookiecutter.project_name}}/README.md | 125 ------- .../events/event.json | 62 ---- .../hello_world/Gemfile | 5 - .../hello_world/app.rb | 38 -- .../template.yaml | 46 --- .../tests/unit/test_handler.rb | 95 ----- ruby2.7/step-func/.gitignore | 229 ------------ ruby2.7/step-func/README.md | 22 -- ruby2.7/step-func/cookiecutter.json | 12 - .../{{cookiecutter.project_name}}/.gitignore | 345 ------------------ .../{{cookiecutter.project_name}}/Gemfile | 6 - .../{{cookiecutter.project_name}}/README.md | 104 ------ .../functions/stock_buyer/Gemfile | 3 - .../functions/stock_buyer/app.rb | 34 -- .../functions/stock_checker/Gemfile | 3 - .../functions/stock_checker/app.rb | 23 -- .../functions/stock_seller/Gemfile | 3 - .../functions/stock_seller/app.rb | 33 -- .../statemachine/stock_trader.asl.json | 94 ----- .../template.yaml | 94 ----- .../tests/unit/test_stock_buyer.rb | 19 - .../tests/unit/test_stock_checker.rb | 11 - .../tests/unit/test_stock_seller.rb | 19 - ruby3.2/hello-img/.gitignore | 229 ------------ ruby3.2/hello-img/README.md | 20 - ruby3.2/hello-img/cookiecutter.json | 12 - .../{{cookiecutter.project_name}}/.gitignore | 345 ------------------ .../{{cookiecutter.project_name}}/Gemfile | 8 - .../{{cookiecutter.project_name}}/README.md | 112 ------ .../events/event.json | 62 ---- .../hello_world/Dockerfile | 9 - .../hello_world/Gemfile | 5 - .../hello_world/app.rb | 38 -- .../template.yaml | 48 --- .../tests/unit/test_handler.rb | 94 ----- ruby3.2/hello/.gitignore | 229 ------------ ruby3.2/hello/README.md | 20 - ruby3.2/hello/cookiecutter.json | 12 - .../{{cookiecutter.project_name}}/.gitignore | 345 ------------------ .../{{cookiecutter.project_name}}/Gemfile | 8 - .../{{cookiecutter.project_name}}/README.md | 125 ------- .../events/event.json | 62 ---- .../hello_world/Gemfile | 5 - .../hello_world/app.rb | 38 -- .../template.yaml | 46 --- .../tests/unit/test_handler.rb | 95 ----- ruby3.2/step-func/.gitignore | 229 ------------ ruby3.2/step-func/README.md | 22 -- ruby3.2/step-func/cookiecutter.json | 12 - .../{{cookiecutter.project_name}}/.gitignore | 345 ------------------ .../{{cookiecutter.project_name}}/Gemfile | 6 - .../{{cookiecutter.project_name}}/README.md | 104 ------ .../functions/stock_buyer/Gemfile | 3 - .../functions/stock_buyer/app.rb | 34 -- .../functions/stock_checker/Gemfile | 3 - .../functions/stock_checker/app.rb | 23 -- .../functions/stock_seller/Gemfile | 3 - .../functions/stock_seller/app.rb | 33 -- .../statemachine/stock_trader.asl.json | 94 ----- .../template.yaml | 94 ----- .../tests/unit/test_stock_buyer.rb | 19 - .../tests/unit/test_stock_checker.rb | 11 - .../tests/unit/test_stock_seller.rb | 19 - tests/refactor/test_compare_folders.py | 45 +-- 81 files changed, 23 insertions(+), 6064 deletions(-) delete mode 100644 ruby2.7/hello-img/.gitignore delete mode 100644 ruby2.7/hello-img/README.md delete mode 100644 ruby2.7/hello-img/cookiecutter.json delete mode 100644 ruby2.7/hello-img/{{cookiecutter.project_name}}/.gitignore delete mode 100644 ruby2.7/hello-img/{{cookiecutter.project_name}}/Gemfile delete mode 100644 ruby2.7/hello-img/{{cookiecutter.project_name}}/README.md delete mode 100644 ruby2.7/hello-img/{{cookiecutter.project_name}}/events/event.json delete mode 100644 ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/Dockerfile delete mode 100644 ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/Gemfile delete mode 100644 ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/app.rb delete mode 100644 ruby2.7/hello-img/{{cookiecutter.project_name}}/template.yaml delete mode 100644 ruby2.7/hello-img/{{cookiecutter.project_name}}/tests/unit/test_handler.rb delete mode 100644 ruby2.7/hello/.gitignore delete mode 100644 ruby2.7/hello/README.md delete mode 100644 ruby2.7/hello/cookiecutter.json delete mode 100644 ruby2.7/hello/{{cookiecutter.project_name}}/.gitignore delete mode 100644 ruby2.7/hello/{{cookiecutter.project_name}}/Gemfile delete mode 100644 ruby2.7/hello/{{cookiecutter.project_name}}/README.md delete mode 100644 ruby2.7/hello/{{cookiecutter.project_name}}/events/event.json delete mode 100644 ruby2.7/hello/{{cookiecutter.project_name}}/hello_world/Gemfile delete mode 100644 ruby2.7/hello/{{cookiecutter.project_name}}/hello_world/app.rb delete mode 100644 ruby2.7/hello/{{cookiecutter.project_name}}/template.yaml delete mode 100644 ruby2.7/hello/{{cookiecutter.project_name}}/tests/unit/test_handler.rb delete mode 100644 ruby2.7/step-func/.gitignore delete mode 100644 ruby2.7/step-func/README.md delete mode 100644 ruby2.7/step-func/cookiecutter.json delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/.gitignore delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/Gemfile delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/README.md delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/Gemfile delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/app.rb delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_checker/Gemfile delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_checker/app.rb delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_seller/Gemfile delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_seller/app.rb delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/statemachine/stock_trader.asl.json delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/template.yaml delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_buyer.rb delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_checker.rb delete mode 100644 ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_seller.rb delete mode 100644 ruby3.2/hello-img/.gitignore delete mode 100644 ruby3.2/hello-img/README.md delete mode 100644 ruby3.2/hello-img/cookiecutter.json delete mode 100644 ruby3.2/hello-img/{{cookiecutter.project_name}}/.gitignore delete mode 100644 ruby3.2/hello-img/{{cookiecutter.project_name}}/Gemfile delete mode 100644 ruby3.2/hello-img/{{cookiecutter.project_name}}/README.md delete mode 100644 ruby3.2/hello-img/{{cookiecutter.project_name}}/events/event.json delete mode 100644 ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/Dockerfile delete mode 100644 ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/Gemfile delete mode 100644 ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/app.rb delete mode 100644 ruby3.2/hello-img/{{cookiecutter.project_name}}/template.yaml delete mode 100644 ruby3.2/hello-img/{{cookiecutter.project_name}}/tests/unit/test_handler.rb delete mode 100644 ruby3.2/hello/.gitignore delete mode 100644 ruby3.2/hello/README.md delete mode 100644 ruby3.2/hello/cookiecutter.json delete mode 100644 ruby3.2/hello/{{cookiecutter.project_name}}/.gitignore delete mode 100644 ruby3.2/hello/{{cookiecutter.project_name}}/Gemfile delete mode 100644 ruby3.2/hello/{{cookiecutter.project_name}}/README.md delete mode 100644 ruby3.2/hello/{{cookiecutter.project_name}}/events/event.json delete mode 100644 ruby3.2/hello/{{cookiecutter.project_name}}/hello_world/Gemfile delete mode 100644 ruby3.2/hello/{{cookiecutter.project_name}}/hello_world/app.rb delete mode 100644 ruby3.2/hello/{{cookiecutter.project_name}}/template.yaml delete mode 100644 ruby3.2/hello/{{cookiecutter.project_name}}/tests/unit/test_handler.rb delete mode 100644 ruby3.2/step-func/.gitignore delete mode 100644 ruby3.2/step-func/README.md delete mode 100644 ruby3.2/step-func/cookiecutter.json delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/.gitignore delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/Gemfile delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/README.md delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/Gemfile delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/app.rb delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_checker/Gemfile delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_checker/app.rb delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_seller/Gemfile delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_seller/app.rb delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/statemachine/stock_trader.asl.json delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/template.yaml delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_buyer.rb delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_checker.rb delete mode 100644 ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_seller.rb diff --git a/ruby2.7/hello-img/.gitignore b/ruby2.7/hello-img/.gitignore deleted file mode 100644 index 41bcace31..000000000 --- a/ruby2.7/hello-img/.gitignore +++ /dev/null @@ -1,229 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam diff --git a/ruby2.7/hello-img/README.md b/ruby2.7/hello-img/README.md deleted file mode 100644 index bc09acae3..000000000 --- a/ruby2.7/hello-img/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Cookiecutter Ruby Hello-world for SAM based Serverless App - -A cookiecutter template to create a Ruby Hello world boilerplate using [Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model). - -## Requirements - -* [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) - -## Usage - -Generate a boilerplate template in your current project directory using the following syntax: - -* **Ruby 2.7**: `sam init --runtime ruby2.7` - -> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default) - - -# Credits - -* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter) diff --git a/ruby2.7/hello-img/cookiecutter.json b/ruby2.7/hello-img/cookiecutter.json deleted file mode 100644 index 3e05d04e7..000000000 --- a/ruby2.7/hello-img/cookiecutter.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "project_name": "Name of the project", - "runtime": "ruby2.7", - "architectures": { - "value": [ - "x86_64", "arm64" - ] - }, - "_copy_without_render": [ - ".gitignore" - ] -} \ No newline at end of file diff --git a/ruby2.7/hello-img/{{cookiecutter.project_name}}/.gitignore b/ruby2.7/hello-img/{{cookiecutter.project_name}}/.gitignore deleted file mode 100644 index 4bccb52c8..000000000 --- a/ruby2.7/hello-img/{{cookiecutter.project_name}}/.gitignore +++ /dev/null @@ -1,345 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,pycharm,visualstudiocode,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history -.ionide - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam diff --git a/ruby2.7/hello-img/{{cookiecutter.project_name}}/Gemfile b/ruby2.7/hello-img/{{cookiecutter.project_name}}/Gemfile deleted file mode 100644 index b566789df..000000000 --- a/ruby2.7/hello-img/{{cookiecutter.project_name}}/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -gem "httparty" - -group :test do - gem "test-unit" - gem "mocha" -end diff --git a/ruby2.7/hello-img/{{cookiecutter.project_name}}/README.md b/ruby2.7/hello-img/{{cookiecutter.project_name}}/README.md deleted file mode 100644 index fbe512411..000000000 --- a/ruby2.7/hello-img/{{cookiecutter.project_name}}/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# {{ cookiecutter.project_name }} - -This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders. - -- hello_world - Code for the application's Lambda function and Project Dockerfile. -- events - Invocation events that you can use to invoke the function. -- tests - Unit tests for the application code. -- template.yaml - A template that defines the application's AWS resources. - -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - -## Deploy the sample application - -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. - -To use the SAM CLI, you need the following tools. - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -You may need the following for local testing. -* Ruby - [Install Ruby 2.7](https://www.ruby-lang.org/en/documentation/installation/) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` - -The first command will build a docker image from a Dockerfile and then copy the source of your application inside the Docker image. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your API Gateway Endpoint URL in the output values displayed after deployment. - -## Use the SAM CLI to build and test locally - -Build your application with the `sam build` command. - -```bash -{{ cookiecutter.project_name }}$ sam build -``` - -The SAM CLI builds a docker image from a Dockerfile and then installs dependencies defined in `hello_world/Gemfile` inside the docker image. The processed template file is saved in the `.aws-sam/build` folder. - -Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project. - -Run functions locally and invoke them with the `sam local invoke` command. - -```bash -{{ cookiecutter.project_name }}$ sam local invoke HelloWorldFunction --event events/event.json -``` - -The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000. - -```bash -{{ cookiecutter.project_name }}$ sam local start-api -{{ cookiecutter.project_name }}$ curl http://localhost:3000/ -``` - -The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path. - -```yaml - Events: - HelloWorld: - Type: Api - Properties: - Path: /hello - Method: get -``` - -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. - -## Fetch, tail, and filter Lambda function logs - -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. - -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. - -```bash -{{ cookiecutter.project_name }}$ sam logs -n HelloWorldFunction --stack-name {{ cookiecutter.project_name }} --tail -``` - -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). - -## Unit tests - -Tests are defined in the `tests` folder in this project. - -```bash -{{ cookiecutter.project_name }}$ ruby tests/unit/test_handler.rb -``` - -## Cleanup - -To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: - -```bash -sam delete --stack-name {{ cookiecutter.project_name }} -``` - -## Resources - -See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. - -Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) diff --git a/ruby2.7/hello-img/{{cookiecutter.project_name}}/events/event.json b/ruby2.7/hello-img/{{cookiecutter.project_name}}/events/event.json deleted file mode 100644 index 070ad8e01..000000000 --- a/ruby2.7/hello-img/{{cookiecutter.project_name}}/events/event.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "body": "{\"message\": \"hello world\"}", - "resource": "/{proxy+}", - "path": "/path/to/resource", - "httpMethod": "POST", - "isBase64Encoded": false, - "queryStringParameters": { - "foo": "bar" - }, - "pathParameters": { - "proxy": "/path/to/resource" - }, - "stageVariables": { - "baz": "qux" - }, - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8", - "Cache-Control": "max-age=0", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "1234567890.execute-api.us-east-1.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Custom User Agent String", - "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", - "X-Forwarded-For": "127.0.0.1, 127.0.0.2", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "requestContext": { - "accountId": "123456789012", - "resourceId": "123456", - "stage": "prod", - "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", - "requestTime": "09/Apr/2015:12:34:56 +0000", - "requestTimeEpoch": 1428582896000, - "identity": { - "cognitoIdentityPoolId": null, - "accountId": null, - "cognitoIdentityId": null, - "caller": null, - "accessKey": null, - "sourceIp": "127.0.0.1", - "cognitoAuthenticationType": null, - "cognitoAuthenticationProvider": null, - "userArn": null, - "userAgent": "Custom User Agent String", - "user": null - }, - "path": "/prod/path/to/resource", - "resourcePath": "/{proxy+}", - "httpMethod": "POST", - "apiId": "1234567890", - "protocol": "HTTP/1.1" - } -} diff --git a/ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/Dockerfile b/ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/Dockerfile deleted file mode 100644 index 5e279d280..000000000 --- a/ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM public.ecr.aws/lambda/ruby:2.7 - -COPY app.rb Gemfile ./ - -ENV GEM_HOME=${LAMBDA_TASK_ROOT} -RUN bundle install - -# Command can be overwritten by providing a different command in the template directly. -CMD ["app.lambda_handler"] diff --git a/ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/Gemfile b/ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/Gemfile deleted file mode 100644 index 8ba70fa68..000000000 --- a/ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source "https://rubygems.org" - -gem "httparty" - -ruby '~> 2.7.0' diff --git a/ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/app.rb b/ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/app.rb deleted file mode 100644 index e2a102f70..000000000 --- a/ruby2.7/hello-img/{{cookiecutter.project_name}}/hello_world/app.rb +++ /dev/null @@ -1,38 +0,0 @@ -# require 'httparty' -require 'json' - -def lambda_handler(event:, context:) - # Sample pure Lambda function - - # Parameters - # ---------- - # event: Hash, required - # API Gateway Lambda Proxy Input Format - # Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format - - # context: object, required - # Lambda Context runtime methods and attributes - # Context doc: https://docs.aws.amazon.com/lambda/latest/dg/ruby-context.html - - # Returns - # ------ - # API Gateway Lambda Proxy Output Format: dict - # 'statusCode' and 'body' are required - # # api-gateway-simple-proxy-for-lambda-output-format - # Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html - - # begin - # response = HTTParty.get('http://checkip.amazonaws.com/') - # rescue HTTParty::Error => error - # puts error.inspect - # raise error - # end - - { - statusCode: 200, - body: { - message: "Hello World!", - # location: response.body - }.to_json - } -end diff --git a/ruby2.7/hello-img/{{cookiecutter.project_name}}/template.yaml b/ruby2.7/hello-img/{{cookiecutter.project_name}}/template.yaml deleted file mode 100644 index 18e72aab2..000000000 --- a/ruby2.7/hello-img/{{cookiecutter.project_name}}/template.yaml +++ /dev/null @@ -1,48 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: > - {{ cookiecutter.project_name }} - - Sample SAM Template for {{ cookiecutter.project_name }} - -# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst -Globals: - Function: - Timeout: 3 - MemorySize: 128 - -Resources: - HelloWorldFunction: - Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction - Properties: - PackageType: Image - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - Events: - HelloWorld: - Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api - Properties: - Path: /hello - Method: get - Metadata: - DockerTag: {{cookiecutter.runtime}}-v1 - DockerContext: ./hello_world - Dockerfile: Dockerfile - -Outputs: - # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function - # Find out more about other implicit resources you can reference within SAM - # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api - HelloWorldApi: - Description: "API Gateway endpoint URL for Prod stage for Hello World function" - Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/" - HelloWorldFunction: - Description: "Hello World Lambda Function ARN" - Value: !GetAtt HelloWorldFunction.Arn - HelloWorldFunctionIamRole: - Description: "Implicit IAM Role created for Hello World function" - Value: !GetAtt HelloWorldFunctionRole.Arn diff --git a/ruby2.7/hello-img/{{cookiecutter.project_name}}/tests/unit/test_handler.rb b/ruby2.7/hello-img/{{cookiecutter.project_name}}/tests/unit/test_handler.rb deleted file mode 100644 index df66b969a..000000000 --- a/ruby2.7/hello-img/{{cookiecutter.project_name}}/tests/unit/test_handler.rb +++ /dev/null @@ -1,94 +0,0 @@ -require 'json' -require 'test/unit' -require 'mocha/test_unit' - -require_relative '../../hello_world/app' - -class HelloWorldTest < Test::Unit::TestCase - def event - { - body: 'eyJ0ZXN0IjoiYm9keSJ9', - resource: '/{proxy+}', - path: '/path/to/resource', - httpMethod: 'POST', - isBase64Encoded: true, - queryStringParameters: { - foo: 'bar' - }, - pathParameters: { - proxy: '/path/to/resource' - }, - stageVariables: { - baz: 'qux' - }, - headers: { - 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', - 'Accept-Encoding' => 'gzip, deflate, sdch', - 'Accept-Language' => 'en-US,en;q=0.8', - 'Cache-Control' => 'max-age=0', - 'CloudFront-Forwarded-Proto' => 'https', - 'CloudFront-Is-Desktop-Viewer' => 'true', - 'CloudFront-Is-Mobile-Viewer' => 'false', - 'CloudFront-Is-SmartTV-Viewer' => 'false', - 'CloudFront-Is-Tablet-Viewer' => 'false', - 'CloudFront-Viewer-Country' => 'US', - 'Host' => '1234567890.execute-api.us-east-1.amazonaws.com', - 'Upgrade-Insecure-Requests' => '1', - 'User-Agent' => 'Custom User Agent String', - 'Via' => '1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)', - 'X-Amz-Cf-Id' => 'cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==', - 'X-Forwarded-For' => '127.0.0.1, 127.0.0.2', - 'X-Forwarded-Port' => '443', - 'X-Forwarded-Proto' => 'https' - }, - requestContext: { - accountId: '123456789012', - resourceId: '123456', - stage: 'prod', - requestId: 'c6af9ac6-7b61-11e6-9a41-93e8deadbeef', - requestTime: '09/Apr/2015:12:34:56 +0000', - requestTimeEpoch: 1428582896000, - identity: { - cognitoIdentityPoolId: 'null', - accountId: 'null', - cognitoIdentityId: 'null', - caller: 'null', - accessKey: 'null', - sourceIp: '127.0.0.1', - cognitoAuthenticationType: 'null', - cognitoAuthenticationProvider: 'null', - userArn: 'null', - userAgent: 'Custom User Agent String', - user: 'null' - }, - path: '/prod/path/to/resource', - resourcePath: '/{proxy+}', - httpMethod: 'POST', - apiId: '1234567890', - protocol: 'HTTP/1.1' - } - } - end - - def mock_response - Object.new.tap do |mock| - mock.expects(:code).returns(200) - mock.expects(:body).returns('1.1.1.1') - end - end - - def expected_result - { - statusCode: 200, - body: { - message: 'Hello World!', - location: '1.1.1.1' - }.to_json - } - end - - def test_lambda_handler - HTTParty.expects(:get).with('http://checkip.amazonaws.com/').returns(mock_response) - assert_equal(lambda_handler(event: event, context: ''), expected_result) - end -end diff --git a/ruby2.7/hello/.gitignore b/ruby2.7/hello/.gitignore deleted file mode 100644 index 41bcace31..000000000 --- a/ruby2.7/hello/.gitignore +++ /dev/null @@ -1,229 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam diff --git a/ruby2.7/hello/README.md b/ruby2.7/hello/README.md deleted file mode 100644 index bc09acae3..000000000 --- a/ruby2.7/hello/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Cookiecutter Ruby Hello-world for SAM based Serverless App - -A cookiecutter template to create a Ruby Hello world boilerplate using [Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model). - -## Requirements - -* [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) - -## Usage - -Generate a boilerplate template in your current project directory using the following syntax: - -* **Ruby 2.7**: `sam init --runtime ruby2.7` - -> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default) - - -# Credits - -* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter) diff --git a/ruby2.7/hello/cookiecutter.json b/ruby2.7/hello/cookiecutter.json deleted file mode 100644 index 3e05d04e7..000000000 --- a/ruby2.7/hello/cookiecutter.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "project_name": "Name of the project", - "runtime": "ruby2.7", - "architectures": { - "value": [ - "x86_64", "arm64" - ] - }, - "_copy_without_render": [ - ".gitignore" - ] -} \ No newline at end of file diff --git a/ruby2.7/hello/{{cookiecutter.project_name}}/.gitignore b/ruby2.7/hello/{{cookiecutter.project_name}}/.gitignore deleted file mode 100644 index 4bccb52c8..000000000 --- a/ruby2.7/hello/{{cookiecutter.project_name}}/.gitignore +++ /dev/null @@ -1,345 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,pycharm,visualstudiocode,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history -.ionide - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam diff --git a/ruby2.7/hello/{{cookiecutter.project_name}}/Gemfile b/ruby2.7/hello/{{cookiecutter.project_name}}/Gemfile deleted file mode 100644 index b566789df..000000000 --- a/ruby2.7/hello/{{cookiecutter.project_name}}/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -gem "httparty" - -group :test do - gem "test-unit" - gem "mocha" -end diff --git a/ruby2.7/hello/{{cookiecutter.project_name}}/README.md b/ruby2.7/hello/{{cookiecutter.project_name}}/README.md deleted file mode 100644 index a2abb0c7d..000000000 --- a/ruby2.7/hello/{{cookiecutter.project_name}}/README.md +++ /dev/null @@ -1,125 +0,0 @@ -# {{ cookiecutter.project_name }} - -This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders. - -- hello_world - Code for the application's Lambda function. -- events - Invocation events that you can use to invoke the function. -- tests - Unit tests for the application code. -- template.yaml - A template that defines the application's AWS resources. - -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - -If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit. -The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started. - -* [CLion](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [GoLand](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [WebStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [Rider](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [PhpStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [RubyMine](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [DataGrip](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html) -* [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html) - -## Deploy the sample application - -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. - -To use the SAM CLI, you need the following tools. - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Ruby - [Install Ruby 2.7](https://www.ruby-lang.org/en/documentation/installation/) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` - -The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your API Gateway Endpoint URL in the output values displayed after deployment. - -## Use the SAM CLI to build and test locally - -Build your application with the `sam build` command. - -```bash -{{ cookiecutter.project_name }}$ sam build -``` - -The SAM CLI installs dependencies defined in `hello_world/Gemfile`, creates a deployment package, and saves it in the `.aws-sam/build` folder. - -Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project. - -Run functions locally and invoke them with the `sam local invoke` command. - -```bash -{{ cookiecutter.project_name }}$ sam local invoke HelloWorldFunction --event events/event.json -``` - -The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000. - -```bash -{{ cookiecutter.project_name }}$ sam local start-api -{{ cookiecutter.project_name }}$ curl http://localhost:3000/ -``` - -The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path. - -```yaml - Events: - HelloWorld: - Type: Api - Properties: - Path: /hello - Method: get -``` - -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. - -## Fetch, tail, and filter Lambda function logs - -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. - -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. - -```bash -{{ cookiecutter.project_name }}$ sam logs -n HelloWorldFunction --stack-name {{ cookiecutter.project_name }} --tail -``` - -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). - -## Unit tests - -Tests are defined in the `tests` folder in this project. - -```bash -{{ cookiecutter.project_name }}$ ruby tests/unit/test_handler.rb -``` - -## Cleanup - -To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: - -```bash -sam delete --stack-name {{ cookiecutter.project_name }} -``` - -## Resources - -See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. - -Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) diff --git a/ruby2.7/hello/{{cookiecutter.project_name}}/events/event.json b/ruby2.7/hello/{{cookiecutter.project_name}}/events/event.json deleted file mode 100644 index 070ad8e01..000000000 --- a/ruby2.7/hello/{{cookiecutter.project_name}}/events/event.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "body": "{\"message\": \"hello world\"}", - "resource": "/{proxy+}", - "path": "/path/to/resource", - "httpMethod": "POST", - "isBase64Encoded": false, - "queryStringParameters": { - "foo": "bar" - }, - "pathParameters": { - "proxy": "/path/to/resource" - }, - "stageVariables": { - "baz": "qux" - }, - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8", - "Cache-Control": "max-age=0", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "1234567890.execute-api.us-east-1.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Custom User Agent String", - "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", - "X-Forwarded-For": "127.0.0.1, 127.0.0.2", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "requestContext": { - "accountId": "123456789012", - "resourceId": "123456", - "stage": "prod", - "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", - "requestTime": "09/Apr/2015:12:34:56 +0000", - "requestTimeEpoch": 1428582896000, - "identity": { - "cognitoIdentityPoolId": null, - "accountId": null, - "cognitoIdentityId": null, - "caller": null, - "accessKey": null, - "sourceIp": "127.0.0.1", - "cognitoAuthenticationType": null, - "cognitoAuthenticationProvider": null, - "userArn": null, - "userAgent": "Custom User Agent String", - "user": null - }, - "path": "/prod/path/to/resource", - "resourcePath": "/{proxy+}", - "httpMethod": "POST", - "apiId": "1234567890", - "protocol": "HTTP/1.1" - } -} diff --git a/ruby2.7/hello/{{cookiecutter.project_name}}/hello_world/Gemfile b/ruby2.7/hello/{{cookiecutter.project_name}}/hello_world/Gemfile deleted file mode 100644 index 8ba70fa68..000000000 --- a/ruby2.7/hello/{{cookiecutter.project_name}}/hello_world/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source "https://rubygems.org" - -gem "httparty" - -ruby '~> 2.7.0' diff --git a/ruby2.7/hello/{{cookiecutter.project_name}}/hello_world/app.rb b/ruby2.7/hello/{{cookiecutter.project_name}}/hello_world/app.rb deleted file mode 100644 index e2a102f70..000000000 --- a/ruby2.7/hello/{{cookiecutter.project_name}}/hello_world/app.rb +++ /dev/null @@ -1,38 +0,0 @@ -# require 'httparty' -require 'json' - -def lambda_handler(event:, context:) - # Sample pure Lambda function - - # Parameters - # ---------- - # event: Hash, required - # API Gateway Lambda Proxy Input Format - # Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format - - # context: object, required - # Lambda Context runtime methods and attributes - # Context doc: https://docs.aws.amazon.com/lambda/latest/dg/ruby-context.html - - # Returns - # ------ - # API Gateway Lambda Proxy Output Format: dict - # 'statusCode' and 'body' are required - # # api-gateway-simple-proxy-for-lambda-output-format - # Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html - - # begin - # response = HTTParty.get('http://checkip.amazonaws.com/') - # rescue HTTParty::Error => error - # puts error.inspect - # raise error - # end - - { - statusCode: 200, - body: { - message: "Hello World!", - # location: response.body - }.to_json - } -end diff --git a/ruby2.7/hello/{{cookiecutter.project_name}}/template.yaml b/ruby2.7/hello/{{cookiecutter.project_name}}/template.yaml deleted file mode 100644 index fb6464475..000000000 --- a/ruby2.7/hello/{{cookiecutter.project_name}}/template.yaml +++ /dev/null @@ -1,46 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: > - {{ cookiecutter.project_name }} - - Sample SAM Template for {{ cookiecutter.project_name }} - -# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst -Globals: - Function: - Timeout: 3 - MemorySize: 128 - -Resources: - HelloWorldFunction: - Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction - Properties: - CodeUri: hello_world/ - Handler: app.lambda_handler - Runtime: ruby2.7 - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - Events: - HelloWorld: - Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api - Properties: - Path: /hello - Method: get - -Outputs: - # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function - # Find out more about other implicit resources you can reference within SAM - # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api - HelloWorldApi: - Description: "API Gateway endpoint URL for Prod stage for Hello World function" - Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/" - HelloWorldFunction: - Description: "Hello World Lambda Function ARN" - Value: !GetAtt HelloWorldFunction.Arn - HelloWorldFunctionIamRole: - Description: "Implicit IAM Role created for Hello World function" - Value: !GetAtt HelloWorldFunctionRole.Arn diff --git a/ruby2.7/hello/{{cookiecutter.project_name}}/tests/unit/test_handler.rb b/ruby2.7/hello/{{cookiecutter.project_name}}/tests/unit/test_handler.rb deleted file mode 100644 index 5df8201b7..000000000 --- a/ruby2.7/hello/{{cookiecutter.project_name}}/tests/unit/test_handler.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'json' -require 'test/unit' -require 'mocha/test_unit' -require 'httparty' - -require_relative '../../hello_world/app' - -class HelloWorldTest < Test::Unit::TestCase - def event - { - body: 'eyJ0ZXN0IjoiYm9keSJ9', - resource: '/{proxy+}', - path: '/path/to/resource', - httpMethod: 'POST', - isBase64Encoded: true, - queryStringParameters: { - foo: 'bar' - }, - pathParameters: { - proxy: '/path/to/resource' - }, - stageVariables: { - baz: 'qux' - }, - headers: { - 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', - 'Accept-Encoding' => 'gzip, deflate, sdch', - 'Accept-Language' => 'en-US,en;q=0.8', - 'Cache-Control' => 'max-age=0', - 'CloudFront-Forwarded-Proto' => 'https', - 'CloudFront-Is-Desktop-Viewer' => 'true', - 'CloudFront-Is-Mobile-Viewer' => 'false', - 'CloudFront-Is-SmartTV-Viewer' => 'false', - 'CloudFront-Is-Tablet-Viewer' => 'false', - 'CloudFront-Viewer-Country' => 'US', - 'Host' => '1234567890.execute-api.us-east-1.amazonaws.com', - 'Upgrade-Insecure-Requests' => '1', - 'User-Agent' => 'Custom User Agent String', - 'Via' => '1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)', - 'X-Amz-Cf-Id' => 'cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==', - 'X-Forwarded-For' => '127.0.0.1, 127.0.0.2', - 'X-Forwarded-Port' => '443', - 'X-Forwarded-Proto' => 'https' - }, - requestContext: { - accountId: '123456789012', - resourceId: '123456', - stage: 'prod', - requestId: 'c6af9ac6-7b61-11e6-9a41-93e8deadbeef', - requestTime: '09/Apr/2015:12:34:56 +0000', - requestTimeEpoch: 1428582896000, - identity: { - cognitoIdentityPoolId: 'null', - accountId: 'null', - cognitoIdentityId: 'null', - caller: 'null', - accessKey: 'null', - sourceIp: '127.0.0.1', - cognitoAuthenticationType: 'null', - cognitoAuthenticationProvider: 'null', - userArn: 'null', - userAgent: 'Custom User Agent String', - user: 'null' - }, - path: '/prod/path/to/resource', - resourcePath: '/{proxy+}', - httpMethod: 'POST', - apiId: '1234567890', - protocol: 'HTTP/1.1' - } - } - end - - def mock_response - Object.new.tap do |mock| - mock.expects(:code).returns(200) - mock.expects(:body).returns('1.1.1.1') - end - end - - def expected_result - { - statusCode: 200, - body: { - message: 'Hello World!', -# location: '1.1.1.1' - }.to_json - } - end - - def test_lambda_handler -# HTTParty.expects(:get).with('http://checkip.amazonaws.com/').returns(mock_response) - assert_equal(lambda_handler(event: event, context: ''), expected_result) - end -end diff --git a/ruby2.7/step-func/.gitignore b/ruby2.7/step-func/.gitignore deleted file mode 100644 index 41bcace31..000000000 --- a/ruby2.7/step-func/.gitignore +++ /dev/null @@ -1,229 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam diff --git a/ruby2.7/step-func/README.md b/ruby2.7/step-func/README.md deleted file mode 100644 index 347f506b7..000000000 --- a/ruby2.7/step-func/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Cookiecutter Ruby Step Functions Sample App (Stock Trader) for SAM based Serverless App - -A cookiecutter template to create a Ruby Step Functions Sample App (Stock Trader) boilerplate using [Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model). - -This application creates a mock stock trading workflow which runs on a pre-defined schedule. It demonstrates the power of Step Functions to orchestrate Lambda functions and other AWS resources to form complex and robust workflows, coupled with event-driven development using Amazon EventBridge. - -## Requirements - -* [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) - -## Usage - -Generate a boilerplate template in your current project directory using the following syntax: - -* **Ruby 2.7**: `sam init --runtime ruby2.7` - -> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default) - - -# Credits - -* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter) diff --git a/ruby2.7/step-func/cookiecutter.json b/ruby2.7/step-func/cookiecutter.json deleted file mode 100644 index 3e05d04e7..000000000 --- a/ruby2.7/step-func/cookiecutter.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "project_name": "Name of the project", - "runtime": "ruby2.7", - "architectures": { - "value": [ - "x86_64", "arm64" - ] - }, - "_copy_without_render": [ - ".gitignore" - ] -} \ No newline at end of file diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/.gitignore b/ruby2.7/step-func/{{cookiecutter.project_name}}/.gitignore deleted file mode 100644 index 4bccb52c8..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/.gitignore +++ /dev/null @@ -1,345 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,pycharm,visualstudiocode,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history -.ionide - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/Gemfile b/ruby2.7/step-func/{{cookiecutter.project_name}}/Gemfile deleted file mode 100644 index d9d41b7d5..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/Gemfile +++ /dev/null @@ -1,6 +0,0 @@ -source "https://rubygems.org" - -group :test do - gem "test-unit" - gem "mocha" -end diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/README.md b/ruby2.7/step-func/{{cookiecutter.project_name}}/README.md deleted file mode 100644 index 7100d673a..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/README.md +++ /dev/null @@ -1,104 +0,0 @@ -# {{ cookiecutter.project_name }} - -This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders: - -- functions - Code for the application's Lambda functions to check the value of, buy, or sell shares of a stock. -- statemachines - Definition for the state machine that orchestrates the stock trading workflow. -- tests - Unit tests for the Lambda functions' application code. -- template.yaml - A template that defines the application's AWS resources. - -This application creates a mock stock trading workflow which runs on a pre-defined schedule (note that the schedule is disabled by default to avoid incurring charges). It demonstrates the power of Step Functions to orchestrate Lambda functions and other AWS resources to form complex and robust workflows, coupled with event-driven development using Amazon EventBridge. - -AWS Step Functions lets you coordinate multiple AWS services into serverless workflows so you can build and update apps quickly. Using Step Functions, you can design and run workflows that stitch together services, such as AWS Lambda, AWS Fargate, and Amazon SageMaker, into feature-rich applications. - -The application uses several AWS resources, including Step Functions state machines, Lambda functions and an EventBridge rule trigger. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - -If you prefer to use an integrated development environment (IDE) to build and test the Lambda functions within your application, you can use the AWS Toolkit. The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started: - -* [CLion](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [GoLand](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [WebStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [Rider](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [PhpStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [RubyMine](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [DataGrip](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html) -* [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html) - -The AWS Toolkit for VS Code includes full support for state machine visualization, enabling you to visualize your state machine in real time as you build. The AWS Toolkit for VS Code includes a language server for Amazon States Language, which lints your state machine definition to highlight common errors, provides auto-complete support, and code snippets for each state, enabling you to build state machines faster. - -## Deploy the sample application - -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. - -To use the SAM CLI, you need the following tools: - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Ruby - [Install Ruby 2.7](https://www.ruby-lang.org/en/documentation/installation/) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` - -The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your State Machine ARN in the output values displayed after deployment. - -## Use the SAM CLI to build and test locally - -Build the Lambda functions in your application with the `sam build --use-container` command. - -```bash -{{ cookiecutter.project_name }}$ sam build -``` - -The SAM CLI installs dependencies defined in `functions/*/Gemfile`, creates a deployment package, and saves it in the `.aws-sam/build` folder. - -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. - -## Fetch, tail, and filter Lambda function logs - -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. - -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. - -```bash -{{ cookiecutter.project_name }}$ sam logs -n StockCheckerFunction --stack-name {{ cookiecutter.project_name }} --tail -``` - -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). - -## Unit tests - -Tests for the Lambda functions are defined in the `tests` folder in this project. - -```bash -{{ cookiecutter.project_name }}$ ruby tests/unit/test_stock_checker.rb -``` - -## Cleanup - -To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: - -```bash -sam delete --stack-name {{ cookiecutter.project_name }} -``` - -## Resources - -See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. - -Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/Gemfile b/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/Gemfile deleted file mode 100644 index 620aaa62f..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" - -ruby '~> 2.7.0' diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/app.rb b/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/app.rb deleted file mode 100644 index 33d1aa04b..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/app.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'json' -require 'securerandom' -require 'date' - -def lambda_handler(event:, context:) - # Sample Lambda function which mocks the operation of buying a random number - # of shares for a stock. - - # For demonstration purposes, this Lambda function does not actually perform any - # actual transactions. It simply returns a mocked result. - - # Parameters - # ---------- - # event: Hash, required - # Input event to the Lambda function - - # context: object, required - # Lambda Context runtime methods and attributes - - # Returns - # ------ - # dict: Object containing details of the stock buying transaction - - # Get the price of the stock provided as input - stock_price = event["stock_price"] - # Mocked result of a stock buying transaction - { - id: SecureRandom.uuid, # Unique ID for the transaction - price: stock_price.to_s, # Price of each share - type: "buy", # Type of transaction (buy/sell) - qty: rand(1...10).to_s, # Number of shares bought/sold (We are mocking this as a random integer between 1 and 10) - timestamp: DateTime.now.iso8601, # Timestamp of the when the transaction was completed - } -end diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_checker/Gemfile b/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_checker/Gemfile deleted file mode 100644 index 620aaa62f..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_checker/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" - -ruby '~> 2.7.0' diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_checker/app.rb b/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_checker/app.rb deleted file mode 100644 index de6e2e28d..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_checker/app.rb +++ /dev/null @@ -1,23 +0,0 @@ -def lambda_handler(event:, context:) - # Sample Lambda function which mocks the operation of checking the current price - # of a stock. - - # For demonstration purposes this Lambda function simply returns - # a random integer between 0 and 100 as the stock price. - - # Parameters - # ---------- - # event: Hash, required - # Input event to the Lambda function - - # context: object, required - # Lambda Context runtime methods and attributes - - # Returns - # ------ - # dict: Object containing the current price of the stock - - # Check current price of the stock - stock_price = rand(0...100) # Current stock price is mocked as a random integer between 0 and 100 - { stock_price: stock_price } -end diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_seller/Gemfile b/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_seller/Gemfile deleted file mode 100644 index 620aaa62f..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_seller/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" - -ruby '~> 2.7.0' diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_seller/app.rb b/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_seller/app.rb deleted file mode 100644 index ef49ab38f..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/functions/stock_seller/app.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'securerandom' -require 'date' - -def lambda_handler(event:, context:) - # Sample Lambda function which mocks the operation of selling a random number - # of shares for a stock. - - # For demonstration purposes, this Lambda function does not actually perform any - # actual transactions. It simply returns a mocked result. - - # Parameters - # ---------- - # event: Hash, required - # Input event to the Lambda function - - # context: object, required - # Lambda Context runtime methods and attributes - - # Returns - # ------ - # dict: Object containing details of the stock selling transaction - - # Get the price of the stock provided as input - stock_price = event["stock_price"] - # Mocked result of a stock buying transaction - { - id: SecureRandom.uuid, # Unique ID for the transaction - price: stock_price.to_s, # Price of each share - type: "sell", # Type of transaction (buy/sell) - qty: rand(1...10).to_s, # Number of shares bought/sold (We are mocking this as a random integer between 1 and 10) - timestamp: DateTime.now.iso8601, # Timestamp of the when the transaction was completed - } -end diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/statemachine/stock_trader.asl.json b/ruby2.7/step-func/{{cookiecutter.project_name}}/statemachine/stock_trader.asl.json deleted file mode 100644 index ea6a0ceb7..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/statemachine/stock_trader.asl.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "Comment": "A state machine that does mock stock trading.", - "StartAt": "Check Stock Value", - "States": { - "Check Stock Value": { - "Type": "Task", - "Resource": "${StockCheckerFunctionArn}", - "Retry": [ - { - "ErrorEquals": [ - "States.TaskFailed" - ], - "IntervalSeconds": 15, - "MaxAttempts": 5, - "BackoffRate": 1.5 - } - ], - "Next": "Buy or Sell?" - }, - "Buy or Sell?": { - "Type": "Choice", - "Choices": [ - { - "Variable": "$.stock_price", - "NumericLessThanEquals": 50, - "Next": "Buy Stock" - } - ], - "Default": "Sell Stock" - }, - "Sell Stock": { - "Type": "Task", - "Resource": "${StockSellerFunctionArn}", - "Retry": [ - { - "ErrorEquals": [ - "States.TaskFailed" - ], - "IntervalSeconds": 2, - "MaxAttempts": 3, - "BackoffRate": 1 - } - ], - "Next": "Record Transaction" - }, - "Buy Stock": { - "Type": "Task", - "Resource": "${StockBuyerFunctionArn}", - "Retry": [ - { - "ErrorEquals": [ - "States.TaskFailed" - ], - "IntervalSeconds": 2, - "MaxAttempts": 3, - "BackoffRate": 1 - } - ], - "Next": "Record Transaction" - }, - "Record Transaction": { - "Type": "Task", - "Resource": "${DDBPutItem}", - "Parameters": { - "TableName": "${DDBTable}", - "Item": { - "Id": { - "S.$": "$.id" - }, - "Type": { - "S.$": "$.type" - }, - "Price": { - "N.$": "$.price" - }, - "Timestamp": { - "S.$": "$.timestamp" - } - } - }, - "Retry": [ - { - "ErrorEquals": [ - "States.TaskFailed" - ], - "IntervalSeconds": 20, - "MaxAttempts": 5, - "BackoffRate": 10 - } - ], - "End": true - } - } -} \ No newline at end of file diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/template.yaml b/ruby2.7/step-func/{{cookiecutter.project_name}}/template.yaml deleted file mode 100644 index 60027d6da..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/template.yaml +++ /dev/null @@ -1,94 +0,0 @@ -AWSTemplateFormatVersion: "2010-09-09" -Transform: AWS::Serverless-2016-10-31 -Description: > - {{ cookiecutter.project_name }} - - Sample SAM Template for {{ cookiecutter.project_name }} - -Resources: - StockTradingStateMachine: - Type: AWS::Serverless::StateMachine # More info about State Machine Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html - Properties: - DefinitionUri: statemachine/stock_trader.asl.json - DefinitionSubstitutions: - StockCheckerFunctionArn: !GetAtt StockCheckerFunction.Arn - StockSellerFunctionArn: !GetAtt StockSellerFunction.Arn - StockBuyerFunctionArn: !GetAtt StockBuyerFunction.Arn - DDBPutItem: !Sub arn:${AWS::Partition}:states:::dynamodb:putItem - DDBTable: !Ref TransactionTable - Events: - HourlyTradingSchedule: - Type: Schedule # More info about Schedule Event Source: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-statemachine-schedule.html - Properties: - Description: Schedule to run the stock trading state machine every hour - Enabled: False # This schedule is disabled by default to avoid incurring charges. - Schedule: "rate(1 hour)" - Policies: # Find out more about SAM policy templates: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html - - LambdaInvokePolicy: - FunctionName: !Ref StockCheckerFunction - - LambdaInvokePolicy: - FunctionName: !Ref StockSellerFunction - - LambdaInvokePolicy: - FunctionName: !Ref StockBuyerFunction - - DynamoDBWritePolicy: - TableName: !Ref TransactionTable - - StockCheckerFunction: - Type: AWS::Serverless::Function # More info about Function Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html - Properties: - CodeUri: functions/stock_checker/ - Handler: app.lambda_handler - Runtime: ruby2.7 - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - - StockSellerFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: functions/stock_seller/ - Handler: app.lambda_handler - Runtime: ruby2.7 - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - - StockBuyerFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: functions/stock_buyer/ - Handler: app.lambda_handler - Runtime: ruby2.7 - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - - TransactionTable: - Type: AWS::Serverless::SimpleTable # More info about SimpleTable Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-simpletable.html - Properties: - PrimaryKey: - Name: Id - Type: String - ProvisionedThroughput: - ReadCapacityUnits: 1 - WriteCapacityUnits: 1 - -Outputs: - # StockTradingStateMachineHourlyTradingSchedule is an implicit Schedule event rule created out of Events key under Serverless::StateMachine - # Find out more about other implicit resources you can reference within SAM - # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html - StockTradingStateMachineArn: - Description: "Stock Trading state machine ARN" - Value: !Ref StockTradingStateMachine - StockTradingStateMachineRole: - Description: "IAM Role created for Stock Trading state machine based on the specified SAM Policy Templates" - Value: !GetAtt StockTradingStateMachineRole.Arn diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_buyer.rb b/ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_buyer.rb deleted file mode 100644 index b26b7c285..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_buyer.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'test/unit' - -require_relative '../../functions/stock_buyer/app' - -class StockBuyerTest < Test::Unit::TestCase - def test_lambda_handler - stock_price = 75 - input_payload = { - 'stock_price' => stock_price - } - result = lambda_handler(event: input_payload, context: '') - assert_true(result.key?(:id)) - assert_true(result.key?(:timestamp)) - assert_true(result.key?(:qty)) - - assert_equal("buy", result[:type]) - assert_equal(stock_price.to_s, result[:price]) - end -end diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_checker.rb b/ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_checker.rb deleted file mode 100644 index 80d164a56..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_checker.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'test/unit' - -require_relative '../../functions/stock_checker/app' - -class StockCheckerTest < Test::Unit::TestCase - def test_lambda_handler - result = lambda_handler(event: nil, context: '') - stock_price = result[:stock_price] - assert_true(stock_price.between?(0, 100)) - end -end diff --git a/ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_seller.rb b/ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_seller.rb deleted file mode 100644 index 2e2c2887d..000000000 --- a/ruby2.7/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_seller.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'test/unit' - -require_relative '../../functions/stock_seller/app' - -class StockSellerTest < Test::Unit::TestCase - def test_lambda_handler - stock_price = 25 - input_payload = { - "stock_price" => stock_price - } - result = lambda_handler(event: input_payload, context: '') - assert_true(result.key?(:id)) - assert_true(result.key?(:timestamp)) - assert_true(result.key?(:qty)) - - assert_equal("sell", result[:type]) - assert_equal(stock_price.to_s, result[:price]) - end -end diff --git a/ruby3.2/hello-img/.gitignore b/ruby3.2/hello-img/.gitignore deleted file mode 100644 index 41bcace31..000000000 --- a/ruby3.2/hello-img/.gitignore +++ /dev/null @@ -1,229 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam diff --git a/ruby3.2/hello-img/README.md b/ruby3.2/hello-img/README.md deleted file mode 100644 index 536366420..000000000 --- a/ruby3.2/hello-img/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Cookiecutter Ruby Hello-world for SAM based Serverless App - -A cookiecutter template to create a Ruby Hello world boilerplate using [Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model). - -## Requirements - -* [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) - -## Usage - -Generate a boilerplate template in your current project directory using the following syntax: - -* **Ruby 3.2**: `sam init --runtime ruby3.2` - -> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default) - - -# Credits - -* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter) diff --git a/ruby3.2/hello-img/cookiecutter.json b/ruby3.2/hello-img/cookiecutter.json deleted file mode 100644 index 10dc222b0..000000000 --- a/ruby3.2/hello-img/cookiecutter.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "project_name": "Name of the project", - "runtime": "ruby3.2", - "architectures": { - "value": [ - "x86_64", "arm64" - ] - }, - "_copy_without_render": [ - ".gitignore" - ] -} diff --git a/ruby3.2/hello-img/{{cookiecutter.project_name}}/.gitignore b/ruby3.2/hello-img/{{cookiecutter.project_name}}/.gitignore deleted file mode 100644 index 4bccb52c8..000000000 --- a/ruby3.2/hello-img/{{cookiecutter.project_name}}/.gitignore +++ /dev/null @@ -1,345 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,pycharm,visualstudiocode,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history -.ionide - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam diff --git a/ruby3.2/hello-img/{{cookiecutter.project_name}}/Gemfile b/ruby3.2/hello-img/{{cookiecutter.project_name}}/Gemfile deleted file mode 100644 index b566789df..000000000 --- a/ruby3.2/hello-img/{{cookiecutter.project_name}}/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -gem "httparty" - -group :test do - gem "test-unit" - gem "mocha" -end diff --git a/ruby3.2/hello-img/{{cookiecutter.project_name}}/README.md b/ruby3.2/hello-img/{{cookiecutter.project_name}}/README.md deleted file mode 100644 index bae8a6e7f..000000000 --- a/ruby3.2/hello-img/{{cookiecutter.project_name}}/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# {{ cookiecutter.project_name }} - -This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders. - -- hello_world - Code for the application's Lambda function and Project Dockerfile. -- events - Invocation events that you can use to invoke the function. -- tests - Unit tests for the application code. -- template.yaml - A template that defines the application's AWS resources. - -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - -## Deploy the sample application - -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. - -To use the SAM CLI, you need the following tools. - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -You may need the following for local testing. -* Ruby - [Install Ruby 3.2](https://www.ruby-lang.org/en/documentation/installation/) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` - -The first command will build a docker image from a Dockerfile and then copy the source of your application inside the Docker image. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your API Gateway Endpoint URL in the output values displayed after deployment. - -## Use the SAM CLI to build and test locally - -Build your application with the `sam build` command. - -```bash -{{ cookiecutter.project_name }}$ sam build -``` - -The SAM CLI builds a docker image from a Dockerfile and then installs dependencies defined in `hello_world/Gemfile` inside the docker image. The processed template file is saved in the `.aws-sam/build` folder. - -Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project. - -Run functions locally and invoke them with the `sam local invoke` command. - -```bash -{{ cookiecutter.project_name }}$ sam local invoke HelloWorldFunction --event events/event.json -``` - -The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000. - -```bash -{{ cookiecutter.project_name }}$ sam local start-api -{{ cookiecutter.project_name }}$ curl http://localhost:3000/ -``` - -The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path. - -```yaml - Events: - HelloWorld: - Type: Api - Properties: - Path: /hello - Method: get -``` - -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. - -## Fetch, tail, and filter Lambda function logs - -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. - -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. - -```bash -{{ cookiecutter.project_name }}$ sam logs -n HelloWorldFunction --stack-name {{ cookiecutter.project_name }} --tail -``` - -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). - -## Unit tests - -Tests are defined in the `tests` folder in this project. - -```bash -{{ cookiecutter.project_name }}$ ruby tests/unit/test_handler.rb -``` - -## Cleanup - -To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: - -```bash -sam delete --stack-name {{ cookiecutter.project_name }} -``` - -## Resources - -See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. - -Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) diff --git a/ruby3.2/hello-img/{{cookiecutter.project_name}}/events/event.json b/ruby3.2/hello-img/{{cookiecutter.project_name}}/events/event.json deleted file mode 100644 index 070ad8e01..000000000 --- a/ruby3.2/hello-img/{{cookiecutter.project_name}}/events/event.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "body": "{\"message\": \"hello world\"}", - "resource": "/{proxy+}", - "path": "/path/to/resource", - "httpMethod": "POST", - "isBase64Encoded": false, - "queryStringParameters": { - "foo": "bar" - }, - "pathParameters": { - "proxy": "/path/to/resource" - }, - "stageVariables": { - "baz": "qux" - }, - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8", - "Cache-Control": "max-age=0", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "1234567890.execute-api.us-east-1.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Custom User Agent String", - "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", - "X-Forwarded-For": "127.0.0.1, 127.0.0.2", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "requestContext": { - "accountId": "123456789012", - "resourceId": "123456", - "stage": "prod", - "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", - "requestTime": "09/Apr/2015:12:34:56 +0000", - "requestTimeEpoch": 1428582896000, - "identity": { - "cognitoIdentityPoolId": null, - "accountId": null, - "cognitoIdentityId": null, - "caller": null, - "accessKey": null, - "sourceIp": "127.0.0.1", - "cognitoAuthenticationType": null, - "cognitoAuthenticationProvider": null, - "userArn": null, - "userAgent": "Custom User Agent String", - "user": null - }, - "path": "/prod/path/to/resource", - "resourcePath": "/{proxy+}", - "httpMethod": "POST", - "apiId": "1234567890", - "protocol": "HTTP/1.1" - } -} diff --git a/ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/Dockerfile b/ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/Dockerfile deleted file mode 100644 index 8c52f4b96..000000000 --- a/ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM public.ecr.aws/lambda/ruby:3.2 - -COPY app.rb Gemfile ./ - -ENV GEM_HOME=${LAMBDA_TASK_ROOT} -RUN bundle install - -# Command can be overwritten by providing a different command in the template directly. -CMD ["app.lambda_handler"] diff --git a/ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/Gemfile b/ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/Gemfile deleted file mode 100644 index 7023beb4a..000000000 --- a/ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source "https://rubygems.org" - -gem "httparty" - -ruby '~> 3.2.0' diff --git a/ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/app.rb b/ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/app.rb deleted file mode 100644 index e2a102f70..000000000 --- a/ruby3.2/hello-img/{{cookiecutter.project_name}}/hello_world/app.rb +++ /dev/null @@ -1,38 +0,0 @@ -# require 'httparty' -require 'json' - -def lambda_handler(event:, context:) - # Sample pure Lambda function - - # Parameters - # ---------- - # event: Hash, required - # API Gateway Lambda Proxy Input Format - # Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format - - # context: object, required - # Lambda Context runtime methods and attributes - # Context doc: https://docs.aws.amazon.com/lambda/latest/dg/ruby-context.html - - # Returns - # ------ - # API Gateway Lambda Proxy Output Format: dict - # 'statusCode' and 'body' are required - # # api-gateway-simple-proxy-for-lambda-output-format - # Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html - - # begin - # response = HTTParty.get('http://checkip.amazonaws.com/') - # rescue HTTParty::Error => error - # puts error.inspect - # raise error - # end - - { - statusCode: 200, - body: { - message: "Hello World!", - # location: response.body - }.to_json - } -end diff --git a/ruby3.2/hello-img/{{cookiecutter.project_name}}/template.yaml b/ruby3.2/hello-img/{{cookiecutter.project_name}}/template.yaml deleted file mode 100644 index 18e72aab2..000000000 --- a/ruby3.2/hello-img/{{cookiecutter.project_name}}/template.yaml +++ /dev/null @@ -1,48 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: > - {{ cookiecutter.project_name }} - - Sample SAM Template for {{ cookiecutter.project_name }} - -# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst -Globals: - Function: - Timeout: 3 - MemorySize: 128 - -Resources: - HelloWorldFunction: - Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction - Properties: - PackageType: Image - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - Events: - HelloWorld: - Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api - Properties: - Path: /hello - Method: get - Metadata: - DockerTag: {{cookiecutter.runtime}}-v1 - DockerContext: ./hello_world - Dockerfile: Dockerfile - -Outputs: - # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function - # Find out more about other implicit resources you can reference within SAM - # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api - HelloWorldApi: - Description: "API Gateway endpoint URL for Prod stage for Hello World function" - Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/" - HelloWorldFunction: - Description: "Hello World Lambda Function ARN" - Value: !GetAtt HelloWorldFunction.Arn - HelloWorldFunctionIamRole: - Description: "Implicit IAM Role created for Hello World function" - Value: !GetAtt HelloWorldFunctionRole.Arn diff --git a/ruby3.2/hello-img/{{cookiecutter.project_name}}/tests/unit/test_handler.rb b/ruby3.2/hello-img/{{cookiecutter.project_name}}/tests/unit/test_handler.rb deleted file mode 100644 index df66b969a..000000000 --- a/ruby3.2/hello-img/{{cookiecutter.project_name}}/tests/unit/test_handler.rb +++ /dev/null @@ -1,94 +0,0 @@ -require 'json' -require 'test/unit' -require 'mocha/test_unit' - -require_relative '../../hello_world/app' - -class HelloWorldTest < Test::Unit::TestCase - def event - { - body: 'eyJ0ZXN0IjoiYm9keSJ9', - resource: '/{proxy+}', - path: '/path/to/resource', - httpMethod: 'POST', - isBase64Encoded: true, - queryStringParameters: { - foo: 'bar' - }, - pathParameters: { - proxy: '/path/to/resource' - }, - stageVariables: { - baz: 'qux' - }, - headers: { - 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', - 'Accept-Encoding' => 'gzip, deflate, sdch', - 'Accept-Language' => 'en-US,en;q=0.8', - 'Cache-Control' => 'max-age=0', - 'CloudFront-Forwarded-Proto' => 'https', - 'CloudFront-Is-Desktop-Viewer' => 'true', - 'CloudFront-Is-Mobile-Viewer' => 'false', - 'CloudFront-Is-SmartTV-Viewer' => 'false', - 'CloudFront-Is-Tablet-Viewer' => 'false', - 'CloudFront-Viewer-Country' => 'US', - 'Host' => '1234567890.execute-api.us-east-1.amazonaws.com', - 'Upgrade-Insecure-Requests' => '1', - 'User-Agent' => 'Custom User Agent String', - 'Via' => '1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)', - 'X-Amz-Cf-Id' => 'cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==', - 'X-Forwarded-For' => '127.0.0.1, 127.0.0.2', - 'X-Forwarded-Port' => '443', - 'X-Forwarded-Proto' => 'https' - }, - requestContext: { - accountId: '123456789012', - resourceId: '123456', - stage: 'prod', - requestId: 'c6af9ac6-7b61-11e6-9a41-93e8deadbeef', - requestTime: '09/Apr/2015:12:34:56 +0000', - requestTimeEpoch: 1428582896000, - identity: { - cognitoIdentityPoolId: 'null', - accountId: 'null', - cognitoIdentityId: 'null', - caller: 'null', - accessKey: 'null', - sourceIp: '127.0.0.1', - cognitoAuthenticationType: 'null', - cognitoAuthenticationProvider: 'null', - userArn: 'null', - userAgent: 'Custom User Agent String', - user: 'null' - }, - path: '/prod/path/to/resource', - resourcePath: '/{proxy+}', - httpMethod: 'POST', - apiId: '1234567890', - protocol: 'HTTP/1.1' - } - } - end - - def mock_response - Object.new.tap do |mock| - mock.expects(:code).returns(200) - mock.expects(:body).returns('1.1.1.1') - end - end - - def expected_result - { - statusCode: 200, - body: { - message: 'Hello World!', - location: '1.1.1.1' - }.to_json - } - end - - def test_lambda_handler - HTTParty.expects(:get).with('http://checkip.amazonaws.com/').returns(mock_response) - assert_equal(lambda_handler(event: event, context: ''), expected_result) - end -end diff --git a/ruby3.2/hello/.gitignore b/ruby3.2/hello/.gitignore deleted file mode 100644 index 41bcace31..000000000 --- a/ruby3.2/hello/.gitignore +++ /dev/null @@ -1,229 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam diff --git a/ruby3.2/hello/README.md b/ruby3.2/hello/README.md deleted file mode 100644 index 536366420..000000000 --- a/ruby3.2/hello/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Cookiecutter Ruby Hello-world for SAM based Serverless App - -A cookiecutter template to create a Ruby Hello world boilerplate using [Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model). - -## Requirements - -* [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) - -## Usage - -Generate a boilerplate template in your current project directory using the following syntax: - -* **Ruby 3.2**: `sam init --runtime ruby3.2` - -> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default) - - -# Credits - -* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter) diff --git a/ruby3.2/hello/cookiecutter.json b/ruby3.2/hello/cookiecutter.json deleted file mode 100644 index 10dc222b0..000000000 --- a/ruby3.2/hello/cookiecutter.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "project_name": "Name of the project", - "runtime": "ruby3.2", - "architectures": { - "value": [ - "x86_64", "arm64" - ] - }, - "_copy_without_render": [ - ".gitignore" - ] -} diff --git a/ruby3.2/hello/{{cookiecutter.project_name}}/.gitignore b/ruby3.2/hello/{{cookiecutter.project_name}}/.gitignore deleted file mode 100644 index 4bccb52c8..000000000 --- a/ruby3.2/hello/{{cookiecutter.project_name}}/.gitignore +++ /dev/null @@ -1,345 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,pycharm,visualstudiocode,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history -.ionide - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam diff --git a/ruby3.2/hello/{{cookiecutter.project_name}}/Gemfile b/ruby3.2/hello/{{cookiecutter.project_name}}/Gemfile deleted file mode 100644 index b566789df..000000000 --- a/ruby3.2/hello/{{cookiecutter.project_name}}/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -gem "httparty" - -group :test do - gem "test-unit" - gem "mocha" -end diff --git a/ruby3.2/hello/{{cookiecutter.project_name}}/README.md b/ruby3.2/hello/{{cookiecutter.project_name}}/README.md deleted file mode 100644 index 510c59603..000000000 --- a/ruby3.2/hello/{{cookiecutter.project_name}}/README.md +++ /dev/null @@ -1,125 +0,0 @@ -# {{ cookiecutter.project_name }} - -This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders. - -- hello_world - Code for the application's Lambda function. -- events - Invocation events that you can use to invoke the function. -- tests - Unit tests for the application code. -- template.yaml - A template that defines the application's AWS resources. - -The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - -If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit. -The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started. - -* [CLion](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [GoLand](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [WebStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [Rider](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [PhpStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [RubyMine](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [DataGrip](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html) -* [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html) - -## Deploy the sample application - -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. - -To use the SAM CLI, you need the following tools. - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Ruby - [Install Ruby 3.2](https://www.ruby-lang.org/en/documentation/installation/) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` - -The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your API Gateway Endpoint URL in the output values displayed after deployment. - -## Use the SAM CLI to build and test locally - -Build your application with the `sam build` command. - -```bash -{{ cookiecutter.project_name }}$ sam build -``` - -The SAM CLI installs dependencies defined in `hello_world/Gemfile`, creates a deployment package, and saves it in the `.aws-sam/build` folder. - -Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project. - -Run functions locally and invoke them with the `sam local invoke` command. - -```bash -{{ cookiecutter.project_name }}$ sam local invoke HelloWorldFunction --event events/event.json -``` - -The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000. - -```bash -{{ cookiecutter.project_name }}$ sam local start-api -{{ cookiecutter.project_name }}$ curl http://localhost:3000/ -``` - -The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path. - -```yaml - Events: - HelloWorld: - Type: Api - Properties: - Path: /hello - Method: get -``` - -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. - -## Fetch, tail, and filter Lambda function logs - -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. - -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. - -```bash -{{ cookiecutter.project_name }}$ sam logs -n HelloWorldFunction --stack-name {{ cookiecutter.project_name }} --tail -``` - -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). - -## Unit tests - -Tests are defined in the `tests` folder in this project. - -```bash -{{ cookiecutter.project_name }}$ ruby tests/unit/test_handler.rb -``` - -## Cleanup - -To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: - -```bash -sam delete --stack-name {{ cookiecutter.project_name }} -``` - -## Resources - -See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. - -Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) diff --git a/ruby3.2/hello/{{cookiecutter.project_name}}/events/event.json b/ruby3.2/hello/{{cookiecutter.project_name}}/events/event.json deleted file mode 100644 index 070ad8e01..000000000 --- a/ruby3.2/hello/{{cookiecutter.project_name}}/events/event.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "body": "{\"message\": \"hello world\"}", - "resource": "/{proxy+}", - "path": "/path/to/resource", - "httpMethod": "POST", - "isBase64Encoded": false, - "queryStringParameters": { - "foo": "bar" - }, - "pathParameters": { - "proxy": "/path/to/resource" - }, - "stageVariables": { - "baz": "qux" - }, - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8", - "Cache-Control": "max-age=0", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "1234567890.execute-api.us-east-1.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Custom User Agent String", - "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", - "X-Forwarded-For": "127.0.0.1, 127.0.0.2", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "requestContext": { - "accountId": "123456789012", - "resourceId": "123456", - "stage": "prod", - "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", - "requestTime": "09/Apr/2015:12:34:56 +0000", - "requestTimeEpoch": 1428582896000, - "identity": { - "cognitoIdentityPoolId": null, - "accountId": null, - "cognitoIdentityId": null, - "caller": null, - "accessKey": null, - "sourceIp": "127.0.0.1", - "cognitoAuthenticationType": null, - "cognitoAuthenticationProvider": null, - "userArn": null, - "userAgent": "Custom User Agent String", - "user": null - }, - "path": "/prod/path/to/resource", - "resourcePath": "/{proxy+}", - "httpMethod": "POST", - "apiId": "1234567890", - "protocol": "HTTP/1.1" - } -} diff --git a/ruby3.2/hello/{{cookiecutter.project_name}}/hello_world/Gemfile b/ruby3.2/hello/{{cookiecutter.project_name}}/hello_world/Gemfile deleted file mode 100644 index 7023beb4a..000000000 --- a/ruby3.2/hello/{{cookiecutter.project_name}}/hello_world/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source "https://rubygems.org" - -gem "httparty" - -ruby '~> 3.2.0' diff --git a/ruby3.2/hello/{{cookiecutter.project_name}}/hello_world/app.rb b/ruby3.2/hello/{{cookiecutter.project_name}}/hello_world/app.rb deleted file mode 100644 index e2a102f70..000000000 --- a/ruby3.2/hello/{{cookiecutter.project_name}}/hello_world/app.rb +++ /dev/null @@ -1,38 +0,0 @@ -# require 'httparty' -require 'json' - -def lambda_handler(event:, context:) - # Sample pure Lambda function - - # Parameters - # ---------- - # event: Hash, required - # API Gateway Lambda Proxy Input Format - # Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format - - # context: object, required - # Lambda Context runtime methods and attributes - # Context doc: https://docs.aws.amazon.com/lambda/latest/dg/ruby-context.html - - # Returns - # ------ - # API Gateway Lambda Proxy Output Format: dict - # 'statusCode' and 'body' are required - # # api-gateway-simple-proxy-for-lambda-output-format - # Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html - - # begin - # response = HTTParty.get('http://checkip.amazonaws.com/') - # rescue HTTParty::Error => error - # puts error.inspect - # raise error - # end - - { - statusCode: 200, - body: { - message: "Hello World!", - # location: response.body - }.to_json - } -end diff --git a/ruby3.2/hello/{{cookiecutter.project_name}}/template.yaml b/ruby3.2/hello/{{cookiecutter.project_name}}/template.yaml deleted file mode 100644 index 42a7309e6..000000000 --- a/ruby3.2/hello/{{cookiecutter.project_name}}/template.yaml +++ /dev/null @@ -1,46 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: > - {{ cookiecutter.project_name }} - - Sample SAM Template for {{ cookiecutter.project_name }} - -# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst -Globals: - Function: - Timeout: 3 - MemorySize: 128 - -Resources: - HelloWorldFunction: - Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction - Properties: - CodeUri: hello_world/ - Handler: app.lambda_handler - Runtime: ruby3.2 - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - Events: - HelloWorld: - Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api - Properties: - Path: /hello - Method: get - -Outputs: - # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function - # Find out more about other implicit resources you can reference within SAM - # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api - HelloWorldApi: - Description: "API Gateway endpoint URL for Prod stage for Hello World function" - Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/" - HelloWorldFunction: - Description: "Hello World Lambda Function ARN" - Value: !GetAtt HelloWorldFunction.Arn - HelloWorldFunctionIamRole: - Description: "Implicit IAM Role created for Hello World function" - Value: !GetAtt HelloWorldFunctionRole.Arn diff --git a/ruby3.2/hello/{{cookiecutter.project_name}}/tests/unit/test_handler.rb b/ruby3.2/hello/{{cookiecutter.project_name}}/tests/unit/test_handler.rb deleted file mode 100644 index 5df8201b7..000000000 --- a/ruby3.2/hello/{{cookiecutter.project_name}}/tests/unit/test_handler.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'json' -require 'test/unit' -require 'mocha/test_unit' -require 'httparty' - -require_relative '../../hello_world/app' - -class HelloWorldTest < Test::Unit::TestCase - def event - { - body: 'eyJ0ZXN0IjoiYm9keSJ9', - resource: '/{proxy+}', - path: '/path/to/resource', - httpMethod: 'POST', - isBase64Encoded: true, - queryStringParameters: { - foo: 'bar' - }, - pathParameters: { - proxy: '/path/to/resource' - }, - stageVariables: { - baz: 'qux' - }, - headers: { - 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', - 'Accept-Encoding' => 'gzip, deflate, sdch', - 'Accept-Language' => 'en-US,en;q=0.8', - 'Cache-Control' => 'max-age=0', - 'CloudFront-Forwarded-Proto' => 'https', - 'CloudFront-Is-Desktop-Viewer' => 'true', - 'CloudFront-Is-Mobile-Viewer' => 'false', - 'CloudFront-Is-SmartTV-Viewer' => 'false', - 'CloudFront-Is-Tablet-Viewer' => 'false', - 'CloudFront-Viewer-Country' => 'US', - 'Host' => '1234567890.execute-api.us-east-1.amazonaws.com', - 'Upgrade-Insecure-Requests' => '1', - 'User-Agent' => 'Custom User Agent String', - 'Via' => '1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)', - 'X-Amz-Cf-Id' => 'cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==', - 'X-Forwarded-For' => '127.0.0.1, 127.0.0.2', - 'X-Forwarded-Port' => '443', - 'X-Forwarded-Proto' => 'https' - }, - requestContext: { - accountId: '123456789012', - resourceId: '123456', - stage: 'prod', - requestId: 'c6af9ac6-7b61-11e6-9a41-93e8deadbeef', - requestTime: '09/Apr/2015:12:34:56 +0000', - requestTimeEpoch: 1428582896000, - identity: { - cognitoIdentityPoolId: 'null', - accountId: 'null', - cognitoIdentityId: 'null', - caller: 'null', - accessKey: 'null', - sourceIp: '127.0.0.1', - cognitoAuthenticationType: 'null', - cognitoAuthenticationProvider: 'null', - userArn: 'null', - userAgent: 'Custom User Agent String', - user: 'null' - }, - path: '/prod/path/to/resource', - resourcePath: '/{proxy+}', - httpMethod: 'POST', - apiId: '1234567890', - protocol: 'HTTP/1.1' - } - } - end - - def mock_response - Object.new.tap do |mock| - mock.expects(:code).returns(200) - mock.expects(:body).returns('1.1.1.1') - end - end - - def expected_result - { - statusCode: 200, - body: { - message: 'Hello World!', -# location: '1.1.1.1' - }.to_json - } - end - - def test_lambda_handler -# HTTParty.expects(:get).with('http://checkip.amazonaws.com/').returns(mock_response) - assert_equal(lambda_handler(event: event, context: ''), expected_result) - end -end diff --git a/ruby3.2/step-func/.gitignore b/ruby3.2/step-func/.gitignore deleted file mode 100644 index 41bcace31..000000000 --- a/ruby3.2/step-func/.gitignore +++ /dev/null @@ -1,229 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,sam diff --git a/ruby3.2/step-func/README.md b/ruby3.2/step-func/README.md deleted file mode 100644 index e92232d33..000000000 --- a/ruby3.2/step-func/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Cookiecutter Ruby Step Functions Sample App (Stock Trader) for SAM based Serverless App - -A cookiecutter template to create a Ruby Step Functions Sample App (Stock Trader) boilerplate using [Serverless Application Model (SAM)](https://github.com/awslabs/serverless-application-model). - -This application creates a mock stock trading workflow which runs on a pre-defined schedule. It demonstrates the power of Step Functions to orchestrate Lambda functions and other AWS resources to form complex and robust workflows, coupled with event-driven development using Amazon EventBridge. - -## Requirements - -* [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) - -## Usage - -Generate a boilerplate template in your current project directory using the following syntax: - -* **Ruby 3.2**: `sam init --runtime ruby3.2` - -> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default) - - -# Credits - -* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter) diff --git a/ruby3.2/step-func/cookiecutter.json b/ruby3.2/step-func/cookiecutter.json deleted file mode 100644 index 10dc222b0..000000000 --- a/ruby3.2/step-func/cookiecutter.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "project_name": "Name of the project", - "runtime": "ruby3.2", - "architectures": { - "value": [ - "x86_64", "arm64" - ] - }, - "_copy_without_render": [ - ".gitignore" - ] -} diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/.gitignore b/ruby3.2/step-func/{{cookiecutter.project_name}}/.gitignore deleted file mode 100644 index 4bccb52c8..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/.gitignore +++ /dev/null @@ -1,345 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam -# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,python,windows,pycharm,visualstudiocode,sam - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### OSX ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -pytestdebug.log - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -#poetry.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -# .env -.env/ -.venv/ -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -pythonenv* - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - - -### SAM ### -# Ignore build directories for the AWS Serverless Application Model (SAM) -# Info: https://aws.amazon.com/serverless/sam/ -# Docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html - -**/.aws-sam - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history -.ionide - -### Windows ### -# Windows thumbnail cache files -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/osx,linux,python,windows,pycharm,visualstudiocode,sam diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/Gemfile b/ruby3.2/step-func/{{cookiecutter.project_name}}/Gemfile deleted file mode 100644 index d9d41b7d5..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/Gemfile +++ /dev/null @@ -1,6 +0,0 @@ -source "https://rubygems.org" - -group :test do - gem "test-unit" - gem "mocha" -end diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/README.md b/ruby3.2/step-func/{{cookiecutter.project_name}}/README.md deleted file mode 100644 index 52e53d9b8..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/README.md +++ /dev/null @@ -1,104 +0,0 @@ -# {{ cookiecutter.project_name }} - -This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders: - -- functions - Code for the application's Lambda functions to check the value of, buy, or sell shares of a stock. -- statemachines - Definition for the state machine that orchestrates the stock trading workflow. -- tests - Unit tests for the Lambda functions' application code. -- template.yaml - A template that defines the application's AWS resources. - -This application creates a mock stock trading workflow which runs on a pre-defined schedule (note that the schedule is disabled by default to avoid incurring charges). It demonstrates the power of Step Functions to orchestrate Lambda functions and other AWS resources to form complex and robust workflows, coupled with event-driven development using Amazon EventBridge. - -AWS Step Functions lets you coordinate multiple AWS services into serverless workflows so you can build and update apps quickly. Using Step Functions, you can design and run workflows that stitch together services, such as AWS Lambda, AWS Fargate, and Amazon SageMaker, into feature-rich applications. - -The application uses several AWS resources, including Step Functions state machines, Lambda functions and an EventBridge rule trigger. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. - -If you prefer to use an integrated development environment (IDE) to build and test the Lambda functions within your application, you can use the AWS Toolkit. The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started: - -* [CLion](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [GoLand](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [WebStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [Rider](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [PhpStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [RubyMine](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [DataGrip](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) -* [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html) -* [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html) - -The AWS Toolkit for VS Code includes full support for state machine visualization, enabling you to visualize your state machine in real time as you build. The AWS Toolkit for VS Code includes a language server for Amazon States Language, which lints your state machine definition to highlight common errors, provides auto-complete support, and code snippets for each state, enabling you to build state machines faster. - -## Deploy the sample application - -The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. - -To use the SAM CLI, you need the following tools: - -* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* Ruby - [Install Ruby 3.2](https://www.ruby-lang.org/en/documentation/installation/) -* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) - -To build and deploy your application for the first time, run the following in your shell: - -```bash -sam build -sam deploy --guided -``` - -The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts: - -* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. -* **AWS Region**: The AWS region you want to deploy your app to. -* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. -* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. -* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. - -You can find your State Machine ARN in the output values displayed after deployment. - -## Use the SAM CLI to build and test locally - -Build the Lambda functions in your application with the `sam build --use-container` command. - -```bash -{{ cookiecutter.project_name }}$ sam build -``` - -The SAM CLI installs dependencies defined in `functions/*/Gemfile`, creates a deployment package, and saves it in the `.aws-sam/build` folder. - -## Add a resource to your application -The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types. - -## Fetch, tail, and filter Lambda function logs - -To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. - -`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM. - -```bash -{{ cookiecutter.project_name }}$ sam logs -n StockCheckerFunction --stack-name {{ cookiecutter.project_name }} --tail -``` - -You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). - -## Unit tests - -Tests for the Lambda functions are defined in the `tests` folder in this project. - -```bash -{{ cookiecutter.project_name }}$ ruby tests/unit/test_stock_checker.rb -``` - -## Cleanup - -To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: - -```bash -sam delete --stack-name {{ cookiecutter.project_name }} -``` - -## Resources - -See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts. - -Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/Gemfile b/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/Gemfile deleted file mode 100644 index d058c25a7..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" - -ruby '~> 3.2.0' diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/app.rb b/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/app.rb deleted file mode 100644 index 33d1aa04b..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_buyer/app.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'json' -require 'securerandom' -require 'date' - -def lambda_handler(event:, context:) - # Sample Lambda function which mocks the operation of buying a random number - # of shares for a stock. - - # For demonstration purposes, this Lambda function does not actually perform any - # actual transactions. It simply returns a mocked result. - - # Parameters - # ---------- - # event: Hash, required - # Input event to the Lambda function - - # context: object, required - # Lambda Context runtime methods and attributes - - # Returns - # ------ - # dict: Object containing details of the stock buying transaction - - # Get the price of the stock provided as input - stock_price = event["stock_price"] - # Mocked result of a stock buying transaction - { - id: SecureRandom.uuid, # Unique ID for the transaction - price: stock_price.to_s, # Price of each share - type: "buy", # Type of transaction (buy/sell) - qty: rand(1...10).to_s, # Number of shares bought/sold (We are mocking this as a random integer between 1 and 10) - timestamp: DateTime.now.iso8601, # Timestamp of the when the transaction was completed - } -end diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_checker/Gemfile b/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_checker/Gemfile deleted file mode 100644 index d058c25a7..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_checker/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" - -ruby '~> 3.2.0' diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_checker/app.rb b/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_checker/app.rb deleted file mode 100644 index de6e2e28d..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_checker/app.rb +++ /dev/null @@ -1,23 +0,0 @@ -def lambda_handler(event:, context:) - # Sample Lambda function which mocks the operation of checking the current price - # of a stock. - - # For demonstration purposes this Lambda function simply returns - # a random integer between 0 and 100 as the stock price. - - # Parameters - # ---------- - # event: Hash, required - # Input event to the Lambda function - - # context: object, required - # Lambda Context runtime methods and attributes - - # Returns - # ------ - # dict: Object containing the current price of the stock - - # Check current price of the stock - stock_price = rand(0...100) # Current stock price is mocked as a random integer between 0 and 100 - { stock_price: stock_price } -end diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_seller/Gemfile b/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_seller/Gemfile deleted file mode 100644 index d058c25a7..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_seller/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" - -ruby '~> 3.2.0' diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_seller/app.rb b/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_seller/app.rb deleted file mode 100644 index ef49ab38f..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/functions/stock_seller/app.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'securerandom' -require 'date' - -def lambda_handler(event:, context:) - # Sample Lambda function which mocks the operation of selling a random number - # of shares for a stock. - - # For demonstration purposes, this Lambda function does not actually perform any - # actual transactions. It simply returns a mocked result. - - # Parameters - # ---------- - # event: Hash, required - # Input event to the Lambda function - - # context: object, required - # Lambda Context runtime methods and attributes - - # Returns - # ------ - # dict: Object containing details of the stock selling transaction - - # Get the price of the stock provided as input - stock_price = event["stock_price"] - # Mocked result of a stock buying transaction - { - id: SecureRandom.uuid, # Unique ID for the transaction - price: stock_price.to_s, # Price of each share - type: "sell", # Type of transaction (buy/sell) - qty: rand(1...10).to_s, # Number of shares bought/sold (We are mocking this as a random integer between 1 and 10) - timestamp: DateTime.now.iso8601, # Timestamp of the when the transaction was completed - } -end diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/statemachine/stock_trader.asl.json b/ruby3.2/step-func/{{cookiecutter.project_name}}/statemachine/stock_trader.asl.json deleted file mode 100644 index ea6a0ceb7..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/statemachine/stock_trader.asl.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "Comment": "A state machine that does mock stock trading.", - "StartAt": "Check Stock Value", - "States": { - "Check Stock Value": { - "Type": "Task", - "Resource": "${StockCheckerFunctionArn}", - "Retry": [ - { - "ErrorEquals": [ - "States.TaskFailed" - ], - "IntervalSeconds": 15, - "MaxAttempts": 5, - "BackoffRate": 1.5 - } - ], - "Next": "Buy or Sell?" - }, - "Buy or Sell?": { - "Type": "Choice", - "Choices": [ - { - "Variable": "$.stock_price", - "NumericLessThanEquals": 50, - "Next": "Buy Stock" - } - ], - "Default": "Sell Stock" - }, - "Sell Stock": { - "Type": "Task", - "Resource": "${StockSellerFunctionArn}", - "Retry": [ - { - "ErrorEquals": [ - "States.TaskFailed" - ], - "IntervalSeconds": 2, - "MaxAttempts": 3, - "BackoffRate": 1 - } - ], - "Next": "Record Transaction" - }, - "Buy Stock": { - "Type": "Task", - "Resource": "${StockBuyerFunctionArn}", - "Retry": [ - { - "ErrorEquals": [ - "States.TaskFailed" - ], - "IntervalSeconds": 2, - "MaxAttempts": 3, - "BackoffRate": 1 - } - ], - "Next": "Record Transaction" - }, - "Record Transaction": { - "Type": "Task", - "Resource": "${DDBPutItem}", - "Parameters": { - "TableName": "${DDBTable}", - "Item": { - "Id": { - "S.$": "$.id" - }, - "Type": { - "S.$": "$.type" - }, - "Price": { - "N.$": "$.price" - }, - "Timestamp": { - "S.$": "$.timestamp" - } - } - }, - "Retry": [ - { - "ErrorEquals": [ - "States.TaskFailed" - ], - "IntervalSeconds": 20, - "MaxAttempts": 5, - "BackoffRate": 10 - } - ], - "End": true - } - } -} \ No newline at end of file diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/template.yaml b/ruby3.2/step-func/{{cookiecutter.project_name}}/template.yaml deleted file mode 100644 index 63c5004ad..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/template.yaml +++ /dev/null @@ -1,94 +0,0 @@ -AWSTemplateFormatVersion: "2010-09-09" -Transform: AWS::Serverless-2016-10-31 -Description: > - {{ cookiecutter.project_name }} - - Sample SAM Template for {{ cookiecutter.project_name }} - -Resources: - StockTradingStateMachine: - Type: AWS::Serverless::StateMachine # More info about State Machine Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html - Properties: - DefinitionUri: statemachine/stock_trader.asl.json - DefinitionSubstitutions: - StockCheckerFunctionArn: !GetAtt StockCheckerFunction.Arn - StockSellerFunctionArn: !GetAtt StockSellerFunction.Arn - StockBuyerFunctionArn: !GetAtt StockBuyerFunction.Arn - DDBPutItem: !Sub arn:${AWS::Partition}:states:::dynamodb:putItem - DDBTable: !Ref TransactionTable - Events: - HourlyTradingSchedule: - Type: Schedule # More info about Schedule Event Source: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-statemachine-schedule.html - Properties: - Description: Schedule to run the stock trading state machine every hour - Enabled: False # This schedule is disabled by default to avoid incurring charges. - Schedule: "rate(1 hour)" - Policies: # Find out more about SAM policy templates: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html - - LambdaInvokePolicy: - FunctionName: !Ref StockCheckerFunction - - LambdaInvokePolicy: - FunctionName: !Ref StockSellerFunction - - LambdaInvokePolicy: - FunctionName: !Ref StockBuyerFunction - - DynamoDBWritePolicy: - TableName: !Ref TransactionTable - - StockCheckerFunction: - Type: AWS::Serverless::Function # More info about Function Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html - Properties: - CodeUri: functions/stock_checker/ - Handler: app.lambda_handler - Runtime: ruby3.2 - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - - StockSellerFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: functions/stock_seller/ - Handler: app.lambda_handler - Runtime: ruby3.2 - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - - StockBuyerFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: functions/stock_buyer/ - Handler: app.lambda_handler - Runtime: ruby3.2 - {%- if cookiecutter.architectures.value != []%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - - TransactionTable: - Type: AWS::Serverless::SimpleTable # More info about SimpleTable Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-simpletable.html - Properties: - PrimaryKey: - Name: Id - Type: String - ProvisionedThroughput: - ReadCapacityUnits: 1 - WriteCapacityUnits: 1 - -Outputs: - # StockTradingStateMachineHourlyTradingSchedule is an implicit Schedule event rule created out of Events key under Serverless::StateMachine - # Find out more about other implicit resources you can reference within SAM - # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html - StockTradingStateMachineArn: - Description: "Stock Trading state machine ARN" - Value: !Ref StockTradingStateMachine - StockTradingStateMachineRole: - Description: "IAM Role created for Stock Trading state machine based on the specified SAM Policy Templates" - Value: !GetAtt StockTradingStateMachineRole.Arn diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_buyer.rb b/ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_buyer.rb deleted file mode 100644 index b26b7c285..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_buyer.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'test/unit' - -require_relative '../../functions/stock_buyer/app' - -class StockBuyerTest < Test::Unit::TestCase - def test_lambda_handler - stock_price = 75 - input_payload = { - 'stock_price' => stock_price - } - result = lambda_handler(event: input_payload, context: '') - assert_true(result.key?(:id)) - assert_true(result.key?(:timestamp)) - assert_true(result.key?(:qty)) - - assert_equal("buy", result[:type]) - assert_equal(stock_price.to_s, result[:price]) - end -end diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_checker.rb b/ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_checker.rb deleted file mode 100644 index 80d164a56..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_checker.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'test/unit' - -require_relative '../../functions/stock_checker/app' - -class StockCheckerTest < Test::Unit::TestCase - def test_lambda_handler - result = lambda_handler(event: nil, context: '') - stock_price = result[:stock_price] - assert_true(stock_price.between?(0, 100)) - end -end diff --git a/ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_seller.rb b/ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_seller.rb deleted file mode 100644 index 2e2c2887d..000000000 --- a/ruby3.2/step-func/{{cookiecutter.project_name}}/tests/unit/test_stock_seller.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'test/unit' - -require_relative '../../functions/stock_seller/app' - -class StockSellerTest < Test::Unit::TestCase - def test_lambda_handler - stock_price = 25 - input_payload = { - "stock_price" => stock_price - } - result = lambda_handler(event: input_payload, context: '') - assert_true(result.key?(:id)) - assert_true(result.key?(:timestamp)) - assert_true(result.key?(:qty)) - - assert_equal("sell", result[:type]) - assert_equal(stock_price.to_s, result[:price]) - end -end diff --git a/tests/refactor/test_compare_folders.py b/tests/refactor/test_compare_folders.py index a6b722094..d8d142c04 100644 --- a/tests/refactor/test_compare_folders.py +++ b/tests/refactor/test_compare_folders.py @@ -30,30 +30,31 @@ def tearDown(self) -> None: self.old_cwd.cleanup() self.new_cwd.cleanup() - @parameterized.expand([ - ("ruby2.7/hello", "ruby/hello", "ruby2.7"), - ("ruby2.7/hello-img", "ruby/hello-img", "ruby2.7"), - ("ruby2.7/step-func", "ruby/step-func", "ruby2.7"), - ("ruby3.2/hello", "ruby/hello", "ruby3.2"), - ("ruby3.2/hello-img", "ruby/hello-img", "ruby3.2"), - ("ruby3.2/step-func", "ruby/step-func", "ruby3.2"), - ]) - def test_compare_folders(self, old_folder, new_folder, runtime): - self.old_template_path = Path(REPO_ROOT, old_folder) - self.new_template_path = Path(REPO_ROOT, new_folder) + # Update following parameters when we refactor any other runtime + # @parameterized.expand([ + # ("ruby2.7/hello", "ruby/hello", "ruby2.7"), + # ("ruby2.7/hello-img", "ruby/hello-img", "ruby2.7"), + # ("ruby2.7/step-func", "ruby/step-func", "ruby2.7"), + # ("ruby3.2/hello", "ruby/hello", "ruby3.2"), + # ("ruby3.2/hello-img", "ruby/hello-img", "ruby3.2"), + # ("ruby3.2/step-func", "ruby/step-func", "ruby3.2"), + # ]) + # def test_compare_folders(self, old_folder, new_folder, runtime): + # self.old_template_path = Path(REPO_ROOT, old_folder) + # self.new_template_path = Path(REPO_ROOT, new_folder) - LOG.info("Running `sam init` for old folder (%s) and new folder (%s)", old_folder, new_folder) - self._run_init(self.old_template_path, Path(self.old_cwd.name)) - self._run_init(self.new_template_path, Path(self.new_cwd.name), runtime) + # LOG.info("Running `sam init` for old folder (%s) and new folder (%s)", old_folder, new_folder) + # self._run_init(self.old_template_path, Path(self.old_cwd.name)) + # self._run_init(self.new_template_path, Path(self.new_cwd.name), runtime) - LOG.info("Comparing generated application for old folder (%s) with new folder (%s) and runtime (%s)", old_folder, new_folder, runtime) - diff_result = run_command([ - "diff", - "-rs", - self.old_cwd.name, - self.new_cwd.name, - ]) - self.assertEqual(0, diff_result.process.returncode) + # LOG.info("Comparing generated application for old folder (%s) with new folder (%s) and runtime (%s)", old_folder, new_folder, runtime) + # diff_result = run_command([ + # "diff", + # "-rs", + # self.old_cwd.name, + # self.new_cwd.name, + # ]) + # self.assertEqual(0, diff_result.process.returncode) def _run_init(self, template_path: Path, cwd: Path, runtime: Optional[str] = None): cmdlist = [ From cf6a78c5b1a9601eb3769c29e04ea51dc9a5d564 Mon Sep 17 00:00:00 2001 From: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> Date: Tue, 6 Feb 2024 15:27:45 -0800 Subject: [PATCH 2/2] add dummy refactor test --- tests/refactor/test_compare_folders.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/refactor/test_compare_folders.py b/tests/refactor/test_compare_folders.py index d8d142c04..b2f019665 100644 --- a/tests/refactor/test_compare_folders.py +++ b/tests/refactor/test_compare_folders.py @@ -30,6 +30,10 @@ def tearDown(self) -> None: self.old_cwd.cleanup() self.new_cwd.cleanup() + def test(self): + """Dummy test to run for refactor test CI checks""" + self.assertTrue(True) + # Update following parameters when we refactor any other runtime # @parameterized.expand([ # ("ruby2.7/hello", "ruby/hello", "ruby2.7"),