{"id":20284894,"url":"https://github.com/eelayoubi/aws-examples","last_synced_at":"2025-07-10T08:41:28.212Z","repository":{"id":121913504,"uuid":"289668000","full_name":"eelayoubi/aws-examples","owner":"eelayoubi","description":null,"archived":false,"fork":false,"pushed_at":"2020-08-25T18:26:03.000Z","size":3555,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-04T03:43:37.296Z","etag":null,"topics":["angular10","aws","aws-iot-device-sdk","awsiot","lambda","sap"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eelayoubi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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-08-23T10:59:03.000Z","updated_at":"2022-08-18T06:53:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"f3f34ca0-c91f-4664-a0c3-c1cc29450e4b","html_url":"https://github.com/eelayoubi/aws-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eelayoubi/aws-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelayoubi%2Faws-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelayoubi%2Faws-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelayoubi%2Faws-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelayoubi%2Faws-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eelayoubi","download_url":"https://codeload.github.com/eelayoubi/aws-examples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelayoubi%2Faws-examples/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264551988,"owners_count":23626614,"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":["angular10","aws","aws-iot-device-sdk","awsiot","lambda","sap"],"created_at":"2024-11-14T14:22:47.127Z","updated_at":"2025-07-10T08:41:28.173Z","avatar_url":"https://github.com/eelayoubi.png","language":"TypeScript","readme":"# Decoupling the Frontend using AWS IOT\n\nIn this example I walk you through how you can decouple your frontend using IOT. The front end is a very basic app, built with angular 10. The frontend consists of a page with one button, when clicked, it will send a request to the API Gateway to add an animal. Once the animal is added in DynamoDB, it will trigger a stream that will trigger a Lambda Function called 'AlertIOTFunction'. This function will publish the newly added animal to an IOT thing which the frontend is subscribing to using mqtt. So in the browser console you can see that we are printing that item coming from the IOT.\n\n## Getting Started\n\nIf you are using AWS API Gateway \u0026 lambda, then you are already aware of the limits. API Gateway has a limit of 29 seconds integration timeout (https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html). AWS Lambda has a limit of 15 minutes.\n\nWhat if our frontend wants to do an action, and that action will lead to other actions being executed.And once done, we want the frontend to be notified? Well in AWS there are several ways to do so. In this example we will use AWS IOT to have an async behaviour.\n\n### Prerequisites\n\nThe example is split to 2 parts:\n - backend (lambda function)\n - frontend (angular 10)\n\nYou need an AWS account, since we will be deploying the backend using SAM: \nhttps://aws.amazon.com/serverless/sam/\n\nWe also need the AWS cli to be installed (we will need it to get the IOT endpoint)\nhttps://aws.amazon.com/cli/\n\n\n### Installing\n\nLet's first deploy the backend:\n\nGo to the backend folder, specifically the iot, and enter the following command:\n\n\n```\nsam build\n```\n\nthis command will build the backend infrastructure. If everything went well it will ask you to run :\n\n```\nsam deploy --guided\n```\n\n- Enter a Stack Name: animals-backend \n- Enter an AWS Region: us-east-1\n- and choose 'y' for the followup questions\n\nYou can verify that everything went well in the terminal, or you can go AWS CloudFormation and find the 'animals-backend' stack that we just deployed\n\nOne thing we still need to do for the backend. We need to grab the AWS IOT endpoint and set it as an Environment Variable for the AlertIOTFunction Lambda function.\n\nin your terminal run the following command: \n\n```\naws iot describe-endpoint --endpoint-type iot:Data-ATS \n```\n\nThe result will be somethin like:\n\n```\n{\n    \"endpointAddress\": \"a1p23e2eds44s-ats.iot.us-east-1.amazonaws.com\"\n}\n```\n\nCopy the endpoint and go to AWS Lambda console, select the 'animals-backend-AlertIOTFunction-*' function, and add the following to the environment variables:\n- Key: IOT_DATA_ENDPOINT\n- Value: the endpoint you just copied\n\nAnd save.\n\nNow moving to the frontend. We will need to replace a couple of placeholders in the app.component.ts. So go to aws-examples, and run:\n\n```\nyarn\n```\n\nThen go to the app.component.ts file and replace the following with the relevant values:\n- api: replace it wit the gateway api that was deployed using sam (you can grab the endpointvia the AWS api gateway console), looks like: https://9e87dhaed.execute-api.us-east-1.amazonaws.com/Prod/\n- poolId: looks like 'us-east-1:e4803d3b-42d5-496f-9c5a-408f20eb28e4' // 'YourCognitoIdentityPoolId'\n- host: 'a1pwqjqny5t44s-ats.iot.us-east-1.amazonaws.com', // 'YourAwsIoTEndpoint', e.g. 'prefix.iot.us-east-1.amazonaws.com'\n\nAfter setting these values, you can run:\n\n```\nyarn start\n```\n\nAnd then navigate to : localhost:4200\n\n## License\n\nThis project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3 - see the [LICENSE.md](LICENSE.md) file for details","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feelayoubi%2Faws-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feelayoubi%2Faws-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feelayoubi%2Faws-examples/lists"}