SERVELESS APPLICATION DEPLOYMENT
Créer une API REST 100% Serverless en Java 17, déployée avec Serverless Framework, qui :
- ✅ Permet d'ajouter, lire, supprimer un utilisateur (
POST,GET,DELETE) - ✅ S'intègre avec Cognito pour authentifier chaque appel API
- ✅ Valide le JSON d'entrée côté Lambda
- ✅ Utilise DynamoDB pour stocker les données
| Élément | Technologie |
|---|---|
| Code métier | Java 17 |
| Plateforme | AWS Lambda |
| Déploiement Infra | Déploiement via Serverless Framework |
| Authentification | Amazon Cognito + JWT (OAuth2) |
| Stockage | DynamoDB (NoSQL, serverless) |
| API Gateway | REST API avec authorizer Cognito |
- Java 17 installé
- Maven (
mvn -v) - SAM CLI (
sam --version) - AWS CLI (
aws configure) - Node.js (pour tests locaux si besoin)
- Va sur Cognito Console
- Crée un User Pool
- Active une App Client (sans secret)
- Note ton
UserPoolIdetAppClientId - Dans
template.yaml, ajoute :
mvn clean package
sls deploy- Authentifie-toi via Cognito → récupère un token JWT
- Fais un POST :
POST /user
Authorization: Bearer <token>
Content-Type: application/json
{
"userId": "abc",
"name": "Alice",
"email": "alice@example.com"
}