Configure and deploy the AWS Amplify backend using the ws1-amplify
profile.
Ensure your AWS CLI is configured with the ws1-amplify
profile:
# Verify profile exists
aws configure list --profile ws1-amplify
# If not configured, set it up
aws configure --profile ws1-amplify
Before deployment, update the hardcoded bucket names in the backend code:
Files to update (use your unique bucket name):
# Use Find & Replace to update all instances
# From: itea-weather-data-lake-storage
# To: itea-weather-data-lake-storage-yourname
Key files:
amplify/backend.ts
amplify/functions/getTotalReadings/handler.ts
amplify/custom/WeatherDataGlue/resource.ts
Use the Amplify sandbox for development with the correct profile:
# Deploy sandbox environment
npx ampx sandbox --profile ws1-amplify
The sandbox will deploy:
Authentication Resources:
Storage Resources:
Lambda Functions:
Custom CDK Constructs:
IAM Policies and Roles:
Watch the deployment process:
# The sandbox will show deployment progress
# ✓ Building backend...
# ✓ Deploying backend...
# ✓ Backend deployed successfully
After successful deployment:
Check generated files:
# Amplify outputs file should be created
ls amplify_outputs.json
Verify AWS resources in the console:
After deployment, you need to configure user access to the platform:
Sign up a new user through the frontend application:
# Start the development server first
pnpm dev
# Navigate to your app and create an account
Add user to platform-admin group in Cognito:
amplify-{app-name}-{env}-userPool
)platform-admin
Authenticated users with platform access
platform-admin
amplify-{app-name}-{env}-identityPool
)us-east-1:12345678-1234-1234-1234-123456789012
)Critical Step: Attach the IoT policy to the specific user’s Identity ID:
# Replace <identity_ID> with the actual Identity ID from step 7.2
aws iot attach-principal-policy \
--policy-name WeatherPlatformPubSubPolicy \
--principal us-east-1:<identity_ID> \
--region us-east-1 \
--profile ws1-amplify
Example:
aws iot attach-principal-policy \
--policy-name WeatherPlatformPubSubPolicy \
--principal us-east-1:12345678-1234-1234-1234-123456789012 \
--region us-east-1 \
--profile ws1-amplify
Verify the policy was attached successfully:
WeatherPlatformPubSubPolicy
Alternative CLI verification:
# List all principals attached to the policy
aws iot list-policy-principals \
--policy-name WeatherPlatformPubSubPolicy \
--profile ws1-amplify
Critical IoT Policy Limitation: AWS IoT Core policies can be attached to individual Cognito Identity IDs but cannot be directly attached to Cognito Identity Pool IDs. This means for each user created, the administrator must perform this extra step to fully allow that user to use IoT Core resources.
Why This Step is Required: Each authenticated user gets a unique Cognito Identity ID when they sign in. IoT policies must be attached to each specific Identity ID to grant access to IoT Core resources like subscribing to MQTT topics and receiving telemetry data.
Start the development server:
# Start Next.js development server
pnpm dev
The frontend will automatically use amplify_outputs.json
for configuration.
Common issues:
Profile not found:
# Reconfigure profile
aws configure --profile ws1-amplify
Deployment fails:
# Clean and retry
npx ampx sandbox delete --profile ws1-amplify
npx ampx sandbox --profile ws1-amplify
Permission errors:
ws1-amplify
profileIoT policy attachment fails:
# Verify policy exists
aws iot get-policy --policy-name WeatherPlatformPubSubPolicy --profile ws1-amplify
# Check if policy is already attached
aws iot list-policy-principals --policy-name WeatherPlatformPubSubPolicy --profile ws1-amplify
User cannot access IoT resources:
platform-admin
group in Cognito User PoolDashboard not loading IoT data:
Keep the sandbox running during development. It provides hot-reloading for backend changes.
Sandbox environments are for development only. Use production deployment for live applications.
Without step 4, users cannot: