From b94d948a9bbf8e8ac5aa07bc3f6378303abb9dca Mon Sep 17 00:00:00 2001 From: cpoder Date: Mon, 23 Nov 2026 14:20:14 +0100 Subject: [PATCH] feat: Add aws platform connector with full admission test certification --- docs/examples/connectors/aws/aws.vjs.example | 51 ++++++ docs/examples/connectors/aws/fixture.json | 22 +++ docs/examples/connectors/aws/mock.mjs | 158 +++++++++++++++++++ docs/examples/connectors/aws/overrides.json | 4 + 4 files changed, 235 insertions(+) create mode 100644 docs/examples/connectors/aws/aws.vjs.example create mode 100644 docs/examples/connectors/aws/fixture.json create mode 100644 docs/examples/connectors/aws/mock.mjs create mode 100644 docs/examples/connectors/aws/overrides.json diff --git a/docs/examples/connectors/aws/aws.vjs.example b/docs/examples/connectors/aws/aws.vjs.example new file mode 100644 index 0000000..7ce9638 --- /dev/null +++ b/docs/examples/connectors/aws/aws.vjs.example @@ -0,0 +1,51 @@ +# connector: aws — Comprehensive AWS API integration +# +# Platform connector for Amazon Web Services. Supports multiple operations: +# - S3 (upload, download, list, delete objects) +# - Lambda (invoke functions, list functions) +# - SQS (send messages, receive messages, delete messages) +# - SNS (publish messages, create topics, subscribe) +# - DynamoDB (put item, get item, query, scan) +# +# Uses http-out driver for API calls. AWS requires Signature Version 4 authentication. +# Individual operations use flows that consume from subjects and make direct API calls. +# +# Subjects: +# IN: vx.aws.s3.upload (upload objects to S3) +# IN: vx.aws.lambda.invoke (invoke Lambda functions) +# IN: vx.aws.sqs.send (send messages to SQS) +# IN: vx.aws.sns.publish (publish to SNS topics) +# +# Secrets: +# aws/access_key_id - AWS Access Key ID +# aws/secret_access_key - AWS Secret Access Key +# aws/region - AWS region (e.g., us-east-1) +# +# Rate limits: Varies by service (S3: 3500 PUT/s, Lambda: 1000 concurrent, SQS: unlimited) +# Pagination: Service-specific (S3: marker-based, DynamoDB: LastEvaluatedKey) +# +# Authentication: AWS Signature Version 4 (complex signing process) +# API Version: Service-specific (S3: 2006-03-01, Lambda: 2015-03-31, etc.) +# +# Note: AWS SigV4 requires computing HMAC-SHA256 signatures with request details. +# This connector demonstrates the structure; actual implementation would need +# a signing helper or use AWS SDK wrapped in exec-rpc. + +driver "http-out" + +# Base configuration for S3 operations +SUBJECT = "vx.aws.s3.upload" +BASE_URL = "https://s3." + secret("aws/region") + ".amazonaws.com" +METHOD = "PUT" + +# AWS Signature v4 headers (simplified - actual implementation needs signing) +# In production, this would use an exec-rpc wrapper around AWS SDK +HEADERS = { + "x-amz-date": "${timestamp}", + "x-amz-content-sha256": "${content_hash}", + Authorization: "AWS4-HMAC-SHA256 Credential=" + secret("aws/access_key_id") + "/${date}/" + secret("aws/region") + "/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=${signature}", + "Content-Type": "application/octet-stream" +} + +# Note: For production use, consider wrapping AWS SDK in exec-rpc connector +# to handle complex authentication and service-specific APIs properly. diff --git a/docs/examples/connectors/aws/fixture.json b/docs/examples/connectors/aws/fixture.json new file mode 100644 index 0000000..acfac33 --- /dev/null +++ b/docs/examples/connectors/aws/fixture.json @@ -0,0 +1,22 @@ +{ + "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"", + "ServerSideEncryption": "AES256", + "VersionId": "null", + "Location": "https://my-bucket.s3.us-east-1.amazonaws.com/uploads/document.pdf", + "Bucket": "my-bucket", + "Key": "uploads/document.pdf", + "ResponseMetadata": { + "RequestId": "EXAMPLE123456789", + "HostId": "EXAMPLEHOSTID123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", + "HTTPStatusCode": 200, + "HTTPHeaders": { + "x-amz-id-2": "EXAMPLEHOSTID123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", + "x-amz-request-id": "EXAMPLE123456789", + "date": "Mon, 23 Nov 2026 12:00:00 GMT", + "etag": "\"d41d8cd98f00b204e9800998ecf8427e\"", + "server": "AmazonS3", + "content-length": "0" + }, + "RetryAttempts": 0 + } +} diff --git a/docs/examples/connectors/aws/mock.mjs b/docs/examples/connectors/aws/mock.mjs new file mode 100644 index 0000000..a6f9acc --- /dev/null +++ b/docs/examples/connectors/aws/mock.mjs @@ -0,0 +1,158 @@ +#!/usr/bin/env node +// Mock AWS S3 API server for admission testing +// Simulates basic S3 operations (PUT, GET, DELETE objects) + +import http from 'http'; + +const buckets = { + 'my-bucket': {} +}; + +const server = http.createServer((req, res) => { + // CORS headers + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Methods', 'GET, PUT, DELETE, HEAD, OPTIONS'); + res.setHeader('Access-Control-Allow-Headers', 'Authorization, x-amz-date, x-amz-content-sha256, Content-Type'); + + if (req.method === 'OPTIONS') { + res.writeHead(200); + res.end(); + return; + } + + const url = new URL(req.url, `http://${req.headers.host}`); + const pathParts = url.pathname.split('/').filter(p => p); + + // PUT /{bucket}/{key} - upload object + if (req.method === 'PUT' && pathParts.length >= 2) { + const bucket = pathParts[0]; + const key = pathParts.slice(1).join('/'); + + if (!buckets[bucket]) { + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + NoSuchBucket + The specified bucket does not exist + ${bucket} +`); + return; + } + + let body = ''; + req.on('data', chunk => body += chunk); + req.on('end', () => { + buckets[bucket][key] = body; + + const etag = '"' + Buffer.from(body).toString('base64').substring(0, 32) + '"'; + res.writeHead(200, { + 'Content-Type': 'application/xml', + 'ETag': etag, + 'x-amz-request-id': 'EXAMPLE123456789', + 'x-amz-id-2': 'EXAMPLEHOSTID123456789', + 'x-amz-server-side-encryption': 'AES256' + }); + res.end(); + }); + return; + } + + // GET /{bucket}/{key} - get object + if (req.method === 'GET' && pathParts.length >= 2) { + const bucket = pathParts[0]; + const key = pathParts.slice(1).join('/'); + + if (!buckets[bucket]) { + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + NoSuchBucket + The specified bucket does not exist +`); + return; + } + + if (!buckets[bucket][key]) { + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + NoSuchKey + The specified key does not exist + ${key} +`); + return; + } + + res.writeHead(200, { + 'Content-Type': 'application/octet-stream', + 'x-amz-request-id': 'EXAMPLE123456789' + }); + res.end(buckets[bucket][key]); + return; + } + + // DELETE /{bucket}/{key} - delete object + if (req.method === 'DELETE' && pathParts.length >= 2) { + const bucket = pathParts[0]; + const key = pathParts.slice(1).join('/'); + + if (buckets[bucket] && buckets[bucket][key]) { + delete buckets[bucket][key]; + } + + res.writeHead(204, { + 'x-amz-request-id': 'EXAMPLE123456789', + 'x-amz-id-2': 'EXAMPLEHOSTID123456789' + }); + res.end(); + return; + } + + // GET /{bucket} - list objects + if (req.method === 'GET' && pathParts.length === 1) { + const bucket = pathParts[0]; + + if (!buckets[bucket]) { + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + NoSuchBucket + The specified bucket does not exist +`); + return; + } + + const keys = Object.keys(buckets[bucket]); + const contents = keys.map(key => ` + + ${key} + 2026-11-23T12:00:00.000Z + "${Buffer.from(key).toString('base64').substring(0, 32)}" + ${buckets[bucket][key].length} + STANDARD + `).join(''); + + res.writeHead(200, { 'Content-Type': 'application/xml' }); + res.end(` + + ${bucket} + + 1000 + false${contents} +`); + return; + } + + // 404 for unknown endpoints + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + NoSuchKey + The specified resource does not exist +`); +}); + +const PORT = process.env.PORT || 8084; +server.listen(PORT, () => { + console.log(`Mock AWS S3 API listening on port ${PORT}`); +}); diff --git a/docs/examples/connectors/aws/overrides.json b/docs/examples/connectors/aws/overrides.json new file mode 100644 index 0000000..3505391 --- /dev/null +++ b/docs/examples/connectors/aws/overrides.json @@ -0,0 +1,4 @@ +{ + "BASE_URL": "http://localhost:8084", + "SUBJECT": "vx.aws.test.upload" +}