Updated on 2024-01-31 GMT+08:00

Obtaining Execution Plans

Function

GetExecutionPlan

This API obtains the details (items) of a specified execution plan. By calling this API, you can check the changes of resources in a stack once the specified execution plan is applied.

If the execution plan is in a CREATION_IN_PROGRESS or CREATION_FAILED state, the list of execution plan items will not be returned.

URI

GET /v1/{project_id}/stacks/{stack_name}/execution-plans/{execution_plan_name}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

A project ID is obtained by calling an API or from the console.

Obtaining a Project ID

Minimum: 3

Maximum: 64

stack_name

Yes

String

A stack name is unique within its domain (domain_id), region, and project (project_id). It is case-sensitive and starts with a letter. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Minimum: 1

Maximum: 128

execution_plan_name

Yes

String

An execution plan name is unique within its domain (domain_id), region, project (project_id), and stack (stack_id). It is case-sensitive and starts with a letter. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Minimum: 1

Maximum: 128

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

stack_id

No

String

Unique stack ID.

It is a UUID generated by RFS when a stack is created.

Stack names are unique at one specific time, so you can create a stack named HelloWorld and another stack with the same name after deleting the first one.

For parallel development, team members may want to ensure that they are operating the stack they created, not one with the same name created by other members after deleting the previous one.

To avoid this mismatch, check the ID, since RFS ensures each stack has a unique ID that does not change with updates. If the stack_id value differs from the current stack ID, 400 is returned.

Minimum: 36

Maximum: 36

execution_plan_id

No

String

Unique execution plan ID.

A UUID is generated by RFS when an execution plan is created.

Execution plan names are unique at one specific time, so you can create an execution plan named HelloWorld and another execution plan with the same name after deleting the first one.

For parallel development, team members may want to ensure that they are operating the execution plan they created, not one with the same name created by other members after deleting the previous one.

To avoid this mismatch, check the ID, since RFS ensures each execution plan has a unique ID that does not change with updates. If the execution_plan_id value differs from the current execution plan ID, 400 is returned.

Minimum: 36

Maximum: 36

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

Client-Request-Id

Yes

String

A unique request ID is specified by a user to locate a request. UUID is recommended.

Minimum: 36

Maximum: 128

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

execution_plan_items

Array of ExecutionPlanItem objects

Item list of an execution plan.

Table 5 ExecutionPlanItem

Parameter

Type

Description

resource_type

String

Resource type.

For example, in the following HCL template, the value of resource_type is huaweicloud_vpc.

resource "huaweicloud_vpc" "my_hello_world_vpc" {
  name = "test_vpc"
}

In a JSON template, the value of resource_type is huaweicloud_vpc.

{
  "resource": {
    "huaweicloud_vpc": {
      "my_hello_world_vpc": {
        "name": "test_vpc"
      }
    }
  }
}

resource_name

String

Resource name. The default value is the logical name of a resource.

For example, in the following HCL template, the value of resource_name is my_hello_world_vpc.

resource "huaweicloud_vpc" "my_hello_world_vpc" {
  name = "test_vpc"
}

In a JSON template, the value of resource_name is my_hello_world_vpc.

{
  "resource": {
    "huaweicloud_vpc": {
      "my_hello_world_vpc": {
        "name": "test_vpc"
      }
    }
  }
}

index

String

Resource index. If count or for_each is used in a template, index is returned. If index appears, resource_name and index can be used to identify a resource. If count is used in a template, index is a number starting from 0.

For example, in the following HCL template, huaweicloud_vpc.my_hello_world_vpc[0] and huaweicloud_vpc.my_hello_world_vpc[1] identify two resources.

resource "huaweicloud_vpc" "my_hello_world_vpc" {
  count = 2
  name = "test_vpc"
}

In a JSON template, huaweicloud_vpc.my_hello_world_vpc[0] and huaweicloud_vpc.my_hello_world_vpc[1] identify two resources.

{
  "resource": {
    "huaweicloud_vpc": {
      "my_hello_world_vpc": {
        "name": "test_vpc",
        "count": 2
      }
    }
  }
}

If for_each is used in a template, index is a user-defined string. For example, in the following HCL template, huaweicloud_vpc.my_hello_world_vpc["vpc1"] and huaweicloud_vpc.my_hello_world_vpc["vpc2"] identify two resources.

resource "huaweicloud_vpc" "my_hello_world_vpc" {
  for_each = {
    "vpc1" = "test_vpc"
    "vpc2" = "test_vpc"
  }
  name = each.value
}

In a JSON template, huaweicloud_vpc.my_hello_world_vpc["vpc1"] and huaweicloud_vpc.my_hello_world_vpc["vpc2"] identify two resources.

{
  "resource": {
    "huaweicloud_vpc": {
      "my_hello_world_vpc": {
        "for_each": {
          "vpc1": "test_vpc",
          "vpc2": "test_vpc"
        }
        "name": "${each.value}"
      }
    }
  }
}

action

String

Resource change types may include:

  • ADD: adds a resource.

  • ADD_THEN_DELETE: creates a resource and then deletes the old one. It is returned by resources those cannot be updated.

  • DELETE: deletes a resource.

  • DELETE_THEN_ADD: deletes the old resource and then creates a new one. It is returned by resources those cannot be updated.

  • UPDATE: updates a resource.

    • NO_OPERATION: only changes the dependencies of a resource. The resource itself is not changed.

Enumeration values:

  • ADD

  • ADD_THEN_DELETE

  • DELETE

  • DELETE_THEN_ADD

  • UPDATE

  • NO_OPERATION

action_reason

String

Reason for triggering project changes, for example, a user updates a template or a resource is deleted remotely.

provider_name

String

Name of the provider to which the project belongs.

mode

String

Resource modes may include:

  • DATA: a type of resource that can run and obtain server data during template parsing. Operations on infrastructure components are not involved.

  • RESOURCE: important infrastructure objects defined by services and managed by templates. It can be physical resources or logical resources.

Enumeration values:

  • DATA

  • RESOURCE

drifted

Boolean

Whether the change of the current resource is caused by deviation.

Deviation, also called drift. After a resource is created by RFS but not modified by RFS, for example, modified manually or by SDK, the resource configuration will be inconsistent with that recorded by RFS. This inconsistency is called deviation.

After a resource deviation occurs:

  • If you attempt to create an execution plan, a message is displayed, indicating that a deviation occurs.

  • If you directly deploy an execution plan, the deviation may be overwritten. RFS only ensures that the resources are configured as written in the template.

The resource deviation types may include:

  • Modification of resource location attribute: mostly happens after a resource is deleted and then a new one is created. The new resource is not the same one before modification. In this case, RFS considers that the original resource has been deleted and attempts to create a new resource.

  • Modification of resource common attribute: RFS can still find the resource, but it will attempt to rectify the deviation during the next deployment to make the resource configuration be consistent with that written in the template.

Note: It is advised to use RFS to maintain and update resources created on RFS to ensure that resource configurations are consistent with those written in your templates. Avoid modifying resources manually except for emergencies.

imported

Boolean

Whether changes to the current resource are imported.

resource_id

String

Unique resource physical ID. It is generated by the resource provider, cloud service provider, or other service providers during resource deployment.

attributes

Array of ExecutionPlanDiffAttribute objects

Execution plan item attributes that are changed. If no attribute is changed, this value is an empty list.

Table 6 ExecutionPlanDiffAttribute

Parameter

Type

Description

name

String

Name of the to-be-modified parameter of the current resource.

previous_value

String

Original value of the modified parameter of the current resource.

During resource creation, previous_value is empty.

If a deviation occurs in a remote resource, the resource returns two ExecutionPlanItems, the drifted values of which are true and false, respectively.

  • The previous_value whose drifted is true indicates the original resource attribute and status in the stack.

  • The previous_value whose drifted is false indicates the resource attribute and status returned by the remote resource after the provider requests the remote resource.

If no deviation occurs in a remote resource, only one ExecutionPlanItem whose drifted is false is returned.

  • The previous_value whose drifted is false indicates the original resource attribute and status in the stack.

target_value

String

Target value of the modified parameter of the current resource.

During resource deletion, target_value is empty.

If a deviation occurs in a remote resource, the resource returns two ExecutionPlanItems, the drifted values of which are true and false, respectively.

  • The target_value whose drifted is true indicates the resource attribute and status returned by the remote resource after the provider requests the remote resource.

  • The target_value whose drifted is false indicates the resource attribute and status updated based on your template.

If no deviation occurs in a remote resource, only one ExecutionPlanItem whose drifted is false is returned.

  • The target_value whose drifted is false indicates the resource attribute and status updated based on your template.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

Minimum: 11

Maximum: 11

error_msg

String

Response message.

encoded_authorization_message

String

The message contains information about unauthorized requests.

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

Minimum: 11

Maximum: 11

error_msg

String

Response message.

encoded_authorization_message

String

The message contains information about unauthorized requests.

Status code: 403

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

Minimum: 11

Maximum: 11

error_msg

String

Response message.

encoded_authorization_message

String

The message contains information about unauthorized requests.

Status code: 404

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

Minimum: 11

Maximum: 11

error_msg

String

Response message.

encoded_authorization_message

String

The message contains information about unauthorized requests.

Status code: 429

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

Minimum: 11

Maximum: 11

error_msg

String

Response message.

encoded_authorization_message

String

The message contains information about unauthorized requests.

Status code: 500

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

Minimum: 11

Maximum: 11

error_msg

String

Response message.

encoded_authorization_message

String

The message contains information about unauthorized requests.

Example Requests

  • Obtain the details (items) of a specified execution plan.

    GET https://{endpoint}/v1/ba2b9930c977f71edaeaa3a5e96a8ff1/stacks/my_hello_world_stack/execution-plans/my_first_execution_plan
  • Obtain the details (items) of a specified execution plan, with a stack ID and an execution plan ID provided to check whether they match the current stack and execution plan.

    GET https://{endpoint}/v1/ba2b9930c977f71edaeaa3a5e96a8ff1/stacks/my_hello_world_stack/execution-plans/my_first_execution_plan?stack_id=ea6a4f0e-ee8a-494e-b12a-8be4a1e65af2&execution_plan_id=fb5e781e-a27d-46e2-9954-242753857a9f

Example Responses

Status code: 200

Execution plan details obtained.

{
  "execution_plan_items" : [ {
    "resource_type" : "huaweicloud_iec_vpc_subnet",
    "resource_name" : "subnet",
    "action" : "ADD",
    "attributes" : [ {
      "name" : "cidr",
      "target_value" : "172.16.0.0/16"
    }, {
      "name" : "dhcp_enable",
      "target_value" : "true"
    }, {
      "name" : "dns_list",
      "target_value" : "(will be generated after apply)"
    }, {
      "name" : "gateway_ip",
      "target_value" : "192.168.128.1"
    }, {
      "name" : "id",
      "target_value" : "(will be generated after apply)"
    }, {
      "name" : "name",
      "target_value" : "subnet_demo"
    }, {
      "name" : "region"
    }, {
      "name" : "site_id",
      "target_value" : "mock_site_id"
    }, {
      "name" : "site_info",
      "target_value" : "(will be generated after apply)"
    }, {
      "name" : "status",
      "target_value" : "(will be generated after apply)"
    }, {
      "name" : "timeouts"
    }, {
      "name" : "vpc_id",
      "target_value" : "mock_vpc_id"
    } ],
    "mode" : "RESOURCE",
    "provider_name" : "huawei.com/provider/huaweicloud"
  }, {
    "resource_type" : "huaweicloud_vpc",
    "resource_name" : "vpc",
    "action" : "ADD",
    "attributes" : [ {
      "name" : "cidr",
      "target_value" : "172.16.0.0/16"
    }, {
      "name" : "description"
    }, {
      "name" : "enterprise_project_id",
      "target_value" : "(will be generated after apply)"
    }, {
      "name" : "id",
      "target_value" : "(will be generated after apply)"
    }, {
      "name" : "name",
      "target_value" : "test_name"
    }, {
      "name" : "region",
      "target_value" : "(will be generated after apply)"
    }, {
      "name" : "routes",
      "target_value" : "(will be generated after apply)"
    }, {
      "name" : "secondary_cidr"
    }, {
      "name" : "status",
      "target_value" : "(will be generated after apply)"
    }, {
      "name" : "tags"
    }, {
      "name" : "timeouts"
    } ],
    "mode" : "RESOURCE",
    "provider_name" : "huawei.com/provider/huaweicloud"
  } ]
}

Status Codes

Status Code

Description

200

Execution plan details obtained.

400

Invalid request.

401

Authentication failed.

403

The user does not have the permission to call this API.

404

  1. The stack does not exist.

  2. The execution plan does not exist.

429

Too frequent requests.

500

Internal server error.