github.com/in4it/ecs-deploy@v0.0.42-0.20240508120354-ed77ff16df25/examples/curl-api.sh (about) 1 #!/bin/bash 2 3 # 4 # example of accessing API 5 # 6 # note: configure .env first 7 # 8 9 # 10 # get env vars 11 export $(egrep -v '^#' .env | xargs) 12 13 # auth 14 TOKEN=`curl -X POST localhost:8080/login -H 'Content-type: application/json' -s -d '{"username":"deploy","password":"'${DEPLOY_PASSWORD}'"}' |jq -r '.token'` 15 16 if [ "$1" == "createrepo" ] ; then 17 curl -X POST localhost:8080/api/v1/ecr/create/myservice -H "Authorization:Bearer ${TOKEN}" 18 elif [ "$1" == "export" ] ; then 19 curl -X GET localhost:8080/api/v1/export/terraform -H "Authorization:Bearer ${TOKEN}" 20 elif [ "$1" == "deploy" ] ; then 21 curl -X POST localhost:8080/api/v1/deploy/myservice -H 'Content-type: application/json' -H "Authorization:Bearer ${TOKEN}" -d \ 22 '{ 23 "cluster": "ward", 24 "servicePort": 3000, 25 "serviceProtocol": "HTTP", 26 "desiredCount": 1, 27 "containers": [ 28 { 29 "containerName": "myservice", 30 "containerTag": "latest", 31 "containerPort": 3000, 32 "memoryReservation": 512, 33 "essential": true 34 } 35 ], 36 "healthCheck": { 37 "healthyThreshold": 3, 38 "unhealthyThreshold": 3, 39 "path": "/", 40 "interval": 60, 41 "matcher": "200,301" 42 } 43 }' 44 else 45 echo 'Usage: curl-api.sh <createrepo|export|deploy>' 46 fi