Package: pspring-aws
pspring-awsThis framework is member of pspring based family of frameworks. It provides a means to access aws resources with minimal code.boto3library is used internally for http requests.All the default variables are listed in defaultvars.pyAnnotations / Decorators that come along with this framework are listed below@SecretValue(name="",region="",column="",columns=[])This is a class decorator can be used to retrieve value of secret in AWS secrets manager. We could also specify a list of columns or a single column name from the secret response to be retrived. A method named "getSecretValue" will be available on the class.@DynamoDBTable(tableName="",primaryKey="",sortKey="",ttlColumnName="",ttl="")This is a class decorator which can be tagged with a dynamodb table. Once tagged with this decorator, the class will have implementations ofgetandputmethods.get(self,primaryKey,sortKey="",columns="",column="")method can be used to retrive only specific columnsput(self,data)can be used to insert data@LambdaHandler(type="lambdaproxy")This is a class decorator which provides below functionalities. You should implement "handler" method which will be enhanceddebug,info,warn,error - This will log a message will required tracking fields like requestId etc.handle cold start requests with requestId = "COLD_START_WARMER"addToLogger method can be used to add a field to all logging messages.returns a 200 response along with the dictionary returned from the "handler" method as json.handles all exceptions and returns gracefully a 500 Internal server error.Below exceptions are available from this frameworkLambdaExceptionNotFoundExceptionUnAuthorizedExceptionInternalServerExceptionCreatedExceptionRedirectExceptionRealTimeSecretsMgrConfigProviderThis along withhttps://github.com/vasudevan-palani/appsync-client.gitworks as a real time secrets manager ( what this means is, you will get notified about the changes to secrets mngr's value as a push event )frompspringimportConfigurationconfig=Configuration.getConfig(__name__)Configuration.initializer([RealTimeSecretsMgrConfigProvider(secretId="mysecretId",region="us-east-1")])SecretsMgrConfigProviderConfigurationProvider for secrets manager in aws to work alongside pspring.ConfigurationfrompspringimportConfigurationconfig=Configuration.getConfig(__name__)Configuration.initializer([SecretsMgrConfigProvider(secretId="mysecretId",region="us-east-1")])SecretsManagerUtility class to interact with aws secrets manager encapsulating the boiler plate codefrompspringawsimportSecretsManagersecretsmngr=SecretsManager(secretId="mysecretId")secretsmngr.getSecretValue()DynamoDBTableUtility class to interact with aws dynamodb encapsulating the boiler plate codefrompspringawsimportDynamoDBTablesecretsmngr=DynamoDBTable(tableName="mytable",primaryKey="primaryKey",sortKey="sortKey")item=secretsmngr.get("primaryKeyValue")item=secretsmngr.put(primaryKeyValue,item)Example:frompspringimport*frompspringawsimport*@LambdaHandler()classMyHandler():@Autowired()def__init__(self,customerbackend:CustomerBackend,cache:DataCache):self.customerbackend=customerbackendself.cache=cachedefhandler(self,event,context):returnself.customerbackend(...)context.initialize()newhandler=MyHandler()defhandler(event,context):returnnewhandler.handler(event,context)To do:Support Lambda integration types