This project is a Weather Validator that uses AWS services (Lambda, RDS, S3, and API Gateway, VPC, NAT Gateway, Internet Gateway, etc). The architecture can be seen below:
The application has a frontend component, using HTML, CSS, and JavaScript. The backend is composed of Lambda functions written in Java. The database is an RDS PostgreSQL instance.
For Local Development:
- Docker
- Java 21
- Maven (3.9.9)
- Node.js (v23.5.0)
- Terraform (v1.9.3) + terraform-local
- LocalStack (for local development)
- AWS CLI
- Open Weather API key (free tier) - to include in terraform/variables.tf and terraform-local/variables.tf
For Deployment to AWS:
- AWS CLI
- Terraform (v1.9.3)
Before proceeding, make sure you have the AWS CLI configured with the necessary permissions (use aws configure). Additionally, your account will need a user with AdministratorAccess policy attached.
In other words:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}For a fast and easy deployment, you can use the following steps.
The Lambda jar files are already included in the project.
cd terraform
terraform init
terraform plan
terraform apply --auto-approveOnce this is done, you will need to run the following command to create the database tables:
aws lambda invoke --function-name db-setup --region us-east-1 output.json See the CloudFront URL in the output of the Terraform run. You can access the application using this URL. That's it! You have successfully deployed the Weather Validator project to AWS.
Backend:
- change java files in the
backenddirectory - run
mvn clean installin thebackenddirectory - run
aws lambda update-function-code --function-name history-lambda --zip-file fileb://history-lambda/target/history-lambda-1.0.0.jar- change according to the function you are updating
Frontend:
- change files in the
frontenddirectory - run
aws s3 sync ./ s3://weather-validator-bucketin thefrontenddirectory
Infrastructure:
- change
.tffiles in theterraformdirectory - run
terraform apply --auto-approvein theterraformdirectory
cd backend
mvn clean installInstall http-server:
npm install --global http-serveror
brew install http-serverThen:
cd frontend
http-serverYou can change the files as needed. The frontend will be available at http://localhost:8080.
After installing the LocalStack CLI (via pip or homebrew), run the following command:
DEBUG=1 localstack startDeploy Infrastructure Locally:
After installing terraform-local, run the following commands:
cd terraform-local
tflocal init
tflocal apply --auto-approveOnce this is done, you will need to run the following command to create the database tables:
awslocal lambda invoke --function-name db-setup --region us-east-1 output.json or
aws --endpoint=http://localhost.localstack.cloud:4566 lambda invoke --function-name db-setup --region us-east-1 output.jsonNote!
It could happen that the tflocal apply executes successfully, but the resources are not ready yet, hence the endpoints will not be available to pass to the Lambdas and environment variables.
Check the terraform.tfstate file, particularly for the HOST and PORT environment variables in the aws_lambda_function resource.
These are the endpoint and port for the RDS Proxy instance.
In this case, please run the command again. You will see that a few resources have changed:
Apply complete! Resources: 0 added, 8 changed, 0 destroyed.In the Check Weather tab, you can enter a city name and click the "Get Weather" button. The application will display the weather for the city you entered, along with the verdict: the weather must be over 20 degrees Celsius with no clouds. Otherwise, the application will display a message saying the weather is not nice.
The history tab will display the history of the cities you have checked the weather for. The full data from the Weather API can be copied to the clipboard by clicking the "Copy" button.
- Destroy the cloud resources:
cd terraform
terraform destroy- Destroy local resources:
cd terraform-local
tflocal destroyOr just shut down the LocalStack container:
localstack stop

