CloudSpec is a testing framework for cloud infrastructure projects, simplifying integration tests for AWS CDK. It provides an easy-to-use interface for deploying and testing cloud resources.
- @cloudspec/aws-cdk: Testing framework for AWS CDK applications
- @cloudspec/aws-toolkit: Utility library for interacting with AWS services
- Simple setup and execution of integration tests for the AWS CDK
- Utility functions for interacting with AWS services (S3 and Step Functions)
- Automatic resource management and cleanup
Check out our Bucket example to see CloudSpec in action.
- Install the required package for your infrastructure framework:
npm install @cloudspec/aws-cdk
- Set up your test file using Vitest and CloudSpec:
import { cloudSpec } from '@cloudspec/aws-cdk';
import { Stack } from 'aws-cdk-lib';
import { Bucket } from 'aws-cdk-lib/aws-s3';
import { describe, it } from 'vitest';
const cloud = cloudSpec();
describe('S3 Bucket Tests', () => {
cloud.setup((stack: Stack, setOutputs) => {
const bucket = new Bucket(stack, 'TestBucket');
setOutputs({ bucketName: bucket.bucketName });
});
cloud.test('bucket should exist', async (outputs) => {
// Add your test assertions here
});
});
- Run your tests using Vitest:
npx vitest
For more detailed information, please refer to the README files of individual packages.
CloudSpec AWS Toolkit is a utility library for interacting with AWS services, specifically S3 and Step Functions, in your Node.js applications.
- S3 operations:
- Check if an object exists in a bucket
- Create an object in a bucket
- Get object content from a bucket
- Step Functions operations:
- Generate console URL for executions
- Execute standard and express state machines
- Monitor execution status
npm install @cloudspec/aws-toolkit
import { s3, stepFunctions } from '@cloudspec/aws-toolkit';
// S3 operations
const objectExists = await s3.objectExists({ bucketName: 'my-bucket', key: 'my-object' });
const objectCreated = await s3.createObject({ bucketName: 'my-bucket', key: 'my-object', body: 'Hello, World!' });
const content = await s3.getObjectContent({ bucketName: 'my-bucket', key: 'my-object' });
// Step Functions operations
const consoleUrl = stepFunctions.getConsoleUrl({ executionArn: 'arn:aws:states:...' });
const result = await stepFunctions.execute({
stateMachineArn: 'arn:aws:states:...',
input: { key: 'value' },
timeout: 60000
});
Set the AWS_REGION
environment variable or it will default to 'us-east-1'.
We welcome contributions!
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.