Pulumi Fundamentals - Tutorial
Overview
A tutorial-style typescript based Pulumi program with sample progressive web application (PWA) the Pulumipus Boba Tea Shop; built with MongoDB
, ExpressJS
, ReactJS
, and NodeJS
(the MERN stack).
Note
This tutorial is part of official Pulumi tutorials. You can follow along here.
Key Concepts
- Create a Pulumi Project
- Pull Docker Images
- Configure and Provision Containers
Prerequisites
Pulumi
(Account and CLI)Docker
TypeScript
orJavaScript
(NodeJS v14+)
Quick Start
Setup
- Clone the repo:
git clone https://github.com/mohammadzainabbas/pulumi-labs.git
or if GitHub CLI is installed:
gh repo clone mohammadzainabbas/pulumi-labs
- Change directory:
cd tutorial-pulumi-fundamentals
- Install dependencies:
yarn
or if you prefer npm
:
npm install
Caution
If you are using npm
, make sure to delete yarn.lock
file first before installing dependencies.
- Deploy via Pulumi:
pulumi up
Note
Source code of Pulumipus Boba Tea Shop application (backend, frontend and database) is available here.
- Access the application by open the following URL in the browser:
pulumi stack output frontendUrl
Tip
By default, the application is deployed to http://localhost:3001
. You can change the port by setting the frontendPort
pulumi config variable as follows:
pulumi config set frontendPort <port>
- Cleanup:
pulumi destroy
Warning
This will delete all the resources (pulled images, containers, network) created by this Pulumi program.
Add new item
If you want to add a new item to your app, you can do so by making a POST
request like the following:
curl --location --request POST 'http://localhost:3000/api/products' \
--header 'Content-Type: application/json' \
--data-raw '{
"ratings": {
"reviews": [],
"total": 63,
"avg": 5
},
"created": 1600979464567,
"currency": {
"id": "USD",
"format": "$"
},
"sizes": [
"M",
"L"
],
"category": "boba",
"teaType": 2,
"status": 1,
"_id": "5f6d025008a1b6f0e5636bc7",
"images": [
{
"src": "classic_boba.png"
}
],
"name": "My New Milk Tea",
"price": 5,
"description": "none",
"productCode": "852542-107"
}'
Important
The above request will add a new drink item called β
βMy New Milk Tea
β to the app. This is just an example. You can change the request body as per your needs.
Full Changelog: v2.0...v3.0