- Notifications
You must be signed in to change notification settings - Fork14
A Python library with convenience helpers for working with the AWS Serverless Application Repository.
License
amazon-archives/aws-serverlessrepo-python
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A Python library with convenience helpers for working with theAWS Serverless Application Repository.
Simply use pip to install the library:
pip install serverlessrepoThe serverlessrepo module provides a simple interface for publishing applications and managing application permissions. To get started, import the serverlessrepo module:
importserverlessrepo
Given anAWS Serverless Application Model (SAM) template, it publishes a new application using the specified metadata in AWS Serverless Application Repository. If the application already exists, it updates metadata of the application and publishes a new version if specified in the template.
For example:
importboto3importyamlfromserverlessrepoimportpublish_applicationsar_client=boto3.client('serverlessrepo',region_name='us-east-1')withopen('template.yaml','r')asf:template=f.read()# if sar_client is not provided, we will initiate the client using region inferred from aws configurationsoutput=publish_application(template,sar_client)# Alternatively, pass parsed template as a dictionarytemplate_dict=yaml.loads(template)output=publish_application(template_dict,sar_client)
The output ofpublish_application has the following structure:
{ 'application_id': 'arn:aws:serverlessrepo:us-east-1:123456789012:applications/test-app', 'actions': ['CREATE_APPLICATION'], 'details': { 'Author': 'user1', 'Description': 'hello', 'Name': 'hello-world', 'SemanticVersion': '0.0.1', 'SourceCodeUrl': 'https://github.com/hello'} }}There are three possible values for theactions field:
['CREATE_APPLICATION']- Created a new application.['UPDATE_APPLICATION']- Updated metadata of an existing application.['UPDATE_APPLICATION', 'CREATE_APPLICATION_VERSION']- Updated metadata of an existing application and created a new version, only applicable if a new SemanticVersion is provided in the input template.
details has different meaning based on theactions taken:
- If a new application is created, it shows metadata values used to create the application.
- If application is updated, it shows updated metadata values.
- If application is updated and new version is created, it shows updated metadata values as well as the new version number.
Parses the application metadata from the SAM template and only updates the metadata.
For example:
importboto3importyamlfromserverlessrepoimportupdate_application_metadatasar_client=boto3.client('serverlessrepo',region_name='us-east-1')withopen('template.yaml','r')asf:template=f.read()application_id='arn:aws:serverlessrepo:us-east-1:123456789012:applications/test-app'# if sar_client is not provided, we will initiate the client using region inferred from aws configurationsupdate_application_metadata(template,application_id,sar_client)# Alternatively, pass parsed template as a dictionarytemplate_dict=yaml.loads(template)update_application_metadata(template_dict,application_id,sar_client)
Makes an application public so that it's visible to everyone.
Makes an application private so that it's only visible to the owner.
Shares the application with specified AWS accounts.
importboto3fromserverlessrepoimport (make_application_public,make_application_private,share_application_with_accounts)application_id='arn:aws:serverlessrepo:us-east-1:123456789012:applications/test-app'sar_client=boto3.client('serverlessrepo',region_name='us-east-1')# Share an application publiclymake_application_public(application_id,sar_client)# Make an application privatemake_application_private(application_id,sar_client)# Share an application with other AWS accountsshare_application_with_accounts(application_id, ['123456789013','123456789014'],sar_client)
- Fork the repository, then clone to your local:
git clone https://github.com/<username>/aws-serverlessrepo-python.git
- Set up the environment:
make init - Install new packages:
pipenv install [package names]- Pipenv will automatically updatePipfile andPipfile.lock for you.
- Add new dependencies tosetup.py install_requires if they are needed for consumers of this library.
- Verify that everything works:
make build- You can run
make testseparately to verify that tests pass. - Check code style with
make flakeandmake lint.
- You can run
- Make code changes, run all verifications again before sending a Pull Request:
make pr
This library is licensed under the Apache 2.0 License.
About
A Python library with convenience helpers for working with the AWS Serverless Application Repository.
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Contributors4
Uh oh!
There was an error while loading.Please reload this page.