@intentius/chant-lexicon-aws 0.0.2

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 (94) hide show
  1. package/README.md +438 -0
  2. package/package.json +30 -0
  3. package/src/codegen/__snapshots__/snapshot.test.ts.snap +197 -0
  4. package/src/codegen/docs-cli.ts +3 -0
  5. package/src/codegen/docs.ts +1206 -0
  6. package/src/codegen/extensions.ts +171 -0
  7. package/src/codegen/fallback.ts +33 -0
  8. package/src/codegen/generate-cli.ts +17 -0
  9. package/src/codegen/generate-lexicon.ts +98 -0
  10. package/src/codegen/generate-typescript.ts +257 -0
  11. package/src/codegen/generate.test.ts +125 -0
  12. package/src/codegen/generate.ts +226 -0
  13. package/src/codegen/idempotency.test.ts +28 -0
  14. package/src/codegen/naming.ts +120 -0
  15. package/src/codegen/package.test.ts +60 -0
  16. package/src/codegen/package.ts +84 -0
  17. package/src/codegen/patches.ts +98 -0
  18. package/src/codegen/rollback.test.ts +80 -0
  19. package/src/codegen/rollback.ts +20 -0
  20. package/src/codegen/sam.ts +387 -0
  21. package/src/codegen/snapshot.test.ts +84 -0
  22. package/src/codegen/typecheck.test.ts +50 -0
  23. package/src/codegen/typecheck.ts +4 -0
  24. package/src/codegen/versions.ts +37 -0
  25. package/src/coverage.ts +14 -0
  26. package/src/generated/index.d.ts +160753 -0
  27. package/src/generated/index.ts +14396 -0
  28. package/src/generated/lexicon-aws.json +114563 -0
  29. package/src/generated/runtime.ts +4 -0
  30. package/src/import/generator.test.ts +181 -0
  31. package/src/import/generator.ts +349 -0
  32. package/src/import/parser.test.ts +200 -0
  33. package/src/import/parser.ts +350 -0
  34. package/src/import/roundtrip-fixtures.test.ts +78 -0
  35. package/src/import/roundtrip.test.ts +195 -0
  36. package/src/index.ts +63 -0
  37. package/src/integration.test.ts +129 -0
  38. package/src/intrinsics.test.ts +167 -0
  39. package/src/intrinsics.ts +223 -0
  40. package/src/lint/post-synth/cf-refs.ts +91 -0
  41. package/src/lint/post-synth/cor020.ts +72 -0
  42. package/src/lint/post-synth/ext001.test.ts +68 -0
  43. package/src/lint/post-synth/ext001.ts +222 -0
  44. package/src/lint/post-synth/post-synth.test.ts +280 -0
  45. package/src/lint/post-synth/waw010.ts +49 -0
  46. package/src/lint/post-synth/waw011.ts +49 -0
  47. package/src/lint/post-synth/waw013.ts +45 -0
  48. package/src/lint/post-synth/waw014.ts +50 -0
  49. package/src/lint/post-synth/waw015.ts +100 -0
  50. package/src/lint/rules/hardcoded-region.ts +43 -0
  51. package/src/lint/rules/iam-wildcard.ts +66 -0
  52. package/src/lint/rules/index.ts +7 -0
  53. package/src/lint/rules/rules.test.ts +175 -0
  54. package/src/lint/rules/s3-encryption.ts +69 -0
  55. package/src/lsp/completions.test.ts +72 -0
  56. package/src/lsp/completions.ts +18 -0
  57. package/src/lsp/hover.test.ts +53 -0
  58. package/src/lsp/hover.ts +53 -0
  59. package/src/nested-stack.test.ts +83 -0
  60. package/src/nested-stack.ts +125 -0
  61. package/src/plugin.test.ts +316 -0
  62. package/src/plugin.ts +514 -0
  63. package/src/pseudo.test.ts +55 -0
  64. package/src/pseudo.ts +29 -0
  65. package/src/serializer.test.ts +507 -0
  66. package/src/serializer.ts +333 -0
  67. package/src/spec/fetch.test.ts +27 -0
  68. package/src/spec/fetch.ts +107 -0
  69. package/src/spec/parse.test.ts +153 -0
  70. package/src/spec/parse.ts +202 -0
  71. package/src/testdata/load-fixtures.ts +17 -0
  72. package/src/testdata/roundtrip/conditions.json +21 -0
  73. package/src/testdata/roundtrip/intrinsic-calls.json +31 -0
  74. package/src/testdata/roundtrip/intrinsics.json +18 -0
  75. package/src/testdata/roundtrip/multi-resource.json +37 -0
  76. package/src/testdata/roundtrip/parameters.json +23 -0
  77. package/src/testdata/roundtrip/simple.json +12 -0
  78. package/src/testdata/sam-fixtures/api.yaml +14 -0
  79. package/src/testdata/sam-fixtures/application.yaml +13 -0
  80. package/src/testdata/sam-fixtures/function.yaml +22 -0
  81. package/src/testdata/sam-fixtures/graphql-api.yaml +13 -0
  82. package/src/testdata/sam-fixtures/http-api.yaml +15 -0
  83. package/src/testdata/sam-fixtures/layer-version.yaml +15 -0
  84. package/src/testdata/sam-fixtures/multi-type-a.yaml +23 -0
  85. package/src/testdata/sam-fixtures/multi-type-b.yaml +29 -0
  86. package/src/testdata/sam-fixtures/simple-table.yaml +12 -0
  87. package/src/testdata/sam-fixtures/state-machine.yaml +14 -0
  88. package/src/testdata/schemas/aws-dynamodb-table.json +126 -0
  89. package/src/testdata/schemas/aws-iam-role.json +85 -0
  90. package/src/testdata/schemas/aws-lambda-function.json +90 -0
  91. package/src/testdata/schemas/aws-s3-bucket.json +83 -0
  92. package/src/testdata/schemas/aws-sns-topic.json +71 -0
  93. package/src/validate-cli.ts +19 -0
  94. package/src/validate.ts +34 -0
