This is a simple weather widget built using a Lambda and API Gateway.
The Lambda is responsible for making API calls and fetching the weather for your location which is geolocated using your IP Address. This of course isn't a super accurate identifier, so I have added support of passing query string parameters for finer grained control on the weather data that is returned.
This project is built using TypeScipt and Terraform and hosted on the AWS cloud.
Simply deploy the project and access it via the api gateway url you will receive in the deployment stage.
By default the lambda will use your IP address for geo-location and fetching of weather. However this is not super accurate and can be spoofed, this is why i added support for query string params. You are able to pass a city parameter to allow more fine grain control. If a query string is passed, it will be preffered to the IP address.
This project uses WeatherStack for its weather forecasts. You will need to apply for an free API key from them.
- Grab an
API keyfrom WeatherStack - Encrypt
API keyusing KMS and place in terraform config file - Deploy 🚀
The deployment is handled using Terraform 🏗
- Run
yarn zipto archive together the code - Run
yarn buildto compile ts code to js code - Run
yarn tf:initto get aws provider plugin downloaded - Run
yarn tf:planto see changes that will be made - Run
yarn tf:applyto actually make those changes to your provider - Visit AWS and see all your services provisioned via terraform
- Run
yarn tf:destroyto destroy all the services that were built
You can also simply call yarn deploy:all to both zip up an archive and provision the resources together. As well as calling yarn update:all to completely destroy and re-deploy resources.
This project makes use of Amazon KMS for encryption and decryption of sensitive variables.
Note: You may need to set a KMS key up if you dont already have one, you may also need the AWS CLI to encrypt variables.
In the terraform config directory is a tfvars file which will need to be updated with your KMS encrypted variables. Once this is done and your KMS key is allowed to consumed by your lambda you should be able to decrypt the values on the lambda itself.
☀️🌤🌧⛈🌨❄️

