diff --git a/docs/providers/spotinst/README.md b/docs/providers/spotinst/README.md index 93b72d500c1..5b78d73ed33 100755 --- a/docs/providers/spotinst/README.md +++ b/docs/providers/spotinst/README.md @@ -30,7 +30,8 @@ If you have questions, join the [chat in gitter](https://gitter.im/serverless/se
  • Serverless.yml Reference
  • Variables
  • Document Store
  • -
  • Stage Variable
  • +
  • Endpoint Set Up
  • +
  • Endpoint API Documentation
  • @@ -49,6 +50,7 @@ If you have questions, join the [chat in gitter](https://gitter.im/serverless/se
  • Deploy Function
  • Invoke
  • Logs
  • +
  • Stage Variable
  • Info
  • Remove
  • Plugin List
  • diff --git a/docs/providers/spotinst/cli-reference/info.md b/docs/providers/spotinst/cli-reference/info.md index 14ddf4b1613..0f2fa8ade2e 100755 --- a/docs/providers/spotinst/cli-reference/info.md +++ b/docs/providers/spotinst/cli-reference/info.md @@ -1,7 +1,7 @@ diff --git a/docs/providers/spotinst/cli-reference/plugin-list.md b/docs/providers/spotinst/cli-reference/plugin-list.md index a99dbad1fb7..d706a719f50 100644 --- a/docs/providers/spotinst/cli-reference/plugin-list.md +++ b/docs/providers/spotinst/cli-reference/plugin-list.md @@ -1,7 +1,7 @@ diff --git a/docs/providers/spotinst/cli-reference/plugin-search.md b/docs/providers/spotinst/cli-reference/plugin-search.md index efcd4a1eb4f..c78e9d53d94 100644 --- a/docs/providers/spotinst/cli-reference/plugin-search.md +++ b/docs/providers/spotinst/cli-reference/plugin-search.md @@ -1,7 +1,7 @@ diff --git a/docs/providers/spotinst/cli-reference/plugin-uninstall.md b/docs/providers/spotinst/cli-reference/plugin-uninstall.md index 9784c843750..d04239f9165 100644 --- a/docs/providers/spotinst/cli-reference/plugin-uninstall.md +++ b/docs/providers/spotinst/cli-reference/plugin-uninstall.md @@ -1,7 +1,7 @@ diff --git a/docs/providers/spotinst/cli-reference/remove.md b/docs/providers/spotinst/cli-reference/remove.md index 9a1510fc201..87d2ce0d1f6 100755 --- a/docs/providers/spotinst/cli-reference/remove.md +++ b/docs/providers/spotinst/cli-reference/remove.md @@ -1,7 +1,7 @@ diff --git a/docs/providers/spotinst/guide/stage.md b/docs/providers/spotinst/cli-reference/stage.md similarity index 92% rename from docs/providers/spotinst/guide/stage.md rename to docs/providers/spotinst/cli-reference/stage.md index 37357a5557d..e26da0f5532 100644 --- a/docs/providers/spotinst/guide/stage.md +++ b/docs/providers/spotinst/cli-reference/stage.md @@ -1,7 +1,7 @@ @@ -18,7 +18,7 @@ You are able to set a stage variable in your function to distinguish between the To change the stage through the serverless framework you simply need to enter the command ```bash -serverless deploy --stage #{Your Stage Name} +serverless deploy --stage #{Your Stage Name} ``` ## Through the .yml File @@ -28,7 +28,7 @@ To change the stage in the serverless.yml file you need to add the following int ```bash provider: name: spotinst - stage: #{Your Stage Name} + stage: #{Your Stage Name} spotinst: environment: #{Your Environment ID} ``` diff --git a/docs/providers/spotinst/guide/endpoint-api.md b/docs/providers/spotinst/guide/endpoint-api.md new file mode 100644 index 00000000000..b5681651fee --- /dev/null +++ b/docs/providers/spotinst/guide/endpoint-api.md @@ -0,0 +1,202 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/spotinst/guide/credentials) + + +# Spotinst Functions - Endpoint API Documentation + +Here is the full list of API calls that you can make to set alias and patterns. Please check out the full article on Setting Up Endpoints first because it will make more sense. + +## Alias +### Create Alias +Create a new alias to point to your environment + +#### HTTPS Request +```bash +POST alias?accountId=${accountId} +``` +#### Host +```bash +api.spotinst.io/functions/ +``` +#### Body +```bash +{ + "alias": { + "host": "myAlias.com", + "environmentId": ${Environment ID} + } +} +``` +#### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json + ``` + +###Get Alias +Returns a single alias + +#### HTTPS Request +```bash +GET alias/${Alias ID}?accountId=${accountId} +``` +#### Host +```bash +api.spotinst.io/functions/ +``` +#### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` + +### Get All Alias +Returns all the alias in your account + +#### HTTPS Request +```bash +GET alias?accountId=${accountId} +``` +##### Host +```bash +api.spotinst.io/functions/ +``` +#### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` + +### Delete Alias +Deletes a single alias + +#### HTTPS Request +```bash +DELETE alias/${Alias ID}?accountId=${accountId} +``` +#### Host +```bash +api.spotinst.io/functions/ +``` +#### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` + + +##Pattern +###Create Pattern +Create a new pattern that maps to a function + +#### HTTPS Request +```bash +POST pattern?accountId=${accountId} +``` +#### Host +```bash +api.spotinst.io/functions/ +``` +#### Body +```bash +{ + "pattern": { + "environmentId":${Environment ID}, + "method": "ALL", + "pattern": "/*", + "functionId": ${Function ID} + } +} +``` +#### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` + +### Update Pattern +Update and existing pattern + +#### HTTPS Request +```bash +PUT pattern/${Pattern ID}?accountId=${accountId} +``` +####Host +```bash +api.spotinst.io/functions/ +``` +#### Body +```bash +{ + "pattern": { + "environmentId":${Environment ID}, + "method": "ALL", + "pattern": "/*", + "functionId": ${Function ID} + } +} +``` +#### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` + +### Get Pattern +Returns a single pattern + +#### HTTPS Request +```bash +GET pattern/${Pattern ID}?accountId=${accountId} +``` +#### Host +```bash +api.spotinst.io/functions/ +``` +#### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` + +### Get All Patterns +Returns all the patterns your account + +#### HTTPS Request +```bash +POST pattern?accountId=${accountId} +``` +#### Host +```bash +api.spotinst.io/functions/ +``` +#### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` + +### Delete Pattern +Delete a single pattern + +#### HTTPS Request +```bash +DELETE pattern/${Pattern ID}?accountId=${accountId} +``` +#### Host +```bash +api.spotinst.io/functions/ +``` +#### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` diff --git a/docs/providers/spotinst/guide/endpoint-setup.md b/docs/providers/spotinst/guide/endpoint-setup.md new file mode 100644 index 00000000000..8809eeab07d --- /dev/null +++ b/docs/providers/spotinst/guide/endpoint-setup.md @@ -0,0 +1,85 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/spotinst/guide/credentials) + + +# Spotinst Functions - Endpoint Setup + +You are able to set an alias URL name as an endpoint for your serverless function to make it more accessible to your users. The way this works is you will point the domain of your choosing to your environment URL's then you will set paths to each of the functions in that environment you wish to bundle in together. To do this you will first need a valid domain. For this example I will be using 'myAlias.com'. + +## Set DNS Record +First you will want to create a DNS record set that will point to your environment URL. Your environment URL can be found in the Spotinst console. When you select the environment you wish to connect you will see a list of functions and their individual URL's. Like this +```bash +https://app-123xyz-raffleapp-execute-function1.spotinst.io/fx-abc987 +``` +We only want the URL starting at app and ending before the function id. Like this +```bash +app-123xyz-raffleapp-execute-function1.spotinst.io +``` +With this you will need to go to a DNS record setter and point your domain to this URL. I used AWS Route 53 to set this up. + +## Set Alias +Next you will need to set the alias in your Spotinst environment by making an API call. This does not need to be done within a function and can be set anyway you are most comfortable. The API request is connecting your domain the environment that you want. This is the API request + +### HTTPS Request +```bash +POST alias?accountId=${accountId} +``` +### Host +```bash +api.spotinst.io/functions/ +``` +### Body +```bash +{ + "alias": { + "host": "myAlias.com", + "environmentId": ${Your Environment ID} + } +} +``` +### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` + +**Note:** You are able to connect multiple alias to the same environment + +##Set Up Pattern +After you have an alias set up you will need to set up pattern to connect to all the functions in the application. This is again another API call and can be done from anywhere. You specify the pattern that you want, the method that will trigger the function, the function ID and the environment ID. The pattern is what will appear after the domain. For example '/home' would point to 'myAlias.com/home'. The methods you can select are any of the usual HTTP request methods: GET, PUT, POST, DELETE , OPTIONS, PATCH, ALL where “ALL” matches every method + +### HTTPS Request +```bash +POST pattern?accountId=${accountId} +``` +### Host +```bash +api.spotinst.io/functions/ +``` +### Body +``` bash +{ + "pattern": { + "environmentId": ${Your Environment ID}, + "method": "ALL", + "pattern": "/*", + "functionId": ${Your Function ID} + } +} +``` +### Headers +```bash +Authorization: Bearer ${Spotinst API Token} +Content-Type: application/json +``` + +## API Documentation +The full API documentation has information like delete and get alias and patterns. Check it out [here](./endpoint-api.md)