From d973ae9db62866c98122f17c05e3024633d954ae Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:08:35 -0700 Subject: [PATCH 1/2] deprecate aot.dotnet7 --- al2/dotnet7-aot/hello/.gitignore | 168 -------- al2/dotnet7-aot/hello/Pipfile | 13 - al2/dotnet7-aot/hello/README.md | 42 -- al2/dotnet7-aot/hello/cookiecutter.json | 13 - al2/dotnet7-aot/hello/setup.cfg | 2 - .../hello/tests/test_cookiecutter.py | 48 --- .../{{cookiecutter.project_name}}/.gitignore | 405 ------------------ .../{{cookiecutter.project_name}}/README.md | 125 ------ .../events/event.json | 63 --- .../omnisharp.json | 11 - .../src/HelloWorld/Function.cs | 68 --- .../src/HelloWorld/HelloWorld.csproj | 37 -- .../HelloWorld/aws-lambda-tools-defaults.json | 14 - .../template.yaml | 49 --- .../test/HelloWorld.Test/FunctionTest.cs | 57 --- .../HelloWorld.Test/HelloWorld.Tests.csproj | 20 - manifest-v2.json | 10 - 17 files changed, 1145 deletions(-) delete mode 100644 al2/dotnet7-aot/hello/.gitignore delete mode 100644 al2/dotnet7-aot/hello/Pipfile delete mode 100644 al2/dotnet7-aot/hello/README.md delete mode 100644 al2/dotnet7-aot/hello/cookiecutter.json delete mode 100644 al2/dotnet7-aot/hello/setup.cfg delete mode 100644 al2/dotnet7-aot/hello/tests/test_cookiecutter.py delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/.gitignore delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/README.md delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/events/event.json delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/omnisharp.json delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/Function.cs delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/HelloWorld.csproj delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/aws-lambda-tools-defaults.json delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/template.yaml delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/test/HelloWorld.Test/FunctionTest.cs delete mode 100644 al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/test/HelloWorld.Test/HelloWorld.Tests.csproj diff --git a/al2/dotnet7-aot/hello/.gitignore b/al2/dotnet7-aot/hello/.gitignore deleted file mode 100644 index 74ea25e0e..000000000 --- a/al2/dotnet7-aot/hello/.gitignore +++ /dev/null @@ -1,168 +0,0 @@ - -# Created by https://www.gitignore.io/api/osx,linux,python,windows - -### 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 ### -*.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/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg - -# 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/ -.coverage -.coverage.* -.cache -.pytest_cache/ -nosetests.xml -coverage.xml -*.cover -.hypothesis/ - -# Translations -*.mo -*.pot - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule.* - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ - -### Windows ### -# Windows thumbnail cache files -Thumbs.db -ehthumbs.db -ehthumbs_vista.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - - -# End of https://www.gitignore.io/api/osx,linux,python,windows \ No newline at end of file diff --git a/al2/dotnet7-aot/hello/Pipfile b/al2/dotnet7-aot/hello/Pipfile deleted file mode 100644 index a22660daa..000000000 --- a/al2/dotnet7-aot/hello/Pipfile +++ /dev/null @@ -1,13 +0,0 @@ -[[source]] - -url = "https://pypi.python.org/simple" -verify_ssl = true -name = "pypi" - -[packages] - -[dev-packages] - -cookiecutter = "*" -pytest-cookies = "*" -pytest = "*" diff --git a/al2/dotnet7-aot/hello/README.md b/al2/dotnet7-aot/hello/README.md deleted file mode 100644 index dcf4ceb19..000000000 --- a/al2/dotnet7-aot/hello/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Cookiecutter SAM for dotNet based Lambda functions - -This is a [Cookiecutter](https://github.com/audreyr/cookiecutter) template to create a Serverless Hello World App based on Serverless Application Model (SAM) and dotnet 7 Native AOT. - -It is important to note that you should not try to `git clone` this project but use `cookiecutter` CLI instead as ``{{cookiecutter.project_name}}`` will be rendered based on your input and therefore all variables and files will be rendered properly. - -## Requirements - -Install `cookiecutter` command line: - -**Pip users**: - -* `pip install cookiecutter` - -**Homebrew users**: - -* `brew install cookiecutter` - -**Windows or Pipenv users**: - -* `pipenv install cookiecutter` - -**NOTE**: [`Pipenv`](https://github.com/pypa/pipenv) is the new and recommended Python packaging tool that works across multiple platforms and makes Windows a first-class citizen. - -## Usage - -Generate a new SAM based Serverless App: `cookiecutter gh:aws-samples/cookiecutter-aws-sam-hello-dotnet`. - -You'll be prompted a few questions to help this cookiecutter template to scaffold this project and after its completed you should see a new folder at your current path with the name of the project you gave as input. - -**NOTE**: After you understand how cookiecutter works (cookiecutter.json, mainly), you can fork this repo and apply your own mechanisms to accelerate your development process and this can be followed for any programming language and OS. - - -# Credits - -* This project has been generated with [Cookiecutter](https://github.com/audreyr/cookiecutter) - - -License -------- - -This project is licensed under the terms of the [MIT License with no attribution](/LICENSE) diff --git a/al2/dotnet7-aot/hello/cookiecutter.json b/al2/dotnet7-aot/hello/cookiecutter.json deleted file mode 100644 index 81023bf85..000000000 --- a/al2/dotnet7-aot/hello/cookiecutter.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "project_name": "Name of the project", - "runtime": "provided.al2", - "architectures": { - "value": [ - "x86_64", "arm64" - ] - }, - "_copy_without_render": [ - ".gitignore" - ] - -} diff --git a/al2/dotnet7-aot/hello/setup.cfg b/al2/dotnet7-aot/hello/setup.cfg deleted file mode 100644 index eee4ab11a..000000000 --- a/al2/dotnet7-aot/hello/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[install] -prefix= \ No newline at end of file diff --git a/al2/dotnet7-aot/hello/tests/test_cookiecutter.py b/al2/dotnet7-aot/hello/tests/test_cookiecutter.py deleted file mode 100644 index f44f4e9f3..000000000 --- a/al2/dotnet7-aot/hello/tests/test_cookiecutter.py +++ /dev/null @@ -1,48 +0,0 @@ -""" - Tests cookiecutter baking process and rendered content -""" - - -def test_project_tree(cookies): - result = cookies.bake(extra_context={ - 'project_name': 'hello sam' - }) - assert result.exit_code == 0 - assert result.exception is None - assert result.project.basename == 'hello sam' - assert result.project.isdir() - assert result.project.join('.gitignore').isfile() - assert result.project.join('template.yaml').isfile() - assert result.project.join('README.md').isfile() - assert result.project.join('src').isdir() - assert result.project.join('test').isdir() - assert result.project.join('src', 'HelloWorld').isdir() - assert result.project.join( - 'src', 'HelloWorld', 'HelloWorld.csproj').isfile() - assert result.project.join('src', 'HelloWorld', 'Function.cs').isfile() - assert result.project.join( - 'src', 'HelloWorld', 'aws-lambda-tools-defaults.json').isfile() - assert result.project.join('src', 'HelloWorld', 'rd.xml').isfile() - assert result.project.join( - 'test', 'HelloWorld.Test', 'FunctionTest.cs').isfile() - assert result.project.join( - 'test', 'HelloWorld.Test', 'HelloWorld.Tests.csproj').isfile() - - -def test_app_content(cookies): - result = cookies.bake(extra_context={'project_name': 'my_lambda'}) - app_file = result.project.join('src', 'HelloWorld', 'Function.cs') - app_content = app_file.readlines() - app_content = ''.join(app_content) - - contents = ( - "GetCallingIP", - "GetStringAsync", - "location", - "message", - "hello world", - "StatusCode" - ) - - for content in contents: - assert content in app_content diff --git a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/.gitignore b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/.gitignore deleted file mode 100644 index 9baa19505..000000000 --- a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/.gitignore +++ /dev/null @@ -1,405 +0,0 @@ - -# Created by https://www.gitignore.io/api/macos,linux,windows,sublimetext,dotsettings,visualstudio,visualstudiocode - -### DotSettings ### -*.DotSettings -### 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* - -### macOS ### -*.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 - -### SublimeText ### -# cache files for sublime text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache - -# workspace files are user-specific -*.sublime-workspace - -# project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using SublimeText -# *.sublime-project - -# sftp configuration file -sftp-config.json - -# Package control specific files -Package Control.last-run -Package Control.ca-list -Package Control.ca-bundle -Package Control.system-ca-bundle -Package Control.cache/ -Package Control.ca-certs/ -Package Control.merged-ca-bundle -Package Control.user-ca-bundle -oscrypto-ca-bundle.crt -bh_unicode_properties.cache - -# Sublime-github package stores a github token in this file -# https://packagecontrol.io/packages/sublime-github -GitHub.sublime-settings - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -.history - -### Windows ### -# Windows thumbnail cache files -Thumbs.db -ehthumbs.db -ehthumbs_vista.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -### VisualStudio ### -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ -**/Properties/launchSettings.json - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Uncomment the next line to ignore your web deploy settings. -# By default, sensitive information, such as encrypted password -# should be stored in the .pubxml.user file. -#*.pubxml -*.pubxml.user -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Typescript v1 declaration files -typings/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -### VisualStudio Patch ### -# By default, sensitive information, such as encrypted password -# should be stored in the .pubxml.user file. - - -# End of https://www.gitignore.io/api/macos,linux,windows,sublimetext,dotsettings,visualstudio,visualstudiocode \ No newline at end of file diff --git a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/README.md b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/README.md deleted file mode 100644 index b7bce6558..000000000 --- a/al2/dotnet7-aot/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. - -- src - Code for the application's Lambda function. -- events - Invocation events that you can use to invoke the function. -- test - 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) -* .NET Core - [Install .NET Core](https://www.microsoft.com/net/download) -* 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 `src/HelloWorld.csproj`, 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 `test` folder in this project. - -```bash -{{ cookiecutter.project_name }}$ dotnet test test/HelloWorld.Test -``` - -## 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/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/events/event.json b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/events/event.json deleted file mode 100644 index 3822fadaa..000000000 --- a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/events/event.json +++ /dev/null @@ -1,63 +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" - } - } - \ No newline at end of file diff --git a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/omnisharp.json b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/omnisharp.json deleted file mode 100644 index c42f8db91..000000000 --- a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/omnisharp.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "fileOptions": { - "excludeSearchPatterns": [ - "**/bin/**/*", - "**/obj/**/*" - ] - }, - "msbuild": { - "Platform": "rhel.7.2-x64" - } -} \ No newline at end of file diff --git a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/Function.cs b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/Function.cs deleted file mode 100644 index b4b099be2..000000000 --- a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/Function.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Threading.Tasks; - -using Amazon.Lambda.APIGatewayEvents; -using Amazon.Lambda.Core; -using Amazon.Lambda.RuntimeSupport; -using Amazon.Lambda.Serialization.SystemTextJson; - -// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. -[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))] - -namespace HelloWorld -{ - - public class Function - { - private static async Task Main() - { - Func> handler = FunctionHandler; - await LambdaBootstrapBuilder.Create(handler, new SourceGeneratorLambdaJsonSerializer()) - .Build() - .RunAsync(); - } - - private static readonly HttpClient client = new HttpClient(); - - private static async Task GetCallingIP() - { - client.DefaultRequestHeaders.Accept.Clear(); - client.DefaultRequestHeaders.Add("User-Agent", "AWS Lambda .Net Client"); - - var msg = await client.GetStringAsync("http://checkip.amazonaws.com/").ConfigureAwait(continueOnCapturedContext:false); - - return msg.Replace("\n",""); - } - - public static async Task FunctionHandler(APIGatewayHttpApiV2ProxyRequest apigProxyEvent, ILambdaContext context) - { - - var location = await GetCallingIP(); - var body = new Dictionary - { - { "message", "hello world" }, - { "location", location } - }; - - return new APIGatewayHttpApiV2ProxyResponse - { - Body = JsonSerializer.Serialize(body), - StatusCode = 200, - Headers = new Dictionary { { "Content-Type", "application/json" } } - }; - } - } - - [JsonSerializable(typeof(APIGatewayHttpApiV2ProxyRequest))] - [JsonSerializable(typeof(APIGatewayHttpApiV2ProxyResponse))] - public partial class MyCustomJsonSerializerContext : JsonSerializerContext - { - // By using this partial class derived from JsonSerializerContext, we can generate reflection free JSON Serializer code at compile time - // which can deserialize our class and properties. However, we must attribute this class to tell it what types to generate serialization code for - // See https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-source-generation - } -} diff --git a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/HelloWorld.csproj b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/HelloWorld.csproj deleted file mode 100644 index 32b287f4b..000000000 --- a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/HelloWorld.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - Exe - net7.0 - enable - enable - Lambda - bootstrap - - true - - - true - - true - - partial - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/aws-lambda-tools-defaults.json b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/aws-lambda-tools-defaults.json deleted file mode 100644 index 3e56bf317..000000000 --- a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/src/HelloWorld/aws-lambda-tools-defaults.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Information": [ - "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", - "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", - "dotnet lambda help", - "All the command line options for the Lambda command can be specified in this file." - ], - "profile": "", - "region": "", - "configuration": "Release", - "function-runtime": "provided.al2", - "template": "template.yaml", - "function-handler": "bootstrap" -} \ No newline at end of file diff --git a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/template.yaml b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/template.yaml deleted file mode 100644 index de6b588f8..000000000 --- a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/template.yaml +++ /dev/null @@ -1,49 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: > - 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: 10 - -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 - Metadata: - BuildMethod: dotnet7 - Properties: - CodeUri: ./src/HelloWorld/ - Handler: bootstrap - Runtime: provided.al2 - {%- if cookiecutter.architectures.value != [ ]%} - Architectures: - {%- for arch in cookiecutter.architectures.value %} - - {{arch}} - {%- endfor %} - {%- endif %} - MemorySize: 256 - Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object - Variables: - PARAM1: VALUE - 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/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/test/HelloWorld.Test/FunctionTest.cs b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/test/HelloWorld.Test/FunctionTest.cs deleted file mode 100644 index 911ef3241..000000000 --- a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/test/HelloWorld.Test/FunctionTest.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Net.Http; -using System.Text.Json; -using Xunit; -using Amazon.Lambda.TestUtilities; -using Amazon.Lambda.APIGatewayEvents; - -namespace HelloWorld.Tests -{ - public class FunctionTest - { - private static readonly HttpClient client = new HttpClient(); - - private static async Task GetCallingIP() - { - client.DefaultRequestHeaders.Accept.Clear(); - client.DefaultRequestHeaders.Add("User-Agent", "AWS Lambda .Net Client"); - - var stringTask = client.GetStringAsync("http://checkip.amazonaws.com/").ConfigureAwait(continueOnCapturedContext:false); - - var msg = await stringTask; - return msg.Replace("\n",""); - } - - [Fact] - public async Task TestHelloWorldFunctionHandler() - { - var request = new APIGatewayHttpApiV2ProxyRequest(); - var context = new TestLambdaContext(); - string location = GetCallingIP().Result; - Dictionary body = new Dictionary - { - { "message", "hello world" }, - { "location", location }, - }; - - var expectedResponse = new APIGatewayHttpApiV2ProxyResponse - { - Body = JsonSerializer.Serialize(body), - StatusCode = 200, - Headers = new Dictionary { { "Content-Type", "application/json" } } - }; - - var response = await Function.FunctionHandler(request, context); - - Console.WriteLine("Lambda Response: \n" + response.Body); - Console.WriteLine("Expected Response: \n" + expectedResponse.Body); - - Assert.Equal(expectedResponse.Body, response.Body); - Assert.Equal(expectedResponse.Headers, response.Headers); - Assert.Equal(expectedResponse.StatusCode, response.StatusCode); - } - } -} \ No newline at end of file diff --git a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/test/HelloWorld.Test/HelloWorld.Tests.csproj b/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/test/HelloWorld.Test/HelloWorld.Tests.csproj deleted file mode 100644 index 1fb9966a1..000000000 --- a/al2/dotnet7-aot/hello/{{cookiecutter.project_name}}/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net7.0 - - - - - - - - - - - - - - - - diff --git a/manifest-v2.json b/manifest-v2.json index c504768ff..b5396efe3 100644 --- a/manifest-v2.json +++ b/manifest-v2.json @@ -191,16 +191,6 @@ "useCaseName": "Data processing" } ], - "aot.dotnet7 (provided.al2)": [ - { - "directory": "al2/dotnet7-aot/hello", - "displayName": "Hello World Example", - "dependencyManager": "cli-package", - "appTemplate": "hello-world", - "packageType": "Zip", - "useCaseName": "Hello World Example" - } - ], "go (provided.al2)": [ { "directory": "al2/go/hello", From ef923f7142b3d8ded6c9154808cb22cbea112d12 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:24:27 -0700 Subject: [PATCH 2/2] remove test files --- .../dotnet/test_build_invoke_dotnet7.py | 25 ------------------- .../unit_test/test_unit_test_dotnet7.py | 7 ------ 2 files changed, 32 deletions(-) delete mode 100644 tests/integration/build_invoke/dotnet/test_build_invoke_dotnet7.py delete mode 100644 tests/integration/unit_test/test_unit_test_dotnet7.py diff --git a/tests/integration/build_invoke/dotnet/test_build_invoke_dotnet7.py b/tests/integration/build_invoke/dotnet/test_build_invoke_dotnet7.py deleted file mode 100644 index efb38c19d..000000000 --- a/tests/integration/build_invoke/dotnet/test_build_invoke_dotnet7.py +++ /dev/null @@ -1,25 +0,0 @@ -from tests.integration.build_invoke.build_invoke_base import BuildInvokeBase - -""" -sam build does not support to build dotnetcore 3.1 templates using container, -here we put them in a separate file and use a dedicate codebuild project with .net 3.1 runtime to build them. - -For each template, it will test the following sam commands: -1. sam init -2. sam build --use-container (if self.use_container is False, --use-container will be omitted) -3. (if there are event jsons), for each event json, check `sam local invoke` response is a valid json -""" - - -class BuildInvoke_dotnet6_cookiecutter_aws_sam_hello_dotnet(BuildInvokeBase.DotNetCoreExtraRerunBuildInvokeBase): - use_container = False - directory = "dotnet7-aot/hello" - - - - -# -# Image templates -# - - diff --git a/tests/integration/unit_test/test_unit_test_dotnet7.py b/tests/integration/unit_test/test_unit_test_dotnet7.py deleted file mode 100644 index 236bbde56..000000000 --- a/tests/integration/unit_test/test_unit_test_dotnet7.py +++ /dev/null @@ -1,7 +0,0 @@ -# dotnet unit tests are executed from test directories, so code_directories point to test directories -from tests.integration.unit_test.unit_test_base import UnitTestBase - - -class UnitTest_dotnet6_cookiecutter_aws_sam_hello_dotnet(UnitTestBase.DotNetCoreUnitTestBase): - directory = "dotnet7-aot/hello" - code_directories = ["test/HelloWorld.Test"]