@@ -0,0 +1,202 @@
1
+ /**
2
+ * CloudFormation Registry JSON Schema parser.
3
+ *
4
+ * Parses each CFNSchema into typed structures suitable for code generation:
5
+ * resources with properties and attributes, property types from definitions,
6
+ * and enum types from string enum definitions.
7
+ */
8
+
9
+ import type { CFNSchema, SchemaProperty, SchemaDefinition } from "./fetch";
10
+ import {
11
+ resolvePropertyType as coreResolvePropertyType,
12
+ extractConstraints as coreExtractConstraints,
13
+ constraintsIsEmpty as coreConstraintsIsEmpty,
14
+ isEnumDefinition as coreIsEnumDefinition,
15
+ type PropertyConstraints,
16
+ type JsonSchemaDocument,
17
+ type JsonSchemaProperty,
18
+ type JsonSchemaDefinition,
19
+ } from "@intentius/chant/codegen/json-schema";
20
+
21
+ export type { PropertyConstraints } from "@intentius/chant/codegen/json-schema";
22
+
23
+ export interface ParsedProperty {
24
+ name: string;
25
+ tsType: string;
26
+ required: boolean;
27
+ description?: string;
28
+ enum?: string[];
29
+ constraints: PropertyConstraints;
30
+ }
31
+
32
+ export interface ParsedAttribute {
33
+ name: string;
34
+ tsType: string;
35
+ }
36
+
37
+ export interface ParsedPropertyType {
38
+ name: string;
39
+ cfnType: string;
40
+ properties: ParsedProperty[];
41
+ }
42
+
43
+ export interface ParsedEnum {
44
+ name: string;
45
+ values: string[];
46
+ }
47
+
48
+ export interface ParsedResource {
49
+ typeName: string;
50
+ properties: ParsedProperty[];
51
+ attributes: ParsedAttribute[];
52
+ createOnly: string[];
53
+ writeOnly: string[];
54
+ primaryIdentifier: string[];
55
+ }
56
+
57
+ export interface SchemaParseResult {
58
+ resource: ParsedResource;
59
+ propertyTypes: ParsedPropertyType[];
60
+ enums: ParsedEnum[];
61
+ }
62
+
63
+ /**
64
+ * Parse a CloudFormation Registry JSON Schema into typed structures.
65
+ */
66
+ export function parseCFNSchema(data: string | Buffer): SchemaParseResult {
67
+ const schema: CFNSchema = JSON.parse(typeof data === "string" ? data : data.toString("utf-8"));
68
+
69
+ const requiredSet = new Set<string>(schema.required ?? []);
70
+ const shortName = cfnShortName(schema.typeName);
71
+
72
+ // Parse top-level properties
73
+ const props: ParsedProperty[] = [];
74
+ if (schema.properties) {
75
+ for (const [name, prop] of Object.entries(schema.properties)) {
76
+ const tsType = resolvePropertyType(prop, schema);
77
+ props.push({
78
+ name,
79
+ tsType,
80
+ required: requiredSet.has(name),
81
+ description: prop.description,
82
+ enum: prop.enum,
83
+ constraints: extractConstraints(prop),
84
+ });
85
+ }
86
+ }
87
+
88
+ // Parse readOnlyProperties as attributes
89
+ const attrs: ParsedAttribute[] = [];
90
+ for (const path of schema.readOnlyProperties ?? []) {
91
+ const attrName = stripPointerPath(path);
92
+ // Skip nested paths (contain "/" after stripping prefix, or ".")
93
+ if (attrName.includes("/") || attrName.includes(".")) continue;
94
+
95
+ // Try to find type from properties, default to string
96
+ let tsType = "string";
97
+ if (schema.properties?.[attrName]) {
98
+ tsType = resolvePropertyType(schema.properties[attrName], schema);
99
+ }
100
+ attrs.push({ name: attrName, tsType });
101
+ }
102
+
103
+ // Parse definitions into property types and enums
104
+ const propertyTypes: ParsedPropertyType[] = [];
105
+ const enums: ParsedEnum[] = [];
106
+
107
+ if (schema.definitions) {
108
+ for (const [defName, def] of Object.entries(schema.definitions)) {
109
+ if (isEnumDefinition(def)) {
110
+ enums.push({
111
+ name: `${shortName}_${defName}`,
112
+ values: def.enum!,
113
+ });
114
+ continue;
115
+ }
116
+
117
+ if (def.properties) {
118
+ const defRequired = new Set<string>(def.required ?? []);
119
+ const defProps: ParsedProperty[] = [];
120
+ for (const [propName, prop] of Object.entries(def.properties)) {
121
+ const tsType = resolvePropertyType(prop, schema);
122
+ defProps.push({
123
+ name: propName,
124
+ tsType,
125
+ required: defRequired.has(propName),
126
+ description: prop.description,
127
+ enum: prop.enum,
128
+ constraints: extractConstraints(prop),
129
+ });
130
+ }
131
+ propertyTypes.push({
132
+ name: `${shortName}_${defName}`,
133
+ cfnType: defName,
134
+ properties: defProps,
135
+ });
136
+ }
137
+ }
138
+ }
139
+
140
+ return {
141
+ resource: {
142
+ typeName: schema.typeName,
143
+ properties: props,
144
+ attributes: attrs,
145
+ createOnly: stripPointerPaths(schema.createOnlyProperties ?? []),
146
+ writeOnly: stripPointerPaths(schema.writeOnlyProperties ?? []),
147
+ primaryIdentifier: stripPointerPaths(schema.primaryIdentifier ?? []),
148
+ },
149
+ propertyTypes,
150
+ enums,
151
+ };
152
+ }
153
+
154
+ // --- Type resolution (delegated to core) ---
155
+
156
+ function resolvePropertyType(prop: SchemaProperty | undefined, schema: CFNSchema): string {
157
+ const shortName = cfnShortName(schema.typeName);
158
+ return coreResolvePropertyType(
159
+ prop as JsonSchemaProperty | undefined,
160
+ schema as unknown as JsonSchemaDocument,
161
+ (defName) => `${shortName}_${defName}`,
162
+ );
163
+ }
164
+
165
+ function extractConstraints(prop: SchemaProperty): PropertyConstraints {
166
+ return coreExtractConstraints(prop as JsonSchemaProperty);
167
+ }
168
+
169
+ export const constraintsIsEmpty = coreConstraintsIsEmpty;
170
+
171
+ function isEnumDefinition(def: SchemaDefinition): boolean {
172
+ return coreIsEnumDefinition(def as JsonSchemaDefinition);
173
+ }
174
+
175
+ /**
176
+ * Extract short resource name: "AWS::S3::Bucket" → "Bucket"
177
+ */
178
+ export function cfnShortName(typeName: string): string {
179
+ const parts = typeName.split("::");
180
+ return parts.length >= 3 ? parts[2] : typeName;
181
+ }
182
+
183
+ /**
184
+ * Extract service name: "AWS::S3::Bucket" → "S3"
185
+ */
186
+ export function cfnServiceName(typeName: string): string {
187
+ const parts = typeName.split("::");
188
+ return parts.length >= 2 ? parts[1] : typeName;
189
+ }
190
+
191
+ /**
192
+ * Strip JSON pointer path prefix: "/properties/BucketName" → "BucketName"
193
+ */
194
+ function stripPointerPath(path: string): string {
195
+ const prefix = "/properties/";
196
+ return path.startsWith(prefix) ? path.slice(prefix.length) : path;
197
+ }
198
+
199
+ function stripPointerPaths(paths: string[]): string[] {
200
+ if (paths.length === 0) return [];
201
+ return paths.map(stripPointerPath);
202
+ }
@@ -0,0 +1,17 @@
1
+ import { readFileSync, readdirSync } from "fs";
2
+ import { join, dirname } from "path";
3
+ import { fileURLToPath } from "url";
4
+
5
+ export function loadSchemaFixtures(): Map<string, Buffer> {
6
+ const schemasDir = join(dirname(fileURLToPath(import.meta.url)), "schemas");
7
+ const schemas = new Map<string, Buffer>();
8
+ for (const file of readdirSync(schemasDir)) {
9
+ if (!file.endsWith(".json")) continue;
10
+ const data = readFileSync(join(schemasDir, file));
11
+ const parsed = JSON.parse(data.toString("utf-8"));
12
+ if (parsed.typeName) {
13
+ schemas.set(parsed.typeName, Buffer.from(data));
14
+ }
15
+ }
16
+ return schemas;
17
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Template with conditions",
4
+ "Parameters": {
5
+ "Environment": {
6
+ "Type": "String",
7
+ "Default": "dev"
8
+ }
9
+ },
10
+ "Conditions": {
11
+ "IsProd": { "Fn::Equals": [{ "Ref": "Environment" }, "prod"] }
12
+ },
13
+ "Resources": {
14
+ "MyBucket": {
15
+ "Type": "AWS::S3::Bucket",
16
+ "Properties": {
17
+ "BucketName": { "Fn::If": ["IsProd", "prod-bucket", "dev-bucket"] }
18
+ }
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Template with GetAtt and Ref intrinsic calls",
4
+ "Resources": {
5
+ "LambdaRole": {
6
+ "Type": "AWS::IAM::Role",
7
+ "Properties": {
8
+ "RoleName": "lambda-role",
9
+ "AssumeRolePolicyDocument": {
10
+ "Version": "2012-10-17",
11
+ "Statement": [
12
+ {
13
+ "Effect": "Allow",
14
+ "Principal": { "Service": "lambda.amazonaws.com" },
15
+ "Action": "sts:AssumeRole"
16
+ }
17
+ ]
18
+ }
19
+ }
20
+ },
21
+ "MyFunction": {
22
+ "Type": "AWS::Lambda::Function",
23
+ "Properties": {
24
+ "FunctionName": "my-function",
25
+ "Runtime": "nodejs18.x",
26
+ "Handler": "index.handler",
27
+ "Role": { "Fn::GetAtt": ["LambdaRole", "Arn"] }
28
+ }
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Template with intrinsic functions",
4
+ "Resources": {
5
+ "MyBucket": {
6
+ "Type": "AWS::S3::Bucket",
7
+ "Properties": {
8
+ "BucketName": { "Fn::Sub": "${AWS::StackName}-data" }
9
+ }
10
+ },
11
+ "MyQueue": {
12
+ "Type": "AWS::SQS::Queue",
13
+ "Properties": {
14
+ "QueueName": { "Fn::Join": ["-", ["my", "queue", { "Ref": "AWS::Region" }]] }
15
+ }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Template with multiple resource types",
4
+ "Resources": {
5
+ "MyBucket": {
6
+ "Type": "AWS::S3::Bucket",
7
+ "Properties": {
8
+ "BucketName": "my-bucket"
9
+ }
10
+ },
11
+ "MyQueue": {
12
+ "Type": "AWS::SQS::Queue",
13
+ "Properties": {
14
+ "QueueName": "my-queue"
15
+ }
16
+ },
17
+ "MyTopic": {
18
+ "Type": "AWS::SNS::Topic",
19
+ "Properties": {
20
+ "TopicName": "my-topic"
21
+ }
22
+ },
23
+ "MyTable": {
24
+ "Type": "AWS::DynamoDB::Table",
25
+ "Properties": {
26
+ "TableName": "my-table",
27
+ "AttributeDefinitions": [
28
+ { "AttributeName": "id", "AttributeType": "S" }
29
+ ],
30
+ "KeySchema": [
31
+ { "AttributeName": "id", "KeyType": "HASH" }
32
+ ],
33
+ "BillingMode": "PAY_PER_REQUEST"
34
+ }
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Template with parameters",
4
+ "Parameters": {
5
+ "Environment": {
6
+ "Type": "String",
7
+ "Default": "dev",
8
+ "Description": "Deployment environment"
9
+ },
10
+ "BucketPrefix": {
11
+ "Type": "String",
12
+ "Description": "Prefix for bucket name"
13
+ }
14
+ },
15
+ "Resources": {
16
+ "MyBucket": {
17
+ "Type": "AWS::S3::Bucket",
18
+ "Properties": {
19
+ "BucketName": { "Ref": "BucketPrefix" }
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Simple S3 bucket",
4
+ "Resources": {
5
+ "MyBucket": {
6
+ "Type": "AWS::S3::Bucket",
7
+ "Properties": {
8
+ "BucketName": "my-simple-bucket"
9
+ }
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,14 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: SAM Api Gateway
4
+
5
+ Resources:
6
+ MyApi:
7
+ Type: AWS::Serverless::Api
8
+ Properties:
9
+ StageName: prod
10
+ TracingEnabled: true
11
+ Cors:
12
+ AllowOrigin: "'*'"
13
+ AllowHeaders: "'Content-Type'"
14
+ AllowMethods: "'GET,POST'"
@@ -0,0 +1,13 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: SAM Application (nested stack)
4
+
5
+ Resources:
6
+ MyApp:
7
+ Type: AWS::Serverless::Application
8
+ Properties:
9
+ Location:
10
+ ApplicationId: arn:aws:serverlessrepo:us-east-1:123456789012:applications/my-app
11
+ SemanticVersion: 1.0.0
12
+ Parameters:
13
+ Stage: prod
@@ -0,0 +1,22 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: SAM Function
4
+
5
+ Resources:
6
+ MyFunction:
7
+ Type: AWS::Serverless::Function
8
+ Properties:
9
+ Handler: index.handler
10
+ Runtime: nodejs18.x
11
+ CodeUri: s3://bucket/code.zip
12
+ MemorySize: 256
13
+ Timeout: 30
14
+ Environment:
15
+ Variables:
16
+ TABLE_NAME: my-table
17
+ Events:
18
+ ApiEvent:
19
+ Type: Api
20
+ Properties:
21
+ Path: /hello
22
+ Method: get
@@ -0,0 +1,13 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: SAM GraphQL API
4
+
5
+ Resources:
6
+ MyGraphQLApi:
7
+ Type: AWS::Serverless::GraphQLApi
8
+ Properties:
9
+ Name: my-graphql-api
10
+ SchemaUri: schema.graphql
11
+ Auth:
12
+ Type: API_KEY
13
+ XrayEnabled: true
@@ -0,0 +1,15 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: SAM HTTP API
4
+
5
+ Resources:
6
+ MyHttpApi:
7
+ Type: AWS::Serverless::HttpApi
8
+ Properties:
9
+ StageName: prod
10
+ CorsConfiguration:
11
+ AllowOrigins:
12
+ - "https://example.com"
13
+ AllowMethods:
14
+ - GET
15
+ - POST
@@ -0,0 +1,15 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: SAM Layer Version
4
+
5
+ Resources:
6
+ MyLayer:
7
+ Type: AWS::Serverless::LayerVersion
8
+ Properties:
9
+ LayerName: my-layer
10
+ Description: Shared dependencies
11
+ ContentUri: s3://bucket/layer.zip
12
+ CompatibleRuntimes:
13
+ - nodejs18.x
14
+ - nodejs20.x
15
+ RetentionPolicy: Retain
@@ -0,0 +1,23 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: Multi-type SAM template A - Function with API
4
+
5
+ Resources:
6
+ MyApi:
7
+ Type: AWS::Serverless::Api
8
+ Properties:
9
+ StageName: prod
10
+
11
+ MyFunction:
12
+ Type: AWS::Serverless::Function
13
+ Properties:
14
+ Handler: index.handler
15
+ Runtime: nodejs18.x
16
+ CodeUri: s3://bucket/code.zip
17
+ Events:
18
+ GetItems:
19
+ Type: Api
20
+ Properties:
21
+ Path: /items
22
+ Method: get
23
+ RestApiId: !Ref MyApi
@@ -0,0 +1,29 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: Multi-type SAM template B - Function with Table and Layer
4
+
5
+ Resources:
6
+ SharedLayer:
7
+ Type: AWS::Serverless::LayerVersion
8
+ Properties:
9
+ LayerName: shared-deps
10
+ ContentUri: s3://bucket/layer.zip
11
+ CompatibleRuntimes:
12
+ - nodejs18.x
13
+
14
+ DataTable:
15
+ Type: AWS::Serverless::SimpleTable
16
+ Properties:
17
+ TableName: data-table
18
+
19
+ ProcessFunction:
20
+ Type: AWS::Serverless::Function
21
+ Properties:
22
+ Handler: index.handler
23
+ Runtime: nodejs18.x
24
+ CodeUri: s3://bucket/code.zip
25
+ Layers:
26
+ - !Ref SharedLayer
27
+ Environment:
28
+ Variables:
29
+ TABLE_NAME: !Ref DataTable
@@ -0,0 +1,12 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: SAM Simple Table
4
+
5
+ Resources:
6
+ MyTable:
7
+ Type: AWS::Serverless::SimpleTable
8
+ Properties:
9
+ TableName: my-table
10
+ PrimaryKey:
11
+ Name: id
12
+ Type: String
@@ -0,0 +1,14 @@
1
+ AWSTemplateFormatVersion: "2010-09-09"
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: SAM State Machine
4
+
5
+ Resources:
6
+ MyStateMachine:
7
+ Type: AWS::Serverless::StateMachine
8
+ Properties:
9
+ Name: my-state-machine
10
+ Type: STANDARD
11
+ DefinitionUri: statemachine/definition.asl.json
12
+ Policies:
13
+ - LambdaInvokePolicy:
14
+ FunctionName: my-function
@@ -0,0 +1,126 @@
1
+ {
2
+ "typeName": "AWS::DynamoDB::Table",
3
+ "description": "The AWS::DynamoDB::Table resource creates a DynamoDB table.",
4
+ "properties": {
5
+ "TableName": {
6
+ "type": "string",
7
+ "description": "A name for the table.",
8
+ "minLength": 3,
9
+ "maxLength": 255,
10
+ "pattern": "^[a-zA-Z0-9._-]+$"
11
+ },
12
+ "Arn": {
13
+ "type": "string",
14
+ "description": "The Amazon Resource Name (ARN) of the DynamoDB table."
15
+ },
16
+ "KeySchema": {
17
+ "type": "array",
18
+ "items": {
19
+ "$ref": "#/definitions/KeySchema"
20
+ },
21
+ "description": "Specifies the attributes that make up the primary key for the table."
22
+ },
23
+ "AttributeDefinitions": {
24
+ "type": "array",
25
+ "items": {
26
+ "$ref": "#/definitions/AttributeDefinition"
27
+ },
28
+ "description": "A list of attributes that describe the key schema for the table."
29
+ },
30
+ "BillingMode": {
31
+ "type": "string",
32
+ "description": "Specify how you are charged for read and write throughput.",
33
+ "enum": ["PROVISIONED", "PAY_PER_REQUEST"]
34
+ },
35
+ "SSESpecification": {
36
+ "$ref": "#/definitions/SSESpecification",
37
+ "description": "Specifies the settings to enable server-side encryption."
38
+ },
39
+ "Tags": {
40
+ "type": "array",
41
+ "items": {
42
+ "$ref": "#/definitions/Tag"
43
+ },
44
+ "description": "An array of key-value pairs to apply to this resource."
45
+ }
46
+ },
47
+ "definitions": {
48
+ "KeySchema": {
49
+ "type": "object",
50
+ "description": "Represents a single element of a key schema.",
51
+ "properties": {
52
+ "AttributeName": {
53
+ "type": "string",
54
+ "description": "The name of a key attribute.",
55
+ "minLength": 1,
56
+ "maxLength": 255
57
+ },
58
+ "KeyType": {
59
+ "type": "string",
60
+ "description": "The role that this key attribute will assume.",
61
+ "enum": ["HASH", "RANGE"]
62
+ }
63
+ },
64
+ "required": ["AttributeName", "KeyType"]
65
+ },
66
+ "AttributeDefinition": {
67
+ "type": "object",
68
+ "description": "Represents an attribute for describing the schema for the table.",
69
+ "properties": {
70
+ "AttributeName": {
71
+ "type": "string",
72
+ "description": "A name for the attribute.",
73
+ "minLength": 1,
74
+ "maxLength": 255
75
+ },
76
+ "AttributeType": {
77
+ "type": "string",
78
+ "description": "The data type for the attribute.",
79
+ "enum": ["S", "N", "B"]
80
+ }
81
+ },
82
+ "required": ["AttributeName", "AttributeType"]
83
+ },
84
+ "SSESpecification": {
85
+ "type": "object",
86
+ "description": "Represents the settings used to enable server-side encryption.",
87
+ "properties": {
88
+ "SSEEnabled": {
89
+ "type": "boolean",
90
+ "description": "Indicates whether server-side encryption is done using an AWS managed key or a customer managed key."
91
+ },
92
+ "SSEType": {
93
+ "type": "string",
94
+ "description": "Server-side encryption type.",
95
+ "enum": ["AES256", "KMS"]
96
+ },
97
+ "KMSMasterKeyId": {
98
+ "type": "string",
99
+ "description": "The KMS key that should be used for the KMS encryption."
100
+ }
101
+ },
102
+ "required": ["SSEEnabled"]
103
+ },
104
+ "Tag": {
105
+ "type": "object",
106
+ "description": "A key-value pair to associate with a resource.",
107
+ "properties": {
108
+ "Key": {
109
+ "type": "string",
110
+ "minLength": 1,
111
+ "maxLength": 128
112
+ },
113
+ "Value": {
114
+ "type": "string",
115
+ "maxLength": 256
116
+ }
117
+ },
118
+ "required": ["Key", "Value"]
119
+ }
120
+ },
121
+ "required": ["KeySchema", "AttributeDefinitions"],
122
+ "readOnlyProperties": ["/properties/Arn"],
123
+ "createOnlyProperties": ["/properties/TableName"],
124
+ "primaryIdentifier": ["/properties/TableName"],
125
+ "additionalProperties": false
126
+ }