Watch Your Fleet Move LIVE - Asset Tracking with Amazon Location & IoT Core
Asset tracking is essential in modern logistics and supply chain operations. Knowing where assets such as trucks or delivery vehicles are located can significantly enhance operational efficiency, reduce costs, and prevent losses. In this detailed walkthrough, we'll explore Amazon Location Service, its use cases, and how to set up a fully functional asset tracking application integrated with AWS IoT Core.
π― What is Amazon Location?β
Amazon Location is a managed service from AWS that allows developers to add location data and functionality such as maps, geocoding, routing, geofencing, and tracking into their applications. It sources data from trusted global providers like Esri, HERE, and OpenStreetMap.
Key Features:β
- Maps & Geospatial Visualization
- Real-Time Tracking
- Geofence Monitoring
- Cost-effective location solutions
Use cases include:
- Fleet tracking
- Delivery route optimization
- Asset protection
- Consumer app geolocation
π Use Casesβ
Geofencing and Proximity-Based Alertsβ
- Use Case: Setting up virtual boundaries (geofences) around specific areas and triggering actions or notifications when devices or users enter or exit these zones.
- Benefit: Security alerts (e.g., unauthorized entry into a restricted area), location-based marketing (e.g., promotional offers to customers), and workflow automation (e.g., clocking in/out field employees). A retail store could notify users when they enter a geofence around the store.
Real-time Asset Tracking and Managementβ
- Use Case: Businesses with fleets of vehicles, equipment, or personnel can track their real-time locations on a map.
- Benefit: Improved operational efficiency, optimized routing, enhanced security, and better resource allocation. For example, dispatching the nearest available driver for a delivery.
Route Planning and Optimizationβ
- Use Case: Calculating optimal routes for navigation considering traffic, road closures, and preferred transport modes.
- Benefit: Reduced travel time, lower fuel costs, improved delivery efficiency, and better user guidance.
π§± Architecture Overviewβ
To better understand the technical setup and flow, let's break down the detailed architecture used in this asset tracking solution. This architecture not only supports real-time tracking but also historical location data, scalable device input, and geofence event handling.
Core Components:β
- Amazon Location Service: Provides maps, geofences, and trackers.
- AWS IoT Core: Acts as the entry point for location data using MQTT.
- Amazon Kinesis Data Streams: Streams live device location data for processing.
- AWS Lambda: Used for transforming data and invoking downstream services like Amazon Location or notifications.
- Amazon SNS: Sends real-time alerts or notifications to subscribed users (e.g., when a geofence is breached).
- Amazon Cognito: Authenticates users for frontend access and API interactions.
- Amazon CloudFront + S3: Hosts the web-based frontend application securely and globally.
Data Flow:β
- A GPS-enabled device or simulation sends a location update to AWS IoT Core using MQTT.
- The update is routed to Kinesis Data Streams for real-time processing.
- An AWS Lambda function processes the Kinesis records and forwards the location to the Amazon Location Tracker.
- If the location triggers a geofence event, another Lambda function can be used to publish a message to Amazon SNS.
- SNS sends out a notification to subscribers, such as mobile users, application dashboards, or administrators.
- The frontend web application, hosted on S3 + CloudFront, visualizes live and historical positions by querying Amazon Location services directly using the credentials from Amazon Cognito.
The architecture consists of Amazon Location for geospatial services, AWS Lambda for processing events, and Amazon SNS to send notifications to end users.
π Setting Up the Projectβ
To demonstrate Amazon Location's capabilities, we'll build a web application that displays current and historical locations of assets. We'll simulate an IoT device and stream location updates to AWS using MQTT.
1. Clone the Sample Projectβ
git clone https://github.com/aws-solutions-library-samples/guidance-for-tracking-assets-and-locating-devices-using-aws-iot.git --recurse-submodules
cd guidance-for-tracking-assets-and-locating-devices-using-aws-iot
2. Install Frontend Dependenciesβ
cd amazon-location-samples-react/tracking-data-streaming
npm install
3. Deploy Location Infrastructureβ
chmod +x deploy_cloudformation.sh && export AWS_REGION=<your region> && ./deploy_cloudformation.sh
4. Deploy IoT Core Resourcesβ
cd ../../cf
aws cloudformation create-stack --stack-name TrackingAndGeofencingIoTResources \
--template-body file://iotResources.yml \
--capabilities CAPABILITY_IAM
πΌ Configuring the Frontendβ
Get the CloudFormation stack outputs:
aws cloudformation describe-stacks \
--stack-name TrackingAndGeofencingSample \
--query "Stacks[0].Outputs[*].[OutputKey, OutputValue]"
Set values in configuration.js
accordingly:
export const READ_ONLY_IDENTITY_POOL_ID = "us-east-1:xxxx...";
export const WRITE_ONLY_IDENTITY_POOL_ID = "us-east-1:xxxx...";
export const REGION = "us-east-1";
export const MAP = {
NAME: "TrackingAndGeofencingSampleMapHere",
STYLE: "VectorHereExplore"
};
export const GEOFENCE = "TrackingAndGeofencingSampleCollection";
export const TRACKER = "SampleTracker";
export const DEVICE_POSITION_HISTORY_OFFSET = 3600;
export const KINESIS_DATA_STREAM_NAME = "TrackingAndGeofencingSampleKinesisDataStream";
Start the frontend locally:
npm start
Navigate to http://localhost:8080
to see your live map.
π Hosting on CloudFrontβ
1. Create S3 Bucketβ
- Go to S3 Console > Create Bucket
- Use a unique bucket name
2. Build Frontendβ
npm run build
3. Upload to S3β
aws s3 cp ./build s3://<your-bucket-name>/ --recursive
4. Create CloudFront Distributionβ
- Origin: S3 Bucket
- Create a new OAC (Origin Access Control)
- Enable WAF protections
5. Update S3 Bucket Policyβ
Paste in the policy suggested by CloudFront for the OAC.
Access your site at:
https://<your-distribution>.cloudfront.net/index.html
π Extend with Real Devicesβ
This tutorial used MQTT message simulation. For real-world scenarios:
- Use GPS-enabled IoT devices
- Integrate with certified hardware listed in the AWS Partner Device Catalog
β Summaryβ
In this blog, we:
- Introduced Amazon Location Service
- Simulated IoT data with AWS IoT Core
- Visualized tracking in a React app
- Hosted it with Amazon S3 + CloudFront
This powerful combination enables real-time tracking for logistics, delivery, field ops, and more.
π Final Thoughtsβ
Whether you are building internal logistics tools or customer-facing tracking apps, Amazon Location and AWS IoT Core offer a scalable, cost-effective foundation. Try building this project and tailor it to your business use case!
π Call to Actionβ
Choosing the right platform depends on your organizations needs. For more insights, subscribe to our newsletter for insights on cloud computing, tips, and the latest trends in technology. or follow our video series on cloud comparisons.
Need help launching your app on AWS? Visit arinatechnologies.com for expert help in cloud architecture.
Interested in having your organization setup on cloud? If yes, please contact us and we'll be more than glad to help you embark on cloud journey.
π¬ Comment below:
How do you plan to use Amazon Locations?