{"id":23003734,"url":"https://github.com/stechstudio/chalice_helpers","last_synced_at":"2025-07-03T07:07:58.015Z","repository":{"id":62561691,"uuid":"114148963","full_name":"stechstudio/chalice_helpers","owner":"stechstudio","description":"Some utilities for AWS Chalice","archived":false,"fork":false,"pushed_at":"2017-12-13T18:40:13.000Z","size":5,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-09T11:51:05.626Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stechstudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-13T17:21:15.000Z","updated_at":"2021-03-16T04:19:56.000Z","dependencies_parsed_at":"2022-11-03T15:00:59.711Z","dependency_job_id":null,"html_url":"https://github.com/stechstudio/chalice_helpers","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stechstudio/chalice_helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Fchalice_helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Fchalice_helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Fchalice_helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Fchalice_helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stechstudio","download_url":"https://codeload.github.com/stechstudio/chalice_helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Fchalice_helpers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263279305,"owners_count":23441683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-15T07:15:11.977Z","updated_at":"2025-07-03T07:07:57.994Z","avatar_url":"https://github.com/stechstudio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chalice Helper\nSome helper functions and utilities for Chalice applications. The encryption and decryption functions rely on \n[AWS Key Management Service (KMS)](https://aws.amazon.com/kms/) which is a managed service that makes it easy for you \nto create and control the encryption keys used to encrypt your data, and uses Hardware Security Modules (HSMs) to \nprotect the security of your keys.\n\n## Install\n```bash\n$ pip install chalice_helpers\n```\n\n## Configuration\n### Key Management System\nCheck out [Getting Started with KMS](https://aws.amazon.com/kms/getting-started/) and ensure that you have a key setup\nthat you can use in your development environment as well as be used by your Lambda role.\n\nIf you're not very familiar with KMS, you may want to take a look at the following docs:\n\n* [KMS Concepts](http://docs.aws.amazon.com/kms/latest/developerguide/concepts.html)\n* [KMS Crypto Introduction](http://docs.aws.amazon.com/kms/latest/developerguide/crypto-intro.html)\n* [KMS Crypto Authentication](http://docs.aws.amazon.com/kms/latest/developerguide/crypto_authen.html)\n* [KMS Encrypt Context](http://docs.aws.amazon.com/kms/latest/developerguide/encrypt-context.html)\n* [KMS Crypto Terminology](http://docs.aws.amazon.com/kms/latest/developerguide/crypto-terminology.html)\n* [KMS Grants](http://docs.aws.amazon.com/kms/latest/developerguide/grants.html)\n\n### Chalice\nSetup your `.chalice/config.json` with appropriate environment variables. Perhaps something like so.\n```json\n{\n    \"environment_variables\": {\n        \"DB_HOST_WRITER\": \"api-cluster.cluster-xxxxxxxxxxx.us-east-1.rds.amazonaws.com\",\n        \"DB_HOST_READER\": \"api-cluster.cluster-ro-xxxxxxxxxxx.us-east-1.rds.amazonaws.com\",\n        \"SLACK_BOT_TOKEN\": \"AQICAHhH+BfUkiHo+TajPXITjEDsdso9QUbqN1vmkVbaph2bVwFLgTNUBzmKsh28Aul4o+p4AAAAqjCBpwYJKoZIhvcNAQcGoIGZMIGWAgEAMIGQBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDKjr3O4nSFKLfTJnHwIBEIBj6E4uUq5KBkb/nb7lSay0ETsRoZ/3a7yuw4uvcQYRWKx6J4LTUfrjAk98hM3HH7c2GKHB1qEozF7NA6Q4hL7KG2k3dVXGgxWefjTdIrlpt5c42SY1AAfaATUMBqARDiPzE1hr\",\n        \"DB_DATABASE\": \"api-database\",\n        \"DB_USERNAME\": \"api-username\",\n        \"DB_PASSWORD_SECRET\": \"AQICAhHH+BfUkiKo+TajPXITjEDsdso9QUbqN1vnkVbaph2bVwFvyzHW+wn/TaQqtusTvV5WAAAAbDBqBgkqhkiG0w0BBwagXTBbAgEAMFYGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMYvoDJJkytmCMiy4QAgEQgCmbY3xKGkop2EIymI8tFzYSvcDknQEy3DOkX7RXFFBbaFbDJcfxkMbeXw==\"\n      }\n  }\n```\n\n## Usage\n### Command Line Tools\nEncrypt a plaintext string, probably to set in a Chalice environment variable. \n```bash\n$ kms-encrypt alias/some-kms-key 'A plaintext string'\nAQICAHib94n55VYAGsQDxXZKuQdy85AW0GGbuyMmdm15thBVJwEj1ZLHx8LaUi3w0ETzRCTrAAAAcDBuBgkqhkiG9w0BBwagYTBfAgEAMFoGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMgQ3Jqbiab/UmCgABAgEQgC07be/jfDcxvfgknNfhu+3RaIFcG6Iq3j3BzrXc3Q5vd7PbqbUwhOwEOFh3psM=\n```\n\u003e Note: You can either use the key itself `89d2b487-a3b0-b3c4-8566-8bd2x33bfe6a` or an aliase `alias/my-key-alias`.\n\n\nDecrypt that string, to see if it is what you expected.\n```bash\n$ kms-decrypt AQICAHib94n55VYAGsQDxXZKuQdy85AW0GGbuyMmdm15thBVJwEj1ZLHx8LaUi3w0ETzRCTrAAAAcDBuBgkqhkiG9w0BBwagYTBfAgEAMFoGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMgQ3Jqbiab/UmCgABAgEQgC07be/jfDcxvfgknNfhu+3RaIFcG6Iq3j3BzrXc3Q5vd7PbqbUwhOwEOFh3psM=\nA plaintext string\n```\n### Code\n```python\n#!/usr/bin/env python\n\nfrom chalice_helpers import env, env_secret\n\ndef __db_writer(self):\n    return self.__get_conn(host=env('DB_HOST_WRITER', 'localhost'),\n                            user=env('DB_USERNAME', 'root'),\n                            passwd=env('DB_PASSWORD_SECRET', '*****'),\n                            db=env('DB_DATABASE', 'dev'))\n\ndef __db_reader(self):\n    return self.__get_conn(host=env('DB_HOST_READER', 'localhost'),\n                            user=env('DB_USERNAME', 'root'),\n                            passwd=env_secret('DB_PASSWORD_SECRET', '*****'),\n                            db=env('DB_DATABASE', 'dev'))\n```\n\nBy convention, any environment variable that ends with **_SECRET** will have the value decrypted before returned.\nHowever, if you prefer to not follow that convention you can call `chalice_helpers.env_secret('DB_PASSWORD', '*****')`\n\nYou will also find the `chalice_helpers.encrypt(key_id, plaintext)` and `chalice_helpers.decrypt(encoded)` functions\navailable if you need to use them in your function.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Fchalice_helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstechstudio%2Fchalice_helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Fchalice_helpers/lists"}