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
| Name | Required | Type | Description |
|---|---|---|---|
url | required | string | The URL to send the request to |
method | optional | string | The HTTP method (GET, POST, PUT, DELETE). Default: GET |
headers | optional | map | HTTP headers to include in the request |
body | optional | string | The request body (for POST/PUT requests) |
timeout_ms | optional | integer | Request timeout in milliseconds |
Outputs
| Name | Type | Description |
|---|---|---|
status_code | integer | The HTTP status code |
body | string | The response body |
headers | map | The 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
| Name | Required | Type | Description |
|---|---|---|---|
path | required | string | The path to the file to read |
Outputs
| Name | Type | Description |
|---|---|---|
content | string | The 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
| Name | Required | Type | Description |
|---|---|---|---|
path | required | string | The path to the file to write |
content | required | string | The content to write to the file |
action "save_output" "std::write_file" {
path = "./output.json"
content = {
"result" = variable.result,
"timestamp" = variable.timestamp
}
}