@intentius/chant-lexicon-aws 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,41 +0,0 @@
1
- ---
2
- name: aws-cloudformation
3
- description: AWS CloudFormation best practices and common patterns
4
- ---
5
-
6
- # AWS CloudFormation with Chant
7
-
8
- ## Common Resource Types
9
-
10
- - `AWS::S3::Bucket` — Object storage
11
- - `AWS::Lambda::Function` — Serverless compute
12
- - `AWS::DynamoDB::Table` — NoSQL database
13
- - `AWS::IAM::Role` — Identity and access management
14
- - `AWS::SNS::Topic` — Pub/sub messaging
15
- - `AWS::SQS::Queue` — Message queue
16
- - `AWS::EC2::SecurityGroup` — Network firewall rules
17
-
18
- ## Intrinsic Functions
19
-
20
- - `Sub` — String interpolation with `${}` syntax
21
- - `Ref` — Reference a resource or parameter
22
- - `GetAtt` — Get a resource attribute (e.g. ARN)
23
- - `If` — Conditional value based on a condition
24
- - `Join` — Join strings with a delimiter
25
- - `Select` — Pick an item from a list by index
26
-
27
- ## Pseudo Parameters
28
-
29
- - `AWS::StackName` — Name of the current stack
30
- - `AWS::Region` — Current deployment region
31
- - `AWS::AccountId` — Current AWS account ID
32
- - `AWS::Partition` — Partition (aws, aws-cn, aws-us-gov)
33
-
34
- ## Best Practices
35
-
36
- 1. **Always enable encryption** — Use `BucketEncryption` for S3, `SSESpecification` for DynamoDB
37
- 2. **Block public access** — Set `PublicAccessBlockConfiguration` on all S3 buckets
38
- 3. **Use least-privilege IAM** — Avoid `*` in IAM policy actions and resources
39
- 4. **Enable versioning** — Turn on `VersioningConfiguration` for data buckets
40
- 5. **Use Sub for dynamic names** — `Sub\`\${AWS::StackName}-suffix\`` for unique naming
41
- 6. **Share config via direct imports** — Put common settings in a config file and import directly
@@ -1,80 +0,0 @@
1
- import { describe, test, expect } from "bun:test";
2
- import { mkdirSync, writeFileSync, rmSync, readFileSync } from "fs";
3
- import { join } from "path";
4
- import { tmpdir } from "os";
5
- import { snapshotArtifacts, saveSnapshot, restoreSnapshot, listSnapshots } from "./rollback";
6
-
7
- function makeTempDir(): string {
8
- const dir = join(tmpdir(), `chant-rollback-test-${Date.now()}-${Math.random().toString(36).slice(2)}`);
9
- mkdirSync(dir, { recursive: true });
10
- return dir;
11
- }
12
-
13
- describe("rollback", () => {
14
- test("snapshot captures generated files", () => {
15
- const dir = makeTempDir();
16
- const genDir = join(dir, "generated");
17
- mkdirSync(genDir, { recursive: true });
18
-
19
- writeFileSync(join(genDir, "lexicon-aws.json"), '{"Bucket":{"kind":"resource"}}');
20
- writeFileSync(join(genDir, "index.d.ts"), "declare class Bucket {}");
21
- writeFileSync(join(genDir, "index.ts"), "export const Bucket = {};");
22
-
23
- const snapshot = snapshotArtifacts(genDir);
24
- expect(snapshot.files["lexicon-aws.json"]).toBeDefined();
25
- expect(snapshot.files["index.d.ts"]).toBeDefined();
26
- expect(snapshot.files["index.ts"]).toBeDefined();
27
- expect(snapshot.hashes["lexicon-aws.json"]).toBeDefined();
28
- expect(snapshot.resourceCount).toBe(1);
29
-
30
- rmSync(dir, { recursive: true, force: true });
31
- });
32
-
33
- test("save and list snapshots", () => {
34
- const dir = makeTempDir();
35
- const snapshotsDir = join(dir, ".snapshots");
36
-
37
- const snapshot = {
38
- timestamp: "2025-01-01T00:00:00.000Z",
39
- files: { "test.json": "{}" },
40
- hashes: { "test.json": "abc123" },
41
- resourceCount: 0,
42
- };
43
-
44
- saveSnapshot(snapshot, snapshotsDir);
45
- const list = listSnapshots(snapshotsDir);
46
- expect(list.length).toBe(1);
47
- expect(list[0].timestamp).toBe("2025-01-01T00:00:00.000Z");
48
-
49
- rmSync(dir, { recursive: true, force: true });
50
- });
51
-
52
- test("restore snapshot overwrites generated files", () => {
53
- const dir = makeTempDir();
54
- const genDir = join(dir, "generated");
55
- const snapshotsDir = join(dir, ".snapshots");
56
- mkdirSync(genDir, { recursive: true });
57
-
58
- // Write original files
59
- writeFileSync(join(genDir, "lexicon-aws.json"), '{"original":true}');
60
-
61
- // Snapshot them
62
- const snapshot = snapshotArtifacts(genDir);
63
- const snapshotPath = saveSnapshot(snapshot, snapshotsDir);
64
-
65
- // Overwrite with new content
66
- writeFileSync(join(genDir, "lexicon-aws.json"), '{"modified":true}');
67
- expect(readFileSync(join(genDir, "lexicon-aws.json"), "utf-8")).toBe('{"modified":true}');
68
-
69
- // Restore
70
- restoreSnapshot(snapshotPath, genDir);
71
- expect(readFileSync(join(genDir, "lexicon-aws.json"), "utf-8")).toBe('{"original":true}');
72
-
73
- rmSync(dir, { recursive: true, force: true });
74
- });
75
-
76
- test("listSnapshots returns empty for nonexistent dir", () => {
77
- const list = listSnapshots("/nonexistent/path");
78
- expect(list).toHaveLength(0);
79
- });
80
- });
@@ -1,20 +0,0 @@
1
- /**
2
- * Re-export from core with AWS-specific artifact names.
3
- */
4
- import {
5
- snapshotArtifacts as _snapshotArtifacts,
6
- saveSnapshot,
7
- restoreSnapshot,
8
- listSnapshots,
9
- } from "@intentius/chant/codegen/rollback";
10
- export type { ArtifactSnapshot, SnapshotInfo } from "@intentius/chant/codegen/rollback";
11
- export { saveSnapshot, restoreSnapshot, listSnapshots };
12
-
13
- const AWS_ARTIFACT_NAMES = ["lexicon-aws.json", "index.d.ts", "index.ts"];
14
-
15
- /**
16
- * Snapshot AWS lexicon artifacts.
17
- */
18
- export function snapshotArtifacts(generatedDir: string) {
19
- return _snapshotArtifacts(generatedDir, AWS_ARTIFACT_NAMES);
20
- }