{"id":22477250,"url":"https://github.com/base2services/demo-aws-sam-cdk","last_synced_at":"2025-03-27T17:44:30.980Z","repository":{"id":145344174,"uuid":"297230537","full_name":"base2Services/demo-aws-sam-cdk","owner":"base2Services","description":null,"archived":false,"fork":false,"pushed_at":"2020-09-21T04:46:09.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-01T20:46:23.209Z","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/base2Services.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-21T04:43:32.000Z","updated_at":"2020-09-28T06:34:36.000Z","dependencies_parsed_at":"2023-07-03T09:17:21.151Z","dependency_job_id":null,"html_url":"https://github.com/base2Services/demo-aws-sam-cdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base2Services%2Fdemo-aws-sam-cdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base2Services%2Fdemo-aws-sam-cdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base2Services%2Fdemo-aws-sam-cdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base2Services%2Fdemo-aws-sam-cdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/base2Services","download_url":"https://codeload.github.com/base2Services/demo-aws-sam-cdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245897366,"owners_count":20690455,"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-06T14:09:59.210Z","updated_at":"2025-03-27T17:44:30.975Z","avatar_url":"https://github.com/base2Services.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS SAM With AWS CDK\n\nThis is a simple api that returns a random food selection for either /veggies or /fruit.\n\nThe cloudformation is written in python using the aws-cdk library and transformed into a sam tempate. from that point the sam-cli is used to managed the stacks and local testing \n\n*NOTE: All the following shell commands are in the context of the root of the repository directory unless specified*\n\n## Requirements\n\n1. aws-cdk - [install](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html#getting_started_install)\n2. sam-cli - [install](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)\n\n## Setup Python Environment\n\n1. clone and cd into the repo\n\n2. setup the python environment\n\n    ```sh\n    python -m venv .env\n    source .env/bin/activate\n    ```\n\n3. install depencies\n\n    ```sh\n    pip install -r requirements.txt\n    ```\n\n## Deploying\n\n1. transfor the cdk to a SAM cloudformation template\n\n    ```sh\n    cdk synth \u003e template.yaml\n    ```\n\n2. build the sam functions\n\n    ```sh\n    sam build\n    ```\n\n3. deploy the stack\n\n    ```sh\n    sam deploy\n    ```\n\n## SAM Local Tests\n\n1. transfor the cdk to a SAM cloudformation template\n\n    ```sh\n    cdk synth \u003e template.yaml\n    ```\n\n2. build the sam functions\n\n    ```sh\n    sam build\n    ```\n\n3. test a function\n\n    ```sh\n    $ sam local invoke FruitFunction\n    ```\n\n    Output \n\n    ```sh\n    Invoking app.lambda_handler (python3.8)\n    Image was not found.\n    Building image................................................................................................................................................................................................................................................................................................................................................................................................................................................................\n    Failed to download a new amazon/aws-sam-cli-emulation-image-python3.8:rapid-1.0.0 image. Invoking with the already downloaded image.\n    Mounting /Users/gus/src/demo/demo-aws-sam-cdk/.aws-sam/build/FruitFunction as /var/task:ro,delegated inside runtime container\n    START RequestId: a997f24f-5b57-1163-caf3-2e96acff1dde Version: $LATEST\n    END RequestId: a997f24f-5b57-1163-caf3-2e96acff1dde\n    REPORT RequestId: a997f24f-5b57-1163-caf3-2e96acff1dde\tInit Duration: 219.56 ms\tDuration: 5.11 ms\tBilled Duration: 100 ms\tMemory Size: 128 MB\tMax Memory Used: 24 MB\n\n    {\"statusCode\":200,\"body\":\"{\\\"selection\\\": \\\"kiwi fruit\\\"}\"}\n    ```\n\n## PyTest\n\n1. install test dependencies\n\n    ```sh\n    pip install -r requirements-dev.txt\n    ```\n\n2. run unit tests\n\n    ```sh\n    python -m pytest\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase2services%2Fdemo-aws-sam-cdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbase2services%2Fdemo-aws-sam-cdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase2services%2Fdemo-aws-sam-cdk/lists"}