data
AWS Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the AWS KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.aws.*.
Use lua_read_doc("integrations.aws") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
AWS workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.aws.list_s3_buckets({region = "example_region"}))' --json kosmo integrations:lua --eval 'print(docs.read("aws"))' --json
kosmo integrations:lua --eval 'print(docs.read("aws.list_s3_buckets"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local aws = app.integrations.aws
local result = aws.list_s3_buckets({region = "example_region"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.aws, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.aws.default.* or app.integrations.aws.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need AWS, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
AWS — Lua API Reference
list_s3_buckets
List all S3 buckets in the AWS account.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
region | string | no | AWS region to query (e.g., "us-east-1") |
Example
local result = app.integrations.aws.list_s3_buckets({})
for _, bucket in ipairs(result.buckets or {}) do
print(bucket.name .. " (" .. bucket.region .. ")")
end
list_ec2_instances
Describe EC2 instances with optional filtering.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
instance_ids | array | no | List of instance IDs to describe (e.g., {"i-1234567890abcdef0"}) |
filters | array | no | Filters to apply (e.g., {{Name = "instance-state-name", Values = {"running"}}}) |
region | string | no | AWS region to query |
Examples
-- List all running instances
local result = app.integrations.aws.list_ec2_instances({
filters = {{Name = "instance-state-name", Values = {"running"}}}
})
-- List specific instances
local result = app.integrations.aws.list_ec2_instances({
instance_ids = {"i-1234567890abcdef0", "i-0987654321fedcba0"}
})
list_lambda_functions
List all Lambda functions.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
max_items | integer | no | Maximum number of functions to return (default: 50) |
region | string | no | AWS region to query |
Example
local result = app.integrations.aws.list_lambda_functions({max_items = 20})
for _, fn in ipairs(result.functions or {}) do
print(fn.name .. " (" .. fn.runtime .. ")")
end
invoke_lambda
Invoke a Lambda function with an optional payload.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
function_name | string | yes | Name or ARN of the Lambda function |
payload | object | no | JSON payload to pass to the function |
invocation_type | string | no | "RequestResponse" (sync, default), "Event" (async), or "DryRun" |
region | string | no | AWS region |
Examples
-- Synchronous invocation
local result = app.integrations.aws.invoke_lambda({
function_name = "my-function",
payload = {key = "value"},
invocation_type = "RequestResponse"
})
print(result.status_code, result.payload)
-- Async invocation (fire and forget)
local result = app.integrations.aws.invoke_lambda({
function_name = "my-function",
payload = {event = "trigger"},
invocation_type = "Event"
})
list_dynamodb_tables
List all DynamoDB tables.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of table names to return (default: 100) |
exclusive_start_table_name | string | no | Pagination token — table name to start from |
region | string | no | AWS region to query |
Example
local result = app.integrations.aws.list_dynamodb_tables({})
for _, name in ipairs(result.table_names or {}) do
print(name)
end
get_cloudwatch_metrics
Get CloudWatch metric data for AWS resources.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
namespace | string | yes | CloudWatch namespace (e.g., "AWS/EC2", "AWS/Lambda") |
metric_name | string | yes | Metric name (e.g., "CPUUtilization", "Invocations") |
statistics | array | yes | Statistics to retrieve (e.g., {"Average", "Maximum"}) |
start_time | string | yes | Start time (ISO 8601, e.g., "2026-01-01T00:00:00Z") |
end_time | string | yes | End time (ISO 8601, e.g., "2026-01-02T00:00:00Z") |
period | integer | no | Granularity in seconds (60, 300, 3600). Default: 300 |
dimensions | array | no | Dimensions to filter by |
region | string | no | AWS region |
Examples
-- EC2 CPU utilization (last hour, 5-minute periods)
local result = app.integrations.aws.get_cloudwatch_metrics({
namespace = "AWS/EC2",
metric_name = "CPUUtilization",
statistics = {"Average", "Maximum"},
start_time = "2026-04-05T00:00:00Z",
end_time = "2026-04-05T01:00:00Z",
period = 300,
dimensions = {{Name = "InstanceId", Value = "i-1234567890abcdef0"}}
})
-- Lambda invocation count
local result = app.integrations.aws.get_cloudwatch_metrics({
namespace = "AWS/Lambda",
metric_name = "Invocations",
statistics = {"Sum"},
start_time = "2026-04-04T00:00:00Z",
end_time = "2026-04-05T00:00:00Z",
period = 3600
})
list_sns_topics
List all SNS notification topics.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
next_token | string | no | Pagination token from a previous response |
region | string | no | AWS region to query |
Example
local result = app.integrations.aws.list_sns_topics({})
for _, topic in ipairs(result.topics or {}) do
print(topic.topic_arn)
end
get_current_user
Get the current IAM user identity.
Parameters
None.
Example
local result = app.integrations.aws.get_current_user({})
print("User ARN: " .. result.user.arn)
print("Account ID: " .. result.user.account_id)
print("User ID: " .. result.user.user_id)
Multi-Account Usage
If you have multiple AWS accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.aws.list_s3_buckets({})
-- Explicit default (portable across setups)
app.integrations.aws.default.list_s3_buckets({})
-- Named accounts
app.integrations.aws.production.list_s3_buckets({})
app.integrations.aws.staging.list_ec2_instances({})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# AWS — Lua API Reference
## list_s3_buckets
List all S3 buckets in the AWS account.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `region` | string | no | AWS region to query (e.g., `"us-east-1"`) |
### Example
```lua
local result = app.integrations.aws.list_s3_buckets({})
for _, bucket in ipairs(result.buckets or {}) do
print(bucket.name .. " (" .. bucket.region .. ")")
end
```
---
## list_ec2_instances
Describe EC2 instances with optional filtering.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `instance_ids` | array | no | List of instance IDs to describe (e.g., `{"i-1234567890abcdef0"}`) |
| `filters` | array | no | Filters to apply (e.g., `{{Name = "instance-state-name", Values = {"running"}}}`) |
| `region` | string | no | AWS region to query |
### Examples
```lua
-- List all running instances
local result = app.integrations.aws.list_ec2_instances({
filters = {{Name = "instance-state-name", Values = {"running"}}}
})
-- List specific instances
local result = app.integrations.aws.list_ec2_instances({
instance_ids = {"i-1234567890abcdef0", "i-0987654321fedcba0"}
})
```
---
## list_lambda_functions
List all Lambda functions.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `max_items` | integer | no | Maximum number of functions to return (default: 50) |
| `region` | string | no | AWS region to query |
### Example
```lua
local result = app.integrations.aws.list_lambda_functions({max_items = 20})
for _, fn in ipairs(result.functions or {}) do
print(fn.name .. " (" .. fn.runtime .. ")")
end
```
---
## invoke_lambda
Invoke a Lambda function with an optional payload.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `function_name` | string | yes | Name or ARN of the Lambda function |
| `payload` | object | no | JSON payload to pass to the function |
| `invocation_type` | string | no | `"RequestResponse"` (sync, default), `"Event"` (async), or `"DryRun"` |
| `region` | string | no | AWS region |
### Examples
```lua
-- Synchronous invocation
local result = app.integrations.aws.invoke_lambda({
function_name = "my-function",
payload = {key = "value"},
invocation_type = "RequestResponse"
})
print(result.status_code, result.payload)
-- Async invocation (fire and forget)
local result = app.integrations.aws.invoke_lambda({
function_name = "my-function",
payload = {event = "trigger"},
invocation_type = "Event"
})
```
---
## list_dynamodb_tables
List all DynamoDB tables.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of table names to return (default: 100) |
| `exclusive_start_table_name` | string | no | Pagination token — table name to start from |
| `region` | string | no | AWS region to query |
### Example
```lua
local result = app.integrations.aws.list_dynamodb_tables({})
for _, name in ipairs(result.table_names or {}) do
print(name)
end
```
---
## get_cloudwatch_metrics
Get CloudWatch metric data for AWS resources.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `namespace` | string | yes | CloudWatch namespace (e.g., `"AWS/EC2"`, `"AWS/Lambda"`) |
| `metric_name` | string | yes | Metric name (e.g., `"CPUUtilization"`, `"Invocations"`) |
| `statistics` | array | yes | Statistics to retrieve (e.g., `{"Average", "Maximum"}`) |
| `start_time` | string | yes | Start time (ISO 8601, e.g., `"2026-01-01T00:00:00Z"`) |
| `end_time` | string | yes | End time (ISO 8601, e.g., `"2026-01-02T00:00:00Z"`) |
| `period` | integer | no | Granularity in seconds (60, 300, 3600). Default: 300 |
| `dimensions` | array | no | Dimensions to filter by |
| `region` | string | no | AWS region |
### Examples
```lua
-- EC2 CPU utilization (last hour, 5-minute periods)
local result = app.integrations.aws.get_cloudwatch_metrics({
namespace = "AWS/EC2",
metric_name = "CPUUtilization",
statistics = {"Average", "Maximum"},
start_time = "2026-04-05T00:00:00Z",
end_time = "2026-04-05T01:00:00Z",
period = 300,
dimensions = {{Name = "InstanceId", Value = "i-1234567890abcdef0"}}
})
-- Lambda invocation count
local result = app.integrations.aws.get_cloudwatch_metrics({
namespace = "AWS/Lambda",
metric_name = "Invocations",
statistics = {"Sum"},
start_time = "2026-04-04T00:00:00Z",
end_time = "2026-04-05T00:00:00Z",
period = 3600
})
```
---
## list_sns_topics
List all SNS notification topics.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `next_token` | string | no | Pagination token from a previous response |
| `region` | string | no | AWS region to query |
### Example
```lua
local result = app.integrations.aws.list_sns_topics({})
for _, topic in ipairs(result.topics or {}) do
print(topic.topic_arn)
end
```
---
## get_current_user
Get the current IAM user identity.
### Parameters
None.
### Example
```lua
local result = app.integrations.aws.get_current_user({})
print("User ARN: " .. result.user.arn)
print("Account ID: " .. result.user.account_id)
print("User ID: " .. result.user.user_id)
```
---
## Multi-Account Usage
If you have multiple AWS accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.aws.list_s3_buckets({})
-- Explicit default (portable across setups)
app.integrations.aws.default.list_s3_buckets({})
-- Named accounts
app.integrations.aws.production.list_s3_buckets({})
app.integrations.aws.staging.list_ec2_instances({})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.aws.list_s3_buckets({region = "example_region"})
print(result) Functions
list_s3_buckets Read
List all S3 buckets in the AWS account. Returns bucket names, creation dates, and regions.
- Lua path
app.integrations.aws.list_s3_buckets- Full name
aws.aws_list_s3_buckets
| Parameter | Type | Required | Description |
|---|---|---|---|
region | string | no | AWS region to query (e.g., "us-east-1"). Defaults to the configured region. |
list_ec2_instances Read
Describe EC2 instances in the AWS account. Returns instance IDs, types, states, and metadata. Supports filtering by instance IDs, states, or tags.
- Lua path
app.integrations.aws.list_ec2_instances- Full name
aws.aws_list_ec2_instances
| Parameter | Type | Required | Description |
|---|---|---|---|
instance_ids | array | no | List of specific instance IDs to describe (e.g., ["i-1234567890abcdef0"]). Omit to list all instances. |
filters | array | no | Filters to apply (e.g., [{"Name": "instance-state-name", "Values": ["running"]}]). |
region | string | no | AWS region to query (e.g., "us-east-1"). Defaults to the configured region. |
list_lambda_functions Read
List all Lambda functions in the AWS account. Returns function names, runtimes, descriptions, and configuration.
- Lua path
app.integrations.aws.list_lambda_functions- Full name
aws.aws_list_lambda_functions
| Parameter | Type | Required | Description |
|---|---|---|---|
max_items | integer | no | Maximum number of functions to return (default: 50). |
region | string | no | AWS region to query (e.g., "us-east-1"). Defaults to the configured region. |
invoke_lambda Write
Invoke an AWS Lambda function with an optional payload. Supports synchronous (RequestResponse) and asynchronous (Event) invocation modes.
- Lua path
app.integrations.aws.invoke_lambda- Full name
aws.aws_invoke_lambda
| Parameter | Type | Required | Description |
|---|---|---|---|
function_name | string | yes | The name or ARN of the Lambda function to invoke. |
payload | object | no | JSON payload to pass to the Lambda function. |
invocation_type | string | no | Invocation type: "RequestResponse" (sync, default), "Event" (async), or "DryRun" (validate only). |
region | string | no | AWS region (e.g., "us-east-1"). Defaults to the configured region. |
list_dynamodb_tables Read
List all DynamoDB tables in the AWS account. Returns table names and can be used with pagination to enumerate all tables.
- Lua path
app.integrations.aws.list_dynamodb_tables- Full name
aws.aws_list_dynamodb_tables
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of table names to return (default: 100). |
exclusive_start_table_name | string | no | The first table name that this operation will evaluate. Use for pagination. |
region | string | no | AWS region to query (e.g., "us-east-1"). Defaults to the configured region. |
get_cloudwatch_metrics Read
Get CloudWatch metric data for AWS resources. Supports querying metrics by namespace, metric name, dimensions, and time range with configurable statistics and periods.
- Lua path
app.integrations.aws.get_cloudwatch_metrics- Full name
aws.aws_get_cloudwatch_metrics
| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | yes | The CloudWatch namespace (e.g., "AWS/EC2", "AWS/Lambda", "AWS/DynamoDB"). |
metric_name | string | yes | The name of the metric (e.g., "CPUUtilization", "Invocations", "ReadThrottleEvents"). |
statistics | array | yes | Statistics to retrieve (e.g., ["Average", "Maximum", "Sum"]). |
start_time | string | yes | Start time for the query (ISO 8601, e.g., "2026-01-01T00:00:00Z"). |
end_time | string | yes | End time for the query (ISO 8601, e.g., "2026-01-02T00:00:00Z"). |
period | integer | no | The granularity in seconds for the returned data points (e.g., 60, 300, 3600). Default: 300. |
dimensions | array | no | Dimensions to filter by (e.g., [{"Name": "InstanceId", "Value": "i-1234567890abcdef0"}]). |
region | string | no | AWS region to query (e.g., "us-east-1"). Defaults to the configured region. |
list_sns_topics Read
List all SNS notification topics in the AWS account. Returns topic ARNs and names.
- Lua path
app.integrations.aws.list_sns_topics- Full name
aws.aws_list_sns_topics
| Parameter | Type | Required | Description |
|---|---|---|---|
next_token | string | no | Pagination token from a previous response to get the next page of results. |
region | string | no | AWS region to query (e.g., "us-east-1"). Defaults to the configured region. |
get_current_user Read
Get the current IAM user identity. Returns user ARN, account ID, and user ID. Useful for verifying credentials and understanding which AWS account is being accessed.
- Lua path
app.integrations.aws.get_current_user- Full name
aws.aws_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||