Infrastructure as CodeStandard Library

Standard Actions

Actions available in the standard library

These actions are available in all Runbooks as part of the standard library.

send_http_request

The std::send_http_request action makes an HTTP request to the specified URL.

Inputs

NameRequiredTypeDescription
urlrequiredstringThe URL to send the request to
methodoptionalstringThe HTTP method (GET, POST, PUT, DELETE). Default: GET
headersoptionalmapHTTP headers to include in the request
bodyoptionalstringThe request body (for POST/PUT requests)
timeout_msoptionalintegerRequest timeout in milliseconds

Outputs

NameTypeDescription
status_codeintegerThe HTTP status code
bodystringThe response body
headersmapThe response headers
action "api_call" "std::send_http_request" {
    description = "Fetch data from API"
    url = "https://api.example.com/data"
    method = "GET"
    headers = {
        "Authorization" = "Bearer ${variable.token}"
    }
}

output "response" {
    value = action.api_call.body
}

output "status" {
    value = action.api_call.status_code
}

POST Request Example

action "create_resource" "std::send_http_request" {
    description = "Create a new resource"
    url = "https://api.example.com/resources"
    method = "POST"
    headers = {
        "Content-Type" = "application/json"
    }
    body = {
        "name" = variable.name,
        "value" = variable.value
    }
}

read_file

The std::read_file action reads the contents of a file.

Inputs

NameRequiredTypeDescription
pathrequiredstringThe path to the file to read

Outputs

NameTypeDescription
contentstringThe file contents
action "config" "std::read_file" {
    path = "./config.json"
}

variable "parsed_config" {
    value = std::jq(action.config.content, ".")
}

write_file

The std::write_file action writes content to a file.

Inputs

NameRequiredTypeDescription
pathrequiredstringThe path to the file to write
contentrequiredstringThe content to write to the file
action "save_output" "std::write_file" {
    path = "./output.json"
    content = {
        "result" = variable.result,
        "timestamp" = variable.timestamp
    }
}

On this page