@rank-lang/plugin-aws
v0.3.1
Published
AWS provider workspace package
Readme
@rank-lang/plugin-aws
First-party AWS provider package for Rank.
Install
Reference the provider from your Rank manifest:
manifestVersion = 1
[package]
name = "aws-example"
version = "0.1.0"
source = "src"
[providers]
aws = { registry = "npm", package = "@rank-lang/plugin-aws", version = "0.1.0" }The package exports three modules under the aws namespace:
use aws::{ DynamoDB, S3, SecretsManager }Current scope
- AWS SDK v3-backed getter implementations for
DynamoDB::Item,DynamoDB::Query,S3::Object, andSecretsManager::Secret - AWS SDK v3-backed
DynamoDB::Putmutation receipts with optional condition support - AWS SDK v3-backed
DynamoDB::Updatemutation receipts with shallowSETupdates and optional condition support - AWS SDK v3-backed
S3::Putmutation receipts with JSON serialization and optionaleTag/versionId - provider-owned Rank source modules for
aws::DynamoDB,aws::S3, andaws::SecretsManager - plain module
createClienthelpers and typed schema aliases - focused mocked Vitest coverage for the fast inner loop
- LocalStack-backed integration coverage for real DynamoDB, S3, and Secrets Manager requests
The v1 getter and mutator surface is implemented. Remaining work is phase-4 hardening around packaged-provider smoke coverage and broader host-flow validation.
Quick start
Create serializable client configs with the provider-owned helpers:
use aws::{ DynamoDB, S3, SecretsManager }
dynamoClient: aws::DynamoDB::ClientConfig = DynamoDB::createClient({
region: `us-east-1`,
})
s3Client: aws::S3::ClientConfig = S3::createClient({
region: `us-east-1`,
})
secretsClient: aws::SecretsManager::ClientConfig = SecretsManager::createClient({
region: `us-east-1`,
})These values are plain serializable configs. The provider runtime memoizes the real AWS SDK clients per live provider session.
Getter example
use aws::{ DynamoDB, S3, SecretsManager }
User = Object {
userId: string,
email: string,
status: `active` | `inactive`,
}
UsersTable = DynamoDB::Table<User, `userId`>
dynamoClient: aws::DynamoDB::ClientConfig = DynamoDB::createClient({
region: `us-east-1`,
})
{ item, metadata } = DynamoDB::Item<UsersTable> {
client: dynamoClient,
tableName: `Users`,
key: {
userId: `123`,
},
}DynamoDB::Query<Resource> uses explicit runtime target metadata and, for index queries, a resource-constrained indexName field. S3::Object<T> reads UTF-8 JSON objects, and SecretsManager::Secret<T> requires format: string or format: json.
Mutation example
use aws::DynamoDB::{ Table, UpdatePatch }
use std::Mutation
User = Object {
userId: string,
email: string,
status: `active` | `inactive`,
}
UsersTable = Table<User, `userId`>
UserPatch = UpdatePatch<UsersTable>
dynamoClient: aws::DynamoDB::ClientConfig = aws::DynamoDB::createClient({
region: `us-east-1`,
})
s3Client: aws::S3::ClientConfig = aws::S3::createClient({
region: `us-east-1`,
})
putUser: Mutation::Effect<User> = aws::DynamoDB::Put<UsersTable> {
client: dynamoClient,
tableName: `Users`,
}
activateUser: Mutation::Effect<UserPatch> = aws::DynamoDB::Update<UsersTable, UserPatch> {
client: dynamoClient,
tableName: `Users`,
key: {
userId: `123`,
},
}
uploadUser: Mutation::Effect<User> = aws::S3::Put<User> {
client: s3Client,
bucket: `profiles`,
key: `users/123.json`,
}
created = putUser({
userId: `123`,
email: `[email protected]`,
status: `inactive`,
})
activated = activateUser({
status: `active`,
})
uploaded = uploadUser({
userId: created.userId,
email: created.email,
status: created.status,
})Fulfillment returns the declared payload value, which stays commit-local and can feed later mutation inputs. Receipt metadata is retained for commit summaries and Mutation::commit(...) projection.
Serve-time JSON and YAML responses may also realize a top-level Mutation::commit(...) body, so AWS receipt metadata can flow directly into HTTP::Response output when needed.
API notes
DynamoDB
Table<T, PK, SK?>declares the base table schema.GSI<BaseTable, Name, IndexTable>andLSI<BaseTable, Name, IndexTable>declare query-only secondary-index schemas.KeyInput<Table>derives the exact key object from the declared table schema.UpdatePatch<Table>is shallow and excludes the declared key fields.QueryInput<Resource>specializes table, GSI, and LSI query inputs from the selected resource kind.
Receipts and metadata
- getter results return
metadata: RequestMetadataorPageMetadata DynamoDB::PutReceiptandDynamoDB::UpdateReceiptincluderequestIdplus optional consumed-capacity summariesS3::PutReceiptincludesrequestIdplus optionaleTagandversionId
Operator notes
IAM and credentials
- this provider assumes the admitted AWS principal is already least-privilege for the tables, buckets, and secrets you intend the program to access
- use service-specific IAM policies to scope real permissions; the Rank host does not yet add AWS-specific table or bucket allowlists on top of IAM
- when credentials come from
Env, source them through@sensitivedestructuring so they stay redacted in diagnostics
Example:
use std::Env
SysEnvironment = Object {
AWS_ACCESS_KEY_ID: string,
AWS_SECRET_ACCESS_KEY: string,
...: string,
}
@sensitive
{ AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY } = Env<SysEnvironment> {}Mutation admission
Mutation exports are separately default-denied. In addition to admitting provider capabilities such as network, your host config must explicitly allow the reachable mutation export names.
[security]
allow-provider-capabilities = ["network"]
allow-provider-mutation-exports = [
"aws::DynamoDB::Put",
"aws::DynamoDB::Update",
"aws::S3::Put",
]LocalStack
The package keeps a pinned LocalStack harness in test/localstack/docker-compose.yml covering DynamoDB, S3, and Secrets Manager.
Typical workflow:
npm run localstack:up -w @rank-lang/plugin-aws
npm run test:localstack -w @rank-lang/plugin-aws
npm run localstack:down -w @rank-lang/plugin-awsKnown v1 limitations
S3::Object<T>andS3::Put<T>are JSON-only in v1SecretsManager::Secret<T>supportsSecretStringonly;SecretBinaryis rejectedDynamoDB::Update<Table, Patch>lowers only shallowSETupdates; removal helpers and deeper path operations are deferredDynamoDB::Query<Resource>uses native DynamoDB expression strings rather than a typed expression DSL- resource-scoped host allowlists for AWS tables, buckets, and secrets are deferred; rely on IAM plus the generic mutation-export allowlist
Development
npm run build -w @rank-lang/plugin-aws
npm run typecheck -w @rank-lang/plugin-aws
npm run test -w @rank-lang/plugin-aws
npm run test:localstack -w @rank-lang/plugin-awsnpm run test:localstack -w @rank-lang/plugin-aws requires docker compose and starts a pinned LocalStack container defined in test/localstack/docker-compose.yml.
Publishing
Build the package first, then publish from the workspace root:
npm run build -w @rank-lang/plugin-aws
npm publish -w @rank-lang/plugin-awsLike the Faker plugin, this package currently relies on normal npm runtime dependencies rather than a fully bundled standalone provider artifact. In particular, it expects @aws-sdk/*, @aws-sdk/lib-dynamodb, and @rank-lang/provider-runtime to materialize as runtime npm dependencies when the package is installed from a registry.
