KosmoKrator

other

AWS Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the AWS KosmoKrator integration.

8 functions 7 read 1 write Bearer token auth

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.

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

NameTypeRequiredDescription
regionstringnoAWS 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

NameTypeRequiredDescription
instance_idsarraynoList of instance IDs to describe (e.g., {"i-1234567890abcdef0"})
filtersarraynoFilters to apply (e.g., {{Name = "instance-state-name", Values = {"running"}}})
regionstringnoAWS 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

NameTypeRequiredDescription
max_itemsintegernoMaximum number of functions to return (default: 50)
regionstringnoAWS 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

NameTypeRequiredDescription
function_namestringyesName or ARN of the Lambda function
payloadobjectnoJSON payload to pass to the function
invocation_typestringno"RequestResponse" (sync, default), "Event" (async), or "DryRun"
regionstringnoAWS 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

NameTypeRequiredDescription
limitintegernoMaximum number of table names to return (default: 100)
exclusive_start_table_namestringnoPagination token — table name to start from
regionstringnoAWS 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

NameTypeRequiredDescription
namespacestringyesCloudWatch namespace (e.g., "AWS/EC2", "AWS/Lambda")
metric_namestringyesMetric name (e.g., "CPUUtilization", "Invocations")
statisticsarrayyesStatistics to retrieve (e.g., {"Average", "Maximum"})
start_timestringyesStart time (ISO 8601, e.g., "2026-01-01T00:00:00Z")
end_timestringyesEnd time (ISO 8601, e.g., "2026-01-02T00:00:00Z")
periodintegernoGranularity in seconds (60, 300, 3600). Default: 300
dimensionsarraynoDimensions to filter by
regionstringnoAWS 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

NameTypeRequiredDescription
next_tokenstringnoPagination token from a previous response
regionstringnoAWS 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.

Metadata-Derived Lua Example

local result = app.integrations.aws.aws_list_s3_buckets({
  region = "example_region"
})
print(result)

Functions

aws_list_s3_buckets

List all S3 buckets in the AWS account. Returns bucket names, creation dates, and regions.

Operation
Read read
Full name
aws.aws_list_s3_buckets
ParameterTypeRequiredDescription
region string no AWS region to query (e.g., "us-east-1"). Defaults to the configured region.

aws_list_ec2_instances

Describe EC2 instances in the AWS account. Returns instance IDs, types, states, and metadata. Supports filtering by instance IDs, states, or tags.

Operation
Read read
Full name
aws.aws_list_ec2_instances
ParameterTypeRequiredDescription
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.

aws_list_lambda_functions

List all Lambda functions in the AWS account. Returns function names, runtimes, descriptions, and configuration.

Operation
Read read
Full name
aws.aws_list_lambda_functions
ParameterTypeRequiredDescription
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.

aws_invoke_lambda

Invoke an AWS Lambda function with an optional payload. Supports synchronous (RequestResponse) and asynchronous (Event) invocation modes.

Operation
Write write
Full name
aws.aws_invoke_lambda
ParameterTypeRequiredDescription
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.

aws_list_dynamodb_tables

List all DynamoDB tables in the AWS account. Returns table names and can be used with pagination to enumerate all tables.

Operation
Read read
Full name
aws.aws_list_dynamodb_tables
ParameterTypeRequiredDescription
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.

aws_get_cloudwatch_metrics

Get CloudWatch metric data for AWS resources. Supports querying metrics by namespace, metric name, dimensions, and time range with configurable statistics and periods.

Operation
Read read
Full name
aws.aws_get_cloudwatch_metrics
ParameterTypeRequiredDescription
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.

aws_list_sns_topics

List all SNS notification topics in the AWS account. Returns topic ARNs and names.

Operation
Read read
Full name
aws.aws_list_sns_topics
ParameterTypeRequiredDescription
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.

aws_get_current_user

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.

Operation
Read read
Full name
aws.aws_get_current_user
ParameterTypeRequiredDescription
No parameters.