-
-
Save vfarcic/56b865446d08c4eb702ac34a888c1398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/56b865446d08c4eb702ac34a888c1398 | |
################################################################ | |
# Use Klotho To Write Applications And NOT Infrastructure Code # | |
# https://youtu.be/1xVU8CZIJeU # | |
################################################################ | |
# Additional Info: | |
# - Klotho: https://klo.dev | |
######### | |
# Setup # | |
######### | |
# Install Pulumi from https://www.pulumi.com/docs/get-started/install | |
# Install CloudCC from https://cloudcompiler.run/docs/#/early-access/getting-started/compiling?id=installing-cloudcc | |
curl -fsSL https://api.cloudcompiler.run/v1/cli/install.sh | bash | |
git clone \ | |
https://github.com/vfarcic/klotho-demo | |
cd klotho-demo | |
# Replace `[...]` with your AWS Access Key ID | |
export AWS_ACCESS_KEY_ID=[...] | |
# Replace `[...]` with your AWS Secret Access Key | |
export AWS_SECRET_ACCESS_KEY=[...] | |
npm install | |
########################################## | |
# Compiling And Running Apps With Klotho # | |
########################################## | |
cat index.ts | |
cat users/userapi.ts | |
cat videos/video-postapi.ts | |
cat videos/video-listapi.ts | |
cat videos/quickrender.ts | |
cat videos/videodb.ts | |
# In a second terminal | |
ts-node index.ts | |
curl "http://localhost:3000/v1/users" | |
curl -X POST --data "s3path=bucket1" \ | |
"http://localhost:3000/v1/video" | |
curl "http://localhost:3000/v1/videos" | |
export APP_NAME=videos-$(date +%Y%m%d%H%M%S) | |
cloudcc compile \ | |
--runenv AWS \ | |
--appname $APP_NAME \ | |
--out-dir compiled \ | |
--typescript-compile \ | |
./index.ts | |
cloudcc up \ | |
--work-dir ./compiled \ | |
--stackname $APP_NAME | |
# It's using Pulumi and Docker | |
# Replace `[...]` with the `apiURL` from the output | |
export API_URL=[...] | |
curl "$API_URL/v1/users" | |
curl -X POST --data "s3path=bucket1" \ | |
"$API_URL/v1/video" | |
curl "$API_URL/v1/videos" | |
ls -1 compiled/ | |
echo compiled/$APP_NAME.png | |
# Open it | |
cat compiled/index.ts | |
cat index.ts | |
cat users/userapi.ts | |
cat videos/video-postapi.ts | |
cat videos/video-listapi.ts | |
cat videos/quickrender.ts | |
cat videos/videodb.ts | |
cloudcc destroy \ | |
--work-dir ./compiled \ | |
--stackname $APP_NAME | |
########### | |
# Destroy # | |
########### | |
rm -rf compiled dist node_modules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment