Todos os produtos
Search
Central de documentação

CloudOps Orchestration Service:ACS::ExecuteHttpRequest

Última atualização: Jun 28, 2026

Chame endpoints HTTP/HTTPS externos em tarefas de O&M para integrar serviços de terceiros, enviar notificações, coletar dados e verificar resultados.

Descrição

A ação executa requisições HTTP/HTTPS externas durante tarefas de O&M e permite a interação entre a manutenção de recursos em nuvem e serviços HTTP externos.

Cenários típicos:

  1. Integração de API: Use a ação ACS::ExecuteHttpRequest para chamar APIs de serviços de terceiros, consultar informações, executar operações ou integrar sistemas externos.

  2. Notificação personalizada: Para enviar uma notificação em uma etapa específica da execução do script, use a ação ACS::ExecuteHttpRequest e direcione a requisição ao webhook ou serviço de notificação desejado. Dessa forma, é possível disparar avisos por e-mail, SMS ou push notification.

  3. Coleta de dados e relatórios: Envie informações sobre uma tarefa de O&M para um servidor remoto ou plataforma de dados com a ação ACS::ExecuteHttpRequest para viabilizar auditoria, monitoramento e geração de relatórios.

  4. Disparo automatizado de processos: Acione a execução de outras ferramentas ou scripts automatizados durante a execução de um modelo do CloudOps Orchestration Service (OOS) com a ação ACS::ExecuteHttpRequest. Por exemplo, inicie um processo de deploy em um sistema de integração contínua ou entrega contínua (CI/CD) ou ative tarefas de O&M em sistemas externos.

  5. Verificação e autorização externas: Caso seja necessário autenticar identidades e validar permissões operacionais durante o processo de O&M, envie uma requisição a um sistema de autenticação externo por meio da ação ACS::ExecuteHttpRequest para confirmar a identidade do operador ou verifique as permissões exigidas.

  6. Aguardar conclusão de tarefas assíncronas ou validar resultados de chamadas: Em cenários em que requisições HTTP envolvem tarefas assíncronas, faça polling e verifique campos específicos na resposta ou valide os resultados da chamada. Use os campos WaitFor/CheckFor para implementar esses requisitos.

Sintaxe

Tasks:
  - Name: executeHttpRequestExample
    Action: ACS::ExecuteHttpRequest
    Properties:
      Method: POST # Optional. The HTTP method used to submit the request. Valid values: POST and GET. Default value: POST.
      URL: 'https://example.com' # Required. The HTTP URL used to specify the location of a specific resource.
      Headers: # Optional. The HTTP request headers.
        Content-Type: 'application/json'
      Query: # Optional. The HTTP request parameters.
        Parameter1: value1
        Parameter2: value2
      Body: # Optional. The HTTP request body. This parameter is valid only if the HTTP method is POST.
        Parameter3: value3
        Parameter4: value4
      CheckFor: # Optional. Verifies the HTTP response results.
        # You can add multiple comparison groups under Rules. The relationship between groups is "AND".
        Rules:
          - PropertySelector: "jq selector" # JQ syntax
            Operator: "Equals" # Comparison operator. Valid values: "Equals", "In", "NotIn"
            Value: "1" # Expected value
      WaitFor: # Optional. Polls and verifies the HTTP response results.
        # Rules are the same as above
        Rules:
          - PropertySelector: "jq selector" 
            Operator: "Equals"
            Value: "1"
        FailRules:
        # When conditions are met, the task fails immediately
          - PropertySelector: "jq selector" 
            Operator: "Equals"
            Value: "1"
        # The Retry module configures retry-related parameters
        Retry:
          Retries: # Optional. The maximum number of retries. The value must be a positive integer, such as 5. Valid values: 0 to 300. Default value: 10.
          DelayType: # Exponential(Default), Constant, Linear. For Exponential type, the retry interval is: 2 ^ times(retry count); For Constant type, the retry interval is fixed at Delay; For Linear type, the retry interval is: Delay + BackOff * times(retry count).
          Delay: # The retry interval. The value must be a positive integer, such as 10. A value of 10 indicates that the retry interval is 10 seconds. Valid values: 1 to 3600. Default value: 2. This parameter is required if the DelayType attribute is set to Constant or Linear.
          BackOff: # The retry interval compensation. The value must be a positive integer. Valid values: 1 to 3600. Default value: 2. This parameter is required if the DelayType attribute is set to Linear.
          MaxRetryInterval: # The maximum retry interval. The value must be a positive integer. Valid values: 1 to 1800. Default value: 1800. Unit: seconds.
    Outputs:
      OutputParameter1:
        ValueSelector: 'jq selector' # The jQuery selector for selecting the data to return. The jQuery selector extracts information from the JSON data returned by the API operation. For more information about the jq syntax, visit https://stedolan.github.io/jq/.
        Type: String/Boolean/List/Number/Object
{
  "Tasks": [
    {
      "Name": "executeHttpRequestExample",
      "Action": "ACS::ExecuteHttpRequest",
      "Properties": {
        "Method": "POST",
        "URL": "https://example.com",
        "Headers": {
          "Content-Type": "application/json"
        },
        "Query": {
          "Parameter1": "value1",
          "Parameter2": "value2"
        },
        "Body": {
          "Parameter3": "value3",
          "Parameter4": "value4"
        },
        "CheckFor": {
          "Rules": [
            {
              "PropertySelector": "jq selector",
              "Operator": "Equals",
              "Value": "1"
            }
          ]
        },
        "WaitFor": {
          "Rules": [
            {
              "PropertySelector": "jq selector",
              "Operator": "Equals",
              "Value": "1"
            }
          ],
          "FailRules": [
            {
              "PropertySelector": "jq selector",
              "Operator": "Equals",
              "Value": "1"
            }
          ],
          "Retry": {
            "Retries": null,
            "DelayType": null,
            "Delay": null,
            "BackOff": null,
            "MaxRetryInterval": null
          }
        }
      },
      "Outputs": {
        "OutputParameter1": {
          "ValueSelector": "jq selector",
          "Type": "String/Boolean/List/Number/Object"
        }
      }
    }
  ]
}

Exemplos

O exemplo a seguir demonstra como acionar um workflow do GitHub Actions a partir de um modelo OOS para fazer deploy de instâncias específicas do Elastic Compute Service (ECS):

FormatVersion: OOS-2019-06-01
Description: 
    en: OOS template for deploying ECS instances using GitHub Actions.
     
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
       
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Type: Json
    Label:
      en: TargetInstance
       
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: regionId
      Status: Running
  gitHubBranch:
    Type: String
    Description:
        en: Branch where the deployment will occur.
         
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances
       
    Action: ACS::SelectTargets
    Properties:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: Instances.Instance[].InstanceId
  - Name: DeployCodeByGitHubAction
    Action: ACS::ExecuteHttpRequest
    Properties:
      Method: POST
      URL: "https://api.github.com/repos/<YOUR-GITHUB-ACCOUNT>/<YOUR-GITHUB-REPO>/actions/workflows/<YOUR-WORKFLOW-ID>/dispatches"
      Headers:
        Accept: application/vnd.github+json
        Authorization: "Bearer <YOUR-TOKEN>"
        X-GitHub-Api-Version: 2022-11-28
      Body: 
        ref: "{{gitHubBranch}}"
        inputs:
          instance_ids: "{{getInstance.instanceIds}}"
{
  "FormatVersion": "OOS-2019-06-01",
  "Description": {
    "en": "OOS template for deploying ECS instances using GitHub Actions.",
     
  },
  "Parameters": {
    "regionId": {
      "Type": "String",
      "Label": {
        "en": "RegionId",
         
      },
      "AssociationProperty": "RegionId",
      "Default": "{{ ACS::RegionId }}"
    },
    "targets": {
      "Type": "Json",
      "Label": {
        "en": "TargetInstance",
         
      },
      "AssociationProperty": "Targets",
      "AssociationPropertyMetadata": {
        "ResourceType": "ALIYUN::ECS::Instance",
        "RegionId": "regionId",
        "Status": "Running"
      }
    },
    "gitHubBranch": {
      "Type": "String",
      "Description": {
        "en": "Branch where the deployment will occur.",
         
      }
    }
  },
  "Tasks": [
    {
      "Name": "getInstance",
      "Description": {
        "en": "Views the ECS instances",
         
      },
      "Action": "ACS::SelectTargets",
      "Properties": {
        "ResourceType": "ALIYUN::ECS::Instance",
        "RegionId": "{{ regionId }}",
        "Filters": [
          "{{ targets }}"
        ]
      },
      "Outputs": {
        "instanceIds": {
          "Type": "List",
          "ValueSelector": "Instances.Instance[].InstanceId"
        }
      }
    },
    {
      "Name": "DeployCodeByGitHubAction",
      "Action": "ACS::ExecuteHttpRequest",
      "Properties": {
        "Method": "POST",
        "URL": "https://api.github.com/repos/<YOUR-GITHUB-ACCOUNT>/<YOUR-GITHUB-REPO>/actions/workflows/<YOUR-WORKFLOW-ID>/dispatches",
        "Headers": {
          "Accept": "application/vnd.github+json",
          "Authorization": "Bearer <YOUR-TOKEN>",
          "X-GitHub-Api-Version": "2022-11-28T00:00:00.000Z"
        },
        "Body": {
          "ref": "{{gitHubBranch}}",
          "inputs": {
            "instance_ids": "{{getInstance.instanceIds}}"
          }
        },
        "Query": {}
      }
    }
  ]
}