-
Notifications
You must be signed in to change notification settings - Fork 444
docs(parameters): snippets split, improved, and lint #1564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
leandrodamascena
merged 25 commits into
aws-powertools:develop
from
leandrodamascena:chore/parameters
Jan 31, 2023
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
bc59b7e
chore(parameters): refactoring examples
leandrodamascena 6e16fe3
chore(parameters): adding cache examples
leandrodamascena ba51315
chore(parameters): adding builtin examples and fix mypy errors
leandrodamascena 7119d93
chore(parameters): adding all providers with custom config
leandrodamascena fd69844
chore(parameters): adding custom provider
leandrodamascena 0ce8f42
chore(parameters): adding custom provider
leandrodamascena cd85cfb
chore(parameters): adding custom provider
leandrodamascena abe8d72
chore(parameters): adding DynamoDB provider
leandrodamascena f7ba42c
chore(parameters): adding tests - mock
leandrodamascena 0231759
chore(parameters): adding more tests
leandrodamascena 2e7c570
chore(parameters): adding appconfig builtin provider
leandrodamascena ae995d6
chore(parameters): adding final examples
leandrodamascena 57b788e
chore(parameters): adding final examples
leandrodamascena 1da673d
chore(parameters): highlights - small changes
leandrodamascena 1f7d9bc
Merge branch 'develop' into chore/parameters
leandrodamascena 68358cd
fix(docs): broken link in boto3_session
heitorlessa ce369c6
fix(docs): improve constrast ratio
heitorlessa 8ee7c25
fix(docs): typing and correctness on null endpoint
heitorlessa f3374eb
Merge branch 'develop' into chore/parameters
leandrodamascena b140445
(merge): merging
leandrodamascena e86e7b0
(merge): merging
leandrodamascena 31c4b31
(chore): addressing Ruben's feedbacks
leandrodamascena b423a3e
(chore): import errors
leandrodamascena 3a2fe3e
(merge): merging
leandrodamascena 8f9f384
(merge): merging
leandrodamascena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
chore(parameters): refactoring examples
- Loading branch information
commit bc59b7e6b9d659d01a86add872c2d495aa6099b5
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import requests | ||
|
||
from aws_lambda_powertools.utilities import parameters | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
|
||
|
||
def lambda_handler(event: dict, context: LambdaContext): | ||
try: | ||
# Retrieve a single parameter | ||
endpoint_comments: bytes = parameters.get_app_config(name="config", environment="dev", application="comments") | ||
print(endpoint_comments) | ||
|
||
# the value of this parameter is https://jsonplaceholder.typicode.com/comments/ | ||
comments: requests.Response = requests.get(endpoint_comments) | ||
|
||
return {"comments": comments.json()[:10], "statusCode": 200} | ||
except parameters.exceptions.GetParameterError as error: | ||
return {"comments": None, "message": str(error), "statusCode": 400} |
23 changes: 23 additions & 0 deletions
23
examples/parameters/src/getting_started_recursive_ssm_parameter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import requests | ||
|
||
from aws_lambda_powertools.utilities import parameters | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
|
||
|
||
def lambda_handler(event: dict, context: LambdaContext): | ||
try: | ||
# Retrieve a single parameter | ||
all_parameters: dict = parameters.get_parameters("/lambda-powertools/") | ||
endpoint_comments = "https://jsonplaceholder.typicode.com/noexists/" | ||
|
||
for parameter, value in all_parameters.items(): | ||
|
||
if parameter == "endpoint_comments": | ||
endpoint_comments = value | ||
|
||
# the value of parameter is https://jsonplaceholder.typicode.com/comments/ | ||
comments: requests.Response = requests.get(endpoint_comments) | ||
|
||
return {"comments": comments.json()[:10]} | ||
except parameters.exceptions.GetParameterError as error: | ||
return {"comments": None, "message": str(error), "statusCode": 400} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import requests | ||
|
||
from aws_lambda_powertools.utilities import parameters | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
|
||
|
||
def lambda_handler(event: dict, context: LambdaContext): | ||
|
||
try: | ||
# Usually an endpoint is not sensitive data, so we store it in SSM Parameters | ||
endpoint_comments: str = parameters.get_parameter("/lambda-powertools/endpoint_comments") | ||
# An API-KEY is a sensitive data and should be stored in SecretsManager | ||
api_key: str = parameters.get_secret("/lambda-powertools/api-key") | ||
|
||
headers: dict = {"X-API-Key": api_key} | ||
|
||
comments: requests.Response = requests.get(endpoint_comments, headers=headers) | ||
|
||
return {"comments": comments.json()[:10], "statusCode": 200} | ||
except parameters.exceptions.GetParameterError as error: | ||
return {"comments": None, "message": str(error), "statusCode": 400} |
17 changes: 17 additions & 0 deletions
17
examples/parameters/src/getting_started_single_ssm_parameter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import requests | ||
|
||
from aws_lambda_powertools.utilities import parameters | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
|
||
|
||
def lambda_handler(event: dict, context: LambdaContext): | ||
try: | ||
# Retrieve a single parameter | ||
endpoint_comments: str = parameters.get_parameter("/lambda-powertools/endpoint_comments") | ||
|
||
# the value of this parameter is https://jsonplaceholder.typicode.com/comments/ | ||
comments: requests.Response = requests.get(endpoint_comments) | ||
|
||
return {"comments": comments.json()[:10], "statusCode": 200} | ||
except parameters.exceptions.GetParameterError as error: | ||
return {"comments": None, "message": str(error), "statusCode": 400} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.