@intentius/chant-lexicon-aws 0.0.8 → 0.0.10

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.
Files changed (115) hide show
  1. package/dist/integrity.json +25 -10
  2. package/dist/manifest.json +1 -1
  3. package/dist/meta.json +5743 -896
  4. package/dist/rules/cf-refs.ts +99 -0
  5. package/dist/rules/ext001.ts +30 -21
  6. package/dist/rules/hardcoded-region.ts +1 -0
  7. package/dist/rules/iam-wildcard.ts +1 -0
  8. package/dist/rules/s3-encryption.ts +1 -0
  9. package/dist/rules/waw016.ts +86 -0
  10. package/dist/rules/waw017.ts +53 -0
  11. package/dist/rules/waw018.ts +71 -0
  12. package/dist/rules/waw019.ts +82 -0
  13. package/dist/rules/waw020.ts +64 -0
  14. package/dist/rules/waw021.ts +53 -0
  15. package/dist/rules/waw022.ts +43 -0
  16. package/dist/rules/waw023.ts +47 -0
  17. package/dist/rules/waw024.ts +54 -0
  18. package/dist/rules/waw025.ts +43 -0
  19. package/dist/rules/waw026.ts +46 -0
  20. package/dist/rules/waw027.ts +50 -0
  21. package/dist/rules/waw028.ts +47 -0
  22. package/dist/rules/waw029.ts +62 -0
  23. package/dist/rules/waw030.ts +246 -0
  24. package/dist/skills/chant-aws.md +388 -30
  25. package/dist/types/index.d.ts +1552 -1528
  26. package/package.json +2 -2
  27. package/src/actions/actions.test.ts +75 -0
  28. package/src/actions/dynamodb.ts +36 -0
  29. package/src/actions/ecr.ts +9 -0
  30. package/src/actions/ecs.ts +5 -0
  31. package/src/actions/iam.ts +3 -0
  32. package/src/actions/index.ts +9 -0
  33. package/src/actions/lambda.ts +11 -0
  34. package/src/actions/logs.ts +4 -0
  35. package/src/actions/s3.ts +34 -0
  36. package/src/actions/sns.ts +5 -0
  37. package/src/actions/sqs.ts +15 -0
  38. package/src/codegen/__snapshots__/snapshot.test.ts.snap +2 -2
  39. package/src/codegen/docs-links.test.ts +143 -0
  40. package/src/codegen/docs.ts +247 -132
  41. package/src/codegen/generate-lexicon.ts +8 -0
  42. package/src/codegen/generate-typescript.ts +25 -1
  43. package/src/composites/composites.test.ts +442 -0
  44. package/src/composites/fargate-alb.ts +253 -0
  45. package/src/composites/index.ts +20 -0
  46. package/src/composites/lambda-api.ts +20 -0
  47. package/src/composites/lambda-dynamodb.ts +64 -0
  48. package/src/composites/lambda-eventbridge.ts +36 -0
  49. package/src/composites/lambda-function.ts +76 -0
  50. package/src/composites/lambda-s3.ts +72 -0
  51. package/src/composites/lambda-sns.ts +30 -0
  52. package/src/composites/lambda-sqs.ts +44 -0
  53. package/src/composites/scheduled-lambda.ts +37 -0
  54. package/src/composites/vpc-default.ts +148 -0
  55. package/src/default-tags.test.ts +38 -0
  56. package/src/default-tags.ts +77 -0
  57. package/src/generated/index.d.ts +1552 -1528
  58. package/src/generated/lexicon-aws.json +5743 -896
  59. package/src/import/roundtrip-fixtures.test.ts +1 -1
  60. package/src/index.ts +21 -0
  61. package/src/integration.test.ts +71 -0
  62. package/src/intrinsics.ts +24 -13
  63. package/src/lint/post-synth/cf-refs.ts +99 -0
  64. package/src/lint/post-synth/ext001.test.ts +214 -31
  65. package/src/lint/post-synth/ext001.ts +30 -21
  66. package/src/lint/post-synth/waw013.test.ts +120 -0
  67. package/src/lint/post-synth/waw014.test.ts +121 -0
  68. package/src/lint/post-synth/waw015.test.ts +147 -0
  69. package/src/lint/post-synth/waw016.test.ts +141 -0
  70. package/src/lint/post-synth/waw016.ts +86 -0
  71. package/src/lint/post-synth/waw017.test.ts +130 -0
  72. package/src/lint/post-synth/waw017.ts +53 -0
  73. package/src/lint/post-synth/waw018.test.ts +109 -0
  74. package/src/lint/post-synth/waw018.ts +71 -0
  75. package/src/lint/post-synth/waw019.test.ts +138 -0
  76. package/src/lint/post-synth/waw019.ts +82 -0
  77. package/src/lint/post-synth/waw020.test.ts +125 -0
  78. package/src/lint/post-synth/waw020.ts +64 -0
  79. package/src/lint/post-synth/waw021.test.ts +81 -0
  80. package/src/lint/post-synth/waw021.ts +53 -0
  81. package/src/lint/post-synth/waw022.test.ts +54 -0
  82. package/src/lint/post-synth/waw022.ts +43 -0
  83. package/src/lint/post-synth/waw023.test.ts +53 -0
  84. package/src/lint/post-synth/waw023.ts +47 -0
  85. package/src/lint/post-synth/waw024.test.ts +64 -0
  86. package/src/lint/post-synth/waw024.ts +54 -0
  87. package/src/lint/post-synth/waw025.test.ts +42 -0
  88. package/src/lint/post-synth/waw025.ts +43 -0
  89. package/src/lint/post-synth/waw026.test.ts +54 -0
  90. package/src/lint/post-synth/waw026.ts +46 -0
  91. package/src/lint/post-synth/waw027.test.ts +63 -0
  92. package/src/lint/post-synth/waw027.ts +50 -0
  93. package/src/lint/post-synth/waw028.test.ts +68 -0
  94. package/src/lint/post-synth/waw028.ts +47 -0
  95. package/src/lint/post-synth/waw029.test.ts +179 -0
  96. package/src/lint/post-synth/waw029.ts +62 -0
  97. package/src/lint/post-synth/waw030.test.ts +800 -0
  98. package/src/lint/post-synth/waw030.ts +246 -0
  99. package/src/lint/rules/hardcoded-region.ts +1 -0
  100. package/src/lint/rules/iam-wildcard.ts +1 -0
  101. package/src/lint/rules/s3-encryption.ts +1 -0
  102. package/src/lsp/hover.ts +15 -0
  103. package/src/nested-stack-integration.test.ts +100 -0
  104. package/src/nested-stack.ts +1 -1
  105. package/src/plugin.ts +468 -36
  106. package/src/serializer.test.ts +330 -2
  107. package/src/serializer.ts +62 -1
  108. package/src/spec/fetch.ts +10 -0
  109. package/src/spec/parse.test.ts +141 -0
  110. package/src/spec/parse.ts +40 -0
  111. package/src/taggable.ts +44 -0
  112. package/src/testdata/nested-stacks/app.ts +26 -0
  113. package/src/testdata/nested-stacks/network/outputs.ts +17 -0
  114. package/src/testdata/nested-stacks/network/security.ts +17 -0
  115. package/src/testdata/nested-stacks/network/vpc.ts +54 -0
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Shared taggable resource lookup — loads from the generated lexicon JSON.
3
+ *
4
+ * Lazy-loaded and cached for the lifetime of the process.
5
+ */
6
+
7
+ import { readFileSync } from "fs";
8
+ import { join } from "path";
9
+
10
+ interface LexiconEntry {
11
+ kind: string;
12
+ resourceType: string;
13
+ tagging?: { taggable: boolean; tagOnCreate: boolean; tagUpdatable: boolean };
14
+ [key: string]: unknown;
15
+ }
16
+
17
+ let _cached: Set<string> | undefined;
18
+
19
+ /**
20
+ * Load taggable resource types from the lexicon JSON.
21
+ * Result is cached after first call.
22
+ */
23
+ export function loadTaggableResources(): Set<string> {
24
+ if (_cached) return _cached;
25
+
26
+ const set = new Set<string>();
27
+ try {
28
+ const pkgDir = join(__dirname, "..");
29
+ const lexiconPath = join(pkgDir, "src", "generated", "lexicon-aws.json");
30
+ const content = readFileSync(lexiconPath, "utf-8");
31
+ const data = JSON.parse(content) as Record<string, LexiconEntry>;
32
+
33
+ for (const [_name, entry] of Object.entries(data)) {
34
+ if (entry.kind === "resource" && entry.resourceType && entry.tagging?.taggable) {
35
+ set.add(entry.resourceType);
36
+ }
37
+ }
38
+ } catch {
39
+ // Lexicon not available — skip
40
+ }
41
+
42
+ _cached = set;
43
+ return set;
44
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * App layer — Lambda function in the parent template that references
3
+ * the network nested stack's outputs via cross-stack references
4
+ */
5
+
6
+ import { Function, Sub, AWS, Ref, nestedStack } from "@intentius/chant-lexicon-aws";
7
+
8
+ // nestedStack() references a child project directory
9
+ const network = nestedStack("network", import.meta.dirname + "/network", {
10
+ parameters: { Environment: "prod" },
11
+ });
12
+
13
+ export const handler = new Function({
14
+ FunctionName: Sub`${AWS.StackName}-handler`,
15
+ Runtime: "nodejs20.x",
16
+ Handler: "index.handler",
17
+ Role: Ref("LambdaExecutionRole"),
18
+ Code: { ZipFile: "exports.handler = async () => ({ statusCode: 200 });" },
19
+ VpcConfig: {
20
+ SubnetIds: [network.outputs.subnetId],
21
+ SecurityGroupIds: [network.outputs.lambdaSgId],
22
+ },
23
+ });
24
+
25
+ // Re-export so discovery picks it up as an entity
26
+ export { network };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Cross-stack outputs — values the parent can reference
3
+ */
4
+
5
+ import { stackOutput } from "@intentius/chant";
6
+ import { vpc, subnet } from "./vpc";
7
+ import { lambdaSg } from "./security";
8
+
9
+ export const vpcId = stackOutput(vpc.VpcId, {
10
+ description: "VPC ID",
11
+ });
12
+ export const subnetId = stackOutput(subnet.SubnetId, {
13
+ description: "Public subnet ID",
14
+ });
15
+ export const lambdaSgId = stackOutput(lambdaSg.GroupId, {
16
+ description: "Lambda security group ID",
17
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Security group for the Lambda function in the parent stack
3
+ */
4
+
5
+ import { SecurityGroup, Sub, AWS } from "@intentius/chant-lexicon-aws";
6
+ import { vpc } from "./vpc";
7
+
8
+ export const lambdaSg = new SecurityGroup({
9
+ GroupDescription: Sub`${AWS.StackName} Lambda security group`,
10
+ VpcId: vpc.VpcId,
11
+ SecurityGroupEgress: [{
12
+ IpProtocol: "-1",
13
+ CidrIp: "0.0.0.0/0",
14
+ Description: "Allow all outbound",
15
+ }],
16
+ Tags: [{ Key: "Name", Value: Sub`${AWS.StackName}-lambda-sg` }],
17
+ });
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Network resources — VPC, subnet, internet gateway, and routing
3
+ */
4
+
5
+ import {
6
+ Vpc,
7
+ Subnet,
8
+ InternetGateway,
9
+ VPCGatewayAttachment,
10
+ RouteTable,
11
+ EC2Route,
12
+ SubnetRouteTableAssociation,
13
+ Sub,
14
+ AWS,
15
+ } from "@intentius/chant-lexicon-aws";
16
+
17
+ export const vpc = new Vpc({
18
+ CidrBlock: "10.0.0.0/16",
19
+ EnableDnsSupport: true,
20
+ EnableDnsHostnames: true,
21
+ Tags: [{ Key: "Name", Value: Sub`${AWS.StackName}-vpc` }],
22
+ });
23
+
24
+ export const subnet = new Subnet({
25
+ VpcId: vpc.VpcId,
26
+ CidrBlock: "10.0.1.0/24",
27
+ MapPublicIpOnLaunch: true,
28
+ Tags: [{ Key: "Name", Value: Sub`${AWS.StackName}-public` }],
29
+ });
30
+
31
+ export const igw = new InternetGateway({
32
+ Tags: [{ Key: "Name", Value: Sub`${AWS.StackName}-igw` }],
33
+ });
34
+
35
+ export const igwAttachment = new VPCGatewayAttachment({
36
+ VpcId: vpc.VpcId,
37
+ InternetGatewayId: igw.InternetGatewayId,
38
+ });
39
+
40
+ export const routeTable = new RouteTable({
41
+ VpcId: vpc.VpcId,
42
+ Tags: [{ Key: "Name", Value: Sub`${AWS.StackName}-public-rt` }],
43
+ });
44
+
45
+ export const defaultRoute = new EC2Route({
46
+ RouteTableId: routeTable.RouteTableId,
47
+ DestinationCidrBlock: "0.0.0.0/0",
48
+ GatewayId: igw.InternetGatewayId,
49
+ });
50
+
51
+ export const subnetRouteTableAssoc = new SubnetRouteTableAssociation({
52
+ SubnetId: subnet.SubnetId,
53
+ RouteTableId: routeTable.RouteTableId,
54
+ });