Create a Stack

After you have confirmed that at least one template is available in your account, you are ready to create a cloud stack with the Oracle Cloud Stack REST API.

Note: All of the examples in this guide use the URL prefix and context path for the United States region in Oracle Cloud. For information about the context path and the URL prefixes for other regions of the world, see Send Requests.

Create

A template defines optional and mandatory input parameters. When creating a stack, you must specify values for any mandatory template parameters or the create operation will respond with an error.

To create a cloud stack, provide the following information on the cURL command line.

  • Define the request:
    • Use the -X option to set the request method to POST.

    • Use the -H option to set the Content-Type header to multipart/form-data.

    • Use the -F option to send a form field called name, whose value is the name of your new stack.

    • Use the -F option to send a form field called template, whose value is the name of an existing template in your Oracle Cloud account.

  • For authentication, you must specify the account credentials obtained previously, as described in Obtain Account Information, on the cURL command line, as follows:
    • Use the -u option to send the user name and password for your Oracle Cloud account.

    • Use the -H option to set the X-ID-TENANT-NAME custom request header to the identity domain ID for your Oracle Cloud account.

  • Use the -F option to specify values for any template parameters as a single form field called parameterValues. The value of this form parameter must be in JSON notation:{ "name":"value","name":"value" }.

For example:

curl -i -X POST \
-u yourUserName:yourPassword \
-H "Content-Type:multipart/form-data" \
-H "X-ID-TENANT-NAME:yourIdentityDomain" \
-F "name=yourStackName" \
-F "template=yourTemplateName" \
-F 'parameterValues={"paramName1":"paramValue1","paramName2":"paramValue2","paramNameN":"paramValueN"}' \
https://psm.us.oraclecloud.com/paas/api/v1.1/instancemgmt/yourIdentityDomain/services/stack/instances

Note: On Windows, you must escape the quotation mark characters found in the parameterValues JSON object. For example:

-F "parameterValues={\"paramName1\":\"paramValue1\",\"paramName2\":\"paramValue2\"}"

Verify that the response includes HTTP code 202, meaning that the stack creation is in progress. The response headers also include the REST endpoints of the creation job and your new stack:

HTTP/1.1 202 Accepted
Location: https://psm.us.oraclecloud.com/paas/api/v1.1/activitylog/MyIdentityDomain/job/101231
Content-Type: application/json
Service-URI: https://psm.us.oraclecloud.com/paas/api/v1.1/instancemgmt/MyIdentityDomain/services/stack/instances/MyStack
Retry-After: 60

The following shows an example of the response contents in JSON format:

{
  "details":{
    "message":"Submitted job to create stack [MyStack] in domain [MyIdentityDomain].",
    "jobId":"101231"
  }
}

List

Use the same URL and set the request method to GET in order to view a list of all cloud stacks in this account. For example:

curl -i -X GET -u yourUserName:yourPassword -H "X-ID-TENANT-NAME:yourIdentityDomain" https://psm.us.oraclecloud.com/paas/api/v1.1/instancemgmt/yourIdentityDomain/services/stack/instances

Below is an example JSON response containing two stacks:

{
     "identityDomain": "MyIdentityDomain",
     "stacks": [
     {
          "serviceName": "MyStack",
          "description": "My first stack",
          "state": "READY",
          "stateDetail": "Ready",
          "identityDomain": "MyIdentityDomain",
          "createdBy": "myuser",
          "creationJobId": "80161",
          "createdOn": "2016-07-26T15:48:18.366+0000",
          "modifiedOn": "2016-07-26T15:48:18.365+0000",
          "links": [
               {
                    "rel": "canonical",
                    "href": "https://psm.us.oraclecloud.com/paas/api/v1.1/instancemgmt/MyIdentityDomain/services/stack/instances/MyStack"
               },
               {
                    "rel": "self",
                    "href": "https://psm.us.oraclecloud.com/paas/api/v1.1/instancemgmt/MyIdentityDomain/services/stack/instances/MyStack"
               }
          ]
     },
     {
          "serviceName": "MyStack2",
          "description": "My second stack",
          "state": "READY",
          "stateDetail": "Ready",
          "identityDomain": "MyIdentityDomain",
          "createdBy": "myuser",
          "creationJobId": "80161",
          "createdOn": "2016-07-27T15:48:18.366+0000",
          "modifiedOn": "2016-07-27T15:48:18.365+0000",
          "links": [
               {
                    "rel": "canonical",
                    "href": "https://psm.us.oraclecloud.com/paas/api/v1.1/instancemgmt/MyIdentityDomain/services/stack/instances/MyStack2"
               },
               {
                    "rel": "self",
                    "href": "https://psm.us.oraclecloud.com/paas/api/v1.1/instancemgmt/MyIdentityDomain/services/stack/instances/MyStack2"
               }
          ]

     }]
}