diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..b67ee85ea --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,43 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug, triage +assignees: '' + +--- + + + + +**What were you trying to accomplish?** + +## Expected Behavior + + + +## Current Behavior + + + +## Possible Solution + + + +## Steps to Reproduce (for bugs) + + +1. +2. +3. +4. + +## Environment + +* **Powertools version used**: +* **AWS Lambda function runtime:** +* **Debugging logs** + +```csharp +# paste logs here +``` diff --git a/.github/ISSUE_TEMPLATE/documentation-improvements.md b/.github/ISSUE_TEMPLATE/documentation-improvements.md new file mode 100644 index 000000000..8341ae4e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation-improvements.md @@ -0,0 +1,17 @@ +--- +name: Documentation improvements +about: Suggest a documentation update +title: '' +labels: documentation +assignees: '' + +--- + +**What were you initially searching for in the docs?** + + +**Is this related to an existing part of the documentation? Please share a link** + +**Describe how we could make it clearer** + +**If you have a proposed update, please share it here** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..b837b7ad5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: feature-request, triage +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** + + +**Describe the solution you'd like** + + +**Describe alternatives you've considered** + + +**Additional context** + diff --git a/.github/ISSUE_TEMPLATE/rfc.md b/.github/ISSUE_TEMPLATE/rfc.md new file mode 100644 index 000000000..a521ff873 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/rfc.md @@ -0,0 +1,62 @@ +--- +name: RFC +about: Feature design and proposals +title: 'RFC: ' +labels: RFC, triage +assignees: '' +approved by: '' +--- + +## Key information + +* RFC PR: (leave this empty) +* Related issue(s), if known: +* Area: (i.e. Tracer, Metrics, Logger, etc.) +* Meet [tenets](https://awslabs.github.io/aws-lambda-powertools-dotnet/#tenets): (Yes/no) +* Approved by: '' +* Reviewed by: '' + +## Summary +[summary]: #summary + +> One paragraph explanation of the feature. + +## Motivation +[motivation]: #motivation + +> Why are we doing this? What use cases does it support? What is the expected outcome? + +## Proposal +[proposal]: #proposal + +> This is the bulk of the RFC. + +> Explain the design in enough detail for somebody familiar with Powertools to understand it, and for somebody familiar with the implementation to implement it. + +**If this feature should be available in other runtimes (e.g. Java, Typescript), how would this look like to ensure consistency?** + +## User Experience + +**How would customers use it?** + +**Any configuration or corner cases you'd expect?** + +**Demonstration of before and after on how the experience will be better** + +## Drawbacks +[drawbacks]: #drawbacks + +> Why should we *not* do this? + +> Do we need additional dependencies? Impact performance/package size? + +## Rationale and alternatives +[rationale-and-alternatives]: #rationale-and-alternatives + +* **What other designs have been considered? Why not them?** +* **What is the impact of not doing this?** + +## Unresolved questions +[unresolved-questions]: #unresolved-questions + +> Optional, stash area for topics that need further development e.g. TBD diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..003e92265 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,25 @@ +**Issue #, if available:** + +## Description of changes: + + + +**Checklist** + + + +* [ ] [Meet tenets criteria](https://awslabs.github.io/aws-lambda-powertools-dotnet/#tenets) +* [ ] Update tests +* [ ] Update docs +* [ ] PR title follows [conventional commit semantics](https://github.com/awslabs/aws-lambda-powertools-dotnet/blob/develop/.github/semantic.yml) + +## Breaking change checklist + + + +**RFC issue #**: + +* [ ] Migration process documented +* [ ] Implement warnings (if it can live side by side) + +By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. diff --git a/.github/auto_assign-issues.yml b/.github/auto_assign-issues.yml new file mode 100644 index 000000000..f5f16997b --- /dev/null +++ b/.github/auto_assign-issues.yml @@ -0,0 +1,8 @@ +addAssignees: true + +# The list of users to assign to new issues. +# If empty or not provided, the repository owner is assigned +assignees: + - t1agob + - sliedig + - amirkaws diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml new file mode 100644 index 000000000..458c4b1b7 --- /dev/null +++ b/.github/boring-cyborg.yml @@ -0,0 +1,45 @@ +##### Labeler ########################################################################################################## +labelPRBasedOnFilePath: + area/logger: + - libraries/src/AWS.Lambda.Powertools.Logging/* + - libraries/src/AWS.Lambda.Powertools.Logging/**/* + area/tracer: + - libraries/src/AWS.Lambda.Powertools.Tracing/* + - libraries/src/AWS.Lambda.Powertools.Tracing/**/* + area/metrics: + - libraries/src/AWS.Lambda.Powertools.Metrics/* + - libraries/src/AWS.Lambda.Powertools.Metrics/**/* + + documentation: + - docs/* + - docs/**/* + - mkdocs.yml + + internal: + - .github/* + - .github/**/* + - .chglog/* + - .flake8 + - .gitignore + - .pre-commit-config.yaml + - Makefile + - CONTRIBUTING.md + - CODE_OF_CONDUCT.md + - LICENSE + + tests: + - libraries/tests/* + - libraries/tests/**/* + + +##### Greetings ######################################################################################################## +firstPRWelcomeComment: > + Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. + +# Comment to be posted to congratulate user on their first merged PR +firstPRMergeComment: > + Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! + +# Comment to be posted to on first time issues +firstIssueWelcomeComment: > + Thanks for opening your first issue here! We'll come back to you as soon as we can. \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 000000000..4fb0323ff --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,39 @@ +change-template: "* $TITLE (#$NUMBER) by @$AUTHOR" +categories: + - title: '⚡ Breaking Changes' + labels: + - 'breaking-change' + - title: '🌟New features and non-breaking changes' + labels: + - 'major' + - 'feature' + - title: '🌟 Minor Changes' + labels: + - 'enhancement' + - title: '📜 Documentation updates' + labels: + - 'documentation' + - title: '🐛 Bug and hot fixes' + labels: + - 'bug' + - 'fix' + - title: '🚒 Deprecations' + labels: + - 'deprecated' + - title: '🔧 Maintenance' + labels: + - 'internal' + - 'dependencies' +exclude-labels: + - 'skip-changelog' +tag-template: 'v$NEXT_PATCH_VERSION' +template: | + ## Changes + + **[Human readable summary of changes]** + + $CHANGES + + ## This release was made possible by the following contributors: + + $CONTRIBUTORS diff --git a/.github/semantic.yml b/.github/semantic.yml new file mode 100644 index 000000000..39119da8d --- /dev/null +++ b/.github/semantic.yml @@ -0,0 +1,19 @@ +# conventional commit types: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json +types: + - feat + - fix + - docs + - style + - refactor + - perf + - test + - build + - ci + - chore + - revert + - improv + +# Always validate the PR title +# and ignore the commits to lower the entry bar for contribution +# while titles make up the Release notes to ease maintenance overhead +titleOnly: true diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 000000000..1bb42057e --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +only: issues +daysUntilStale: 30 +daysUntilClose: 7 +exemptLabels: + - bug + - documentation + - enhancement + - feature-request + - RFC +staleLabel: pending-close-response-required +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +closeComment: > + This issue has been automatically closed because of inactivity. + Please open a new issue if you are still encountering problems. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..32c71566c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build .NET + +on: + push: + branches: [ develop, main ] + pull_request: + branches: [ develop, main ] + +defaults: + run: + working-directory: ./libraries + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + - name: Install solution dependencies + run: dotnet restore + - name: Build + run: dotnet build --configuration Release --no-restore + - name: Test & Code Coverage + run: dotnet test --collect:"XPlat Code Coverage" -r ./codecov --no-restore --verbosity normal + - name: Codecov + uses: codecov/codecov-action@v2.1.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: unittests + fail_ci_if_error: true + name: codecov-lambda-powertools-dotnet + verbose: true + directory: ./libraries/codecov diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..7ada67bfc --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,48 @@ +name: Docs + +on: + push: + branches: + - develop + - main + +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v2.2.2 + with: + python-version: "3.8" + - name: Capture branch and tag + id: branch_name + run: | + echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Build docs website + run: make build-docs-website + - name: Deploy all docs + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist + apidocs: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Configure and build api docs generator + run: | + brew install -f docfx --skip-cask-deps --ignore-dependencies + docfx apidocs/docfx.json + - name: Release API docs to latest + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./apidocs/_site + keep_files: true + destination_dir: api diff --git a/.github/workflows/label_pr_on_title.yml b/.github/workflows/label_pr_on_title.yml new file mode 100644 index 000000000..45adc1af3 --- /dev/null +++ b/.github/workflows/label_pr_on_title.yml @@ -0,0 +1,87 @@ +name: Label PR based on title + +on: + workflow_run: + workflows: ["Record PR number"] + types: + - completed + +jobs: + upload: + runs-on: ubuntu-latest + # Guardrails to only ever run if PR recording workflow was indeed + # run in a PR event and ran successfully + if: > + ${{ github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' }} + steps: + - name: 'Download artifact' + uses: actions/github-script@v5 + # For security, we only download artifacts tied to the successful PR recording workflow + with: + script: | + const fs = require('fs'); + + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.event.workflow_run.id }}, + }); + + const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0]; + + const artifact = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + + fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(artifact.data)); + # NodeJS standard library doesn't provide ZIP capabilities; use system `unzip` command instead + - run: unzip pr.zip + + - name: 'Label PR based on title' + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + # This safely runs in our base repo, not on fork + # thus allowing us to provide a write access token to label based on PR title + # and label PR based on semantic title accordingly + script: | + const fs = require('fs'); + const pr_number = Number(fs.readFileSync('./number')); + const pr_title = fs.readFileSync('./title', 'utf-8').trim(); + + const FEAT_REGEX = /feat(\((\w+)\))?(\:.+)/ + const BUG_REGEX = /(fix|bug)(\((\w+)\))?(\:.+)/ + const DOCS_REGEX = /(docs|doc)(\((\w+)\))?(\:.+)/ + const CHORE_REGEX = /(chore)(\((\w+)\))?(\:.+)/ + const DEPRECATED_REGEX = /(deprecated)(\((\w+)\))?(\:.+)/ + const REFACTOR_REGEX = /(refactor)(\((\w+)\))?(\:.+)/ + + const labels = { + "feature": FEAT_REGEX, + "bug": BUG_REGEX, + "documentation": DOCS_REGEX, + "internal": CHORE_REGEX, + "enhancement": REFACTOR_REGEX, + "deprecated": DEPRECATED_REGEX, + } + + for (const label in labels) { + const matcher = new RegExp(labels[label]) + const isMatch = matcher.exec(pr_title) + if (isMatch != null) { + console.info(`Auto-labeling PR ${pr_number} with ${label}`) + + await github.rest.issues.addLabels({ + issue_number: pr_number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [label] + }) + + break + } + } \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..f903c9a7a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,62 @@ +name: Publish new package version + +on: + push: + paths: + - 'version.json' + +jobs: + release: + if: ${{ github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Read AWS.Lambda.Powertools.Common version + id: common-version + uses: notiz-dev/github-action-json-property@release + with: + path: 'version.json' + prop_path: 'Core.Common' + - name: Read AWS.Lambda.Powertools.Logging version + id: logging-version + uses: notiz-dev/github-action-json-property@release + with: + path: 'version.json' + prop_path: 'Core.Logging' + - name: Read AWS.Lambda.Powertools.Tracing version + id: tracing-version + uses: notiz-dev/github-action-json-property@release + with: + path: 'version.json' + prop_path: 'Core.Tracing' + - name: Read AWS.Lambda.Powertools.Metrics version + id: metrics-version + uses: notiz-dev/github-action-json-property@release + with: + path: 'version.json' + prop_path: 'Core.Metrics' + - name: Setup .NET 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + - name: Setup semver + run: dotnet tool install -g dotnet-setversion + - name: Set assembly version in all projects + run: | + setversion ${{steps.common-version.outputs.prop}} libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj + setversion ${{steps.logging-version.outputs.prop}} libraries/src/AWS.Lambda.Powertools.Logging/AWS.Lambda.Powertools.Logging.csproj + setversion ${{steps.metrics-version.outputs.prop}} libraries/src/AWS.Lambda.Powertools.Metrics/AWS.Lambda.Powertools.Metrics.csproj + setversion ${{steps.tracing-version.outputs.prop}} libraries/src/AWS.Lambda.Powertools.Tracing/AWS.Lambda.Powertools.Tracing.csproj + - name: Authenticate to GitHub packages # Temporary package repository for publishing validation + run: dotnet nuget add source --username ${{ secrets.PUBLISH_USERNAME }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name nuget ${{ secrets.NUGET_SOURCE }} + - name: Generate Nuget Packages + run: | + cd buildtools + dotnet build -c Release + - name: Publish Nuget Packages + run: | + cd deploy/nuget-packages + dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate -s nuget + diff --git a/.github/workflows/record_pr.yml b/.github/workflows/record_pr.yml new file mode 100644 index 000000000..88edce19f --- /dev/null +++ b/.github/workflows/record_pr.yml @@ -0,0 +1,21 @@ +name: Record PR number + +on: + pull_request: + types: [opened, edited] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Save PR number + run: | + mkdir -p ./pr + echo ${{ github.event.number }} > ./pr/number + echo "${{ github.event.pull_request.title }}" > ./pr/title + - uses: actions/upload-artifact@v2 + with: + name: pr + path: pr/ \ No newline at end of file diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 000000000..59633a634 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,15 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - develop + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..fba2714b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +docs/node_modules +docs/.cache +docs/public + +apidocs/_site +apidocs/obj + +deploy/** + +.idea +.vscode +.vs/ + +examples/SimpleLambda/.aws-sam +examples/SimpleLambda/samconfig.toml + +AWS.Lambda.Powertools.sln.DotSettings.user +[Oo]bj/** +[Bb]in/** +.DS_Store diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..c97d51b40 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,27 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/libraries/tests/Amazon.LambdaPowertools.Logging.Tests/bin/Debug/netcoreapp3.1/Amazon.LambdaPowertools.Logging.Tests.dll", + "args": [], + "cwd": "${workspaceFolder}/libraries/tests/Amazon.LambdaPowertools.Logging.Tests", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..7a73a41bf --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..c258fc978 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/libraries/tests/Amazon.LambdaPowertools.Logging.Tests/Amazon.LambdaPowertools.Logging.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/libraries/tests/Amazon.LambdaPowertools.Logging.Tests/Amazon.LambdaPowertools.Logging.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/libraries/tests/Amazon.LambdaPowertools.Logging.Tests/Amazon.LambdaPowertools.Logging.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/404.html b/404.html new file mode 100644 index 000000000..5ab03a082 --- /dev/null +++ b/404.html @@ -0,0 +1,20 @@ + + + +
+ + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..398953761 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format for changes and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [Unreleased] + +## [0.1.0] - 2021-11-15 +### Added +- Public beta release diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..da8dca0c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim AS build-image + +ARG FUNCTION_DIR="/build" +ARG SAM_BUILD_MODE="run" +ENV PATH="/root/.dotnet/tools:${PATH}" + +RUN apt-get update && apt-get -y install zip + +RUN mkdir $FUNCTION_DIR +WORKDIR $FUNCTION_DIR +COPY examples/SimpleLambda/src/HelloWorld/Function.cs examples/SimpleLambda/src/HelloWorld/HelloWorld.csproj examples/SimpleLambda/src/HelloWorld/aws-lambda-tools-defaults.json $FUNCTION_DIR/examples/SimpleLambda/src/HelloWorld/ +COPY libraries/src/ $FUNCTION_DIR/libraries/src/ +COPY libraries/*.png $FUNCTION_DIR/libraries/ +RUN dotnet tool install -g Amazon.Lambda.Tools + +# Build and Copy artifacts depending on build mode. +RUN mkdir -p build_artifacts +WORKDIR $FUNCTION_DIR/examples/SimpleLambda/src/HelloWorld/ +RUN if [ "$SAM_BUILD_MODE" = "debug" ]; then dotnet lambda package --configuration Debug; else dotnet lambda package --configuration Release; fi +RUN if [ "$SAM_BUILD_MODE" = "debug" ]; then cp -r /bin/Debug/net6.0/publish/* /build/build_artifacts; else cp -r bin/Release/net6.0/publish/* /build/build_artifacts; fi + +FROM public.ecr.aws/lambda/dotnet:6 + +COPY --from=build-image /build/build_artifacts/ /var/task/ +# Command can be overwritten by providing a different command in the template directly. +CMD ["HelloWorld::HelloWorld.Function::FunctionHandler"] diff --git a/LICENSE b/LICENSE index 67db85882..12ad443cd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,175 +1,14 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. +Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..3158dcef7 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: build-docs build-docs-website docs-local docs-local-docker + +build-docs: + @$(MAKE) build-docs-website + +build-docs-website: + mkdir -p dist + docker build -t squidfunk/mkdocs-material ./docs/ + docker run --rm -t -v ${PWD}:/docs squidfunk/mkdocs-material build + cp -R site/* dist/ + +docs-local: + poetry run mkdocs serve + +docs-local-docker: + docker build -t squidfunk/mkdocs-material ./docs/ + docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material \ No newline at end of file diff --git a/README.md b/README.md index 847260ca5..900107d4c 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,65 @@ -## My Project +# AWS Lambda Powertools for .NET -TODO: Fill this README out! + [](https://github.com/awslabs/aws-lambda-powertools-dotnet/actions/workflows/build.yml) -Be sure to: +AWS Lambda Powertools for .NET (C#) is suite of utilities for AWS Lambda functions to simplify implementation of serverless observability best practices such as tracing, structured logging, custom metrics. -* Change the title in this README -* Edit your repository description on GitHub +**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-dotnet/)** | **[NuGet](https://www.nuget.org/)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](#examples)** | **[Blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/)** -## Security +> **Join us on the AWS Developers Slack at `#lambda-powertools`** - **[Invite, if you don't have an account](https://join.slack.com/t/awsdevelopers/shared_invite/zt-gu30gquv-EhwIYq3kHhhysaZ2aIX7ew)** -See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. +## Features + +Lambda Powertools provides three core utilities: + +* **[Logging](https://awslabs.github.io/aws-lambda-powertools-dotnet/core/logging/)** - provides a custom logger class that outputs structured JSON. It allows you to pass in strings or more complex objects, and will take care of serializing the log output. Common use cases—such as logging the Lambda event payload and capturing cold start information—are handled for you, including appending custom keys to the logger at anytime. + +* **[Metrics](https://awslabs.github.io/aws-lambda-powertools-dotnet/core/metrics/)** - makes collecting custom metrics from your application simple, without the need to make synchronous requests to external systems. This functionality is powered by [Amazon CloudWatch Embedded Metric Format (EMF)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format.html), which allows for capturing metrics asynchronously. + +* **[Tracing](https://awslabs.github.io/aws-lambda-powertools-dotnet/core/tracing/)** - provides a simple way to send traces from functions to AWS X-Ray to provide visibility into function calls, interactions with other AWS services, or external HTTP requests. Annotations easily can be added to traces to allow filtering traces based on key information. For example, when using Tracer, a ColdStart annotation is created for you, so you can easily group and analyze traces where there was an initialization overhead. + +### Installation + +The AWS Lambda Powertools for .NET utilities (.NET 6) are available as Nuget packages. You can install the packages from Nuget gallery or from Visual Studio editor. Search `AWS.Lambda.Powertools*` to see various utilities available.Powertools is available on NuGet. + +* [AWS.Lambda.Powertools.Logging](https://www.nuget.org/packages?q=AWS.Lambda.Powertools.Logging): + + `dotnet nuget add AWS.Lambda.Powertools.Logging` + +* [AWS.Lambda.Powertools.Metrics](https://www.nuget.org/packages?q=AWS.Lambda.Powertools.Metrics): + + `dotnet nuget add AWS.Lambda.Powertools.Metrics` + +* [AWS.Lambda.Powertools.Tracing](https://www.nuget.org/packages?q=AWS.Lambda.Powertools.Tracing): + + `dotnet nuget add AWS.Lambda.Powertools.Tracing` + +## Examples + +We have provided examples focused specifically on each of the utilities. Each solution comes with AWS Serverless Application Model (AWS SAM) templates to run your functions as Zip package using the AWS Lambda .NET 6 managed runtime, or as a container package using the AWS base images for .NET. + +* **[Logging example](examples/Logging/README.md)** +* **[Metrics example](examples/Metrics/README.md)** +* **[Tracing example](examples/Tracing/README.md)** + +## Other members of the AWS Lambda Powertools family + +Not using .NET? No problem we have you covered. Here are the other members of the AWS Lambda Powertools family: + +* [AWS Lambda Powertools for Python](https://github.com/awslabs/aws-lambda-powertools-python) +* [AWS Lambda Powertools for Java](https://github.com/awslabs/aws-lambda-powertools-java) +* [AWS Lambda Powertools for TypeScript](https://github.com/awslabs/aws-lambda-powertools-typescript) + +## Credits + +* Structured logging initial implementation from [aws-lambda-logging](https://gitlab.com/hadrien/aws_lambda_logging) +* Powertools idea [DAZN Powertools](https://github.com/getndazn/dazn-lambda-powertools/) + +## Connect + +* **AWS Developers Slack**: `#lambda-powertools` - **[Invite, if you don't have an account](https://join.slack.com/t/awsdevelopers/shared_invite/zt-yryddays-C9fkWrmguDv0h2EEDzCqvw)** +* **Email**: aws-lambda-powertools-feedback@amazon.com ## License This project is licensed under the Apache-2.0 License. - diff --git a/apidocs/api/.gitignore b/apidocs/api/.gitignore new file mode 100644 index 000000000..f798527e6 --- /dev/null +++ b/apidocs/api/.gitignore @@ -0,0 +1,5 @@ +############### +# temp file # +############### +*.yml +.manifest diff --git a/apidocs/api/index.md b/apidocs/api/index.md new file mode 100644 index 000000000..e69de29bb diff --git a/apidocs/docfx.json b/apidocs/docfx.json new file mode 100644 index 000000000..00f5ca4fb --- /dev/null +++ b/apidocs/docfx.json @@ -0,0 +1,60 @@ +{ + "metadata": [ + { + "src": [ + { + "files": [ + "**/*.csproj" + ], + "src": "../libraries/src/", + "force": true + } + ], + "dest": "api", + "disableGitFeatures": false, + "disableDefaultFilter": false + } + ], + "build": { + "content": [ + { + "files": ["api/**.yml", "api/index.md"] + }, + { + "files": ["toc.yml", "*.md"] + } + ], + "resource": [ + { + "files": [ + "images/**" + ] + } + ], + "overwrite": [ + { + "files": ["apidoc/**.md"], + "exclude": ["obj/**", "_site/**"] + } + ], + "dest": "_site", + "globalMetadataFiles": [], + "globalMetadata": { + "_appTitle": "AWS Lambda Powertools for .NET", + "_appFaviconPath": "images/favicon.ico", + "_appLogoPath": "images/img.svg", + "_enableNewTab": true, + "_disableContribution": true, + "_enableSearch": "true", + "_appFooter": "AWS Lambda Powertools for .NET" + }, + "fileMetadataFiles": [], + "template": ["default", "templates/material"], + "postProcessors": ["ExtractSearchIndex"], + "markdownEngineName": "markdig", + "noLangKeyword": false, + "keepFileLink": false, + "cleanupCacheHistory": false, + "disableGitFeatures": false + } +} \ No newline at end of file diff --git a/apidocs/images/favicon.ico b/apidocs/images/favicon.ico new file mode 100644 index 000000000..dba84c499 Binary files /dev/null and b/apidocs/images/favicon.ico differ diff --git a/apidocs/images/img.svg b/apidocs/images/img.svg new file mode 100644 index 000000000..8d3ee48d7 --- /dev/null +++ b/apidocs/images/img.svg @@ -0,0 +1,38 @@ + + + diff --git a/apidocs/index.md b/apidocs/index.md new file mode 100644 index 000000000..ab3e571d6 --- /dev/null +++ b/apidocs/index.md @@ -0,0 +1,14 @@ +# AWS Lambda Powertools for .NET API + +Welcome to the *AWS Lambda Powertools for .NET* API reference. This documentation contains the API details for all supported utilities. + +To get started use the `API` menu on the navigation bar, or search for specific keywords on the search box on top-right corner of your screen. + +> [!NOTE] +> Are you looking for documentation on how to use AWS Lambda Powertools for .NET utilities and code samples? +> +> 👉 [Here](https://awslabs.github.io/aws-lambda-powertools-dotnet/) is the perfect place to start. + +## Feedback + +If you have any feedback, create a new issue in the *AWS Lambda Powertools for .NET* repository on [GitHub](https://github.com/awslabs/aws-lambda-powertools-dotnet/issues). diff --git a/apidocs/templates/material/partials/head.tmpl.partial b/apidocs/templates/material/partials/head.tmpl.partial new file mode 100644 index 000000000..8d9c10c7e --- /dev/null +++ b/apidocs/templates/material/partials/head.tmpl.partial @@ -0,0 +1,21 @@ +{{!Copyright (c) Oscar Vasquez. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} + + + + +
+ =0;r--){for(var c=t.words[r],f=u-1;f>=0;f--){var l=c>>f&1;i!==n[0]&&(i=this.sqr(i)),0!==l||0!==s?(s<<=1,s|=l,(4===++a||0===r&&0===f)&&(i=this.mul(i,n[s]),a=0,s=0)):a=0}u=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,S),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,n(57)(e))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return C})),n.d(t,"c",(function(){return P})),n.d(t,"d",(function(){return N})),n.d(t,"e",(function(){return V})),n.d(t,"f",(function(){return F})),n.d(t,"g",(function(){return te})),n.d(t,"h",(function(){return j})),n.d(t,"i",(function(){return re}));
+/*!
+ * Copyright 2016 Amazon.com,
+ * Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Amazon Software License (the "License").
+ * You may not use this file except in compliance with the
+ * License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/asl/
+ *
+ * or in the "license" file accompanying this file. This file is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, express or implied. See the License
+ * for the specific language governing permissions and
+ * limitations under the License.
+ */
+var r=function(){function e(e){var t=e||{},n=t.ValidationData,r=t.Username,i=t.Password,o=t.AuthParameters,s=t.ClientMetadata;this.validationData=n||{},this.authParameters=o||{},this.clientMetadata=s||{},this.username=r,this.password=i}var t=e.prototype;return t.getUsername=function(){return this.username},t.getPassword=function(){return this.password},t.getValidationData=function(){return this.validationData},t.getAuthParameters=function(){return this.authParameters},t.getClientMetadata=function(){return this.clientMetadata},e}(),i=n(6),o=n(32),s=n.n(o),a=(n(161),n(87)),u=n.n(a),c=n(75),f=n.n(c),l=n(250);var d,h=function(){function e(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length}var t=e.prototype;return t.random=function(t){for(var n=[],r=0;r