@dsqr/ace
v0.0.0-beta.18
Published
A library of reusable AWS constructs that can be easily integrated into your applications. ACE supports both the traditional `npm` import style and the newer `shaden` CLI style, giving you flexibility to choose your preferred approach.
Downloads
290
Readme
Amazon Construct Engine
A library of reusable AWS constructs that can be easily integrated into your applications. ACE supports both the traditional npm
import style and the newer shaden
CLI style, giving you flexibility to choose your preferred approach.
Getting Started
Installation
Local First Constructs
Install and add a construct locally using the CLI. For example, to add a DynamoDB table construct:
npx dsqr add table
Once added, you can use it in your stack:
import { DynamoTable } from "./constructs/table";
new DynamoTable(this, "MyTable", {
partitionKey: { name: "id", type: "string" },
});
The add command works under the assumption you created your proejcts with teh dsqr
or cdk
cli tool, and will look for a ./lib/constructs
, if one does not exist it will create it. All constrcuts will be imported to ./lib/constrcuts/ace
.
NPM Constructs
Prefer not to manage constructs locally? You can import them directly from NPM and use them out of the box:
npm install @dsqr/ace
Then use it in your application:
import { DynamoTable } from "@dsqr/constructs";
new DynamoTable(this, "MyTable", {
partitionKey: { name: "id", type: "string" },
});
Examples
Using the ACE App
ACE provides a custom App
class that extends the standard AWS CDK App
. This simplifies managing stages and environments.
#!/usr/bin/env node
import * as ace from "@dsqr/ace";
import { StaticSite } from "../lib/stacks/static-site";
// Define your AWS environment variables
const env = {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
};
// Determine the current stage (default: development)
const stage = process.env.CDK_STAGE || "development";
// Create a new ACE app
const app = new ace.aws.App({
name: "MyApplication",
stage,
region: env.region,
account: env.account,
});
// Add the environment-specific stage dynamically
app.addStage("DaveDennisDotDev", (currentStage) => {
new StaticSite(currentStage, "PersonalSite", {
env,
domainName:
stage === "development" ? "dev.davedennis.dev" : "davedennis.dev",
});
});
app.synth(); // Synthesize the app
Creating a Static Site
Why this repo was originally built, was the need to deploy static sites (vite in my case, but any static site will work), quick and easy using the CDK. Most pet projects started out this way, so it was used to speed that up. The construct allows you to deploy static content quickly. It will build and deploy your content for you. If you dont' want to build the content, you can just pass in build.path and build.outputDir and it will upload the content at that destination, or you can can not pass in build at all, and handle the deployment of the content your self. The constrcut in this case would simply create the infrastructe for you (CloudFront Distribution -> S3) but would not uplaod any content to the bucket.
import * as "ace" from "@dsqr/ace";
new ace.aws.StaticSite(this, "StaticSite", {
indexPage: "index.html",
build: {
command: "bun run build",
path: "../../packages/web",
outputDir: "dist"
},
customDomain: {
domainName: props.domainName,
overrides: {
certificate: certificate
}
}
})