@suss/contract-terraform 0.31.2 → 0.33.0
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.
- package/README.md +66 -4
- package/dist/index.cjs +876 -155
- package/dist/index.d.cts +199 -36
- package/dist/index.d.ts +199 -36
- package/dist/index.js +882 -156
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageBusTechnology, MetricValueShape, MetricAccumulation, BehavioralSummary } from '@suss/behavioral-ir';
|
|
1
|
+
import { DeployableUnit, MessageBusTechnology, MetricValueShape, MetricAccumulation, BehavioralSummary } from '@suss/behavioral-ir';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* What a pack says about the resources one Terraform provider declares.
|
|
@@ -13,11 +13,36 @@ import { MessageBusTechnology, MetricValueShape, MetricAccumulation, BehavioralS
|
|
|
13
13
|
* pack to ship code the reader cannot see into.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* An attribute whose value the pack translates into one of suss's own
|
|
18
|
+
* words. The reader takes the value at `attribute` and looks it up in
|
|
19
|
+
* `means`; a value the pack did not list says nothing, and so does one
|
|
20
|
+
* the configuration builds at deploy time.
|
|
21
|
+
*/
|
|
22
|
+
interface AttributeMeaning<T extends string> {
|
|
23
|
+
/** The attribute path whose value says which one it is. */
|
|
24
|
+
attribute: string;
|
|
25
|
+
/** What each value the provider can write there means. */
|
|
26
|
+
means: Record<string, T>;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a value has to equal a key of `means` or start with one.
|
|
29
|
+
* Cloud SQL writes an engine and a release together, `POSTGRES_15`,
|
|
30
|
+
* and the releases change every quarter, so a pack lists the prefix.
|
|
31
|
+
*/
|
|
32
|
+
matches?: "value" | "prefix";
|
|
33
|
+
/** What the resource means when it never set the attribute at all. */
|
|
34
|
+
whenUnset?: T;
|
|
35
|
+
}
|
|
16
36
|
/** A store a caller addresses by container and key. */
|
|
17
37
|
interface StorageResource {
|
|
18
38
|
kind: "storage";
|
|
19
|
-
/**
|
|
20
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Which store this is: dynamodb, s3. A resource that runs whichever
|
|
41
|
+
* engine one of its attributes picks says which attribute instead,
|
|
42
|
+
* and a value the pack does not list leaves the store with no engine
|
|
43
|
+
* on it rather than dropping the resource.
|
|
44
|
+
*/
|
|
45
|
+
storageSystem: string | AttributeMeaning<string>;
|
|
21
46
|
/** How a caller reaches it, when that is not the store's own name. */
|
|
22
47
|
transport?: string;
|
|
23
48
|
/**
|
|
@@ -33,6 +58,12 @@ interface StorageResource {
|
|
|
33
58
|
declares?: "container" | "store";
|
|
34
59
|
/** The attribute that says what the resource is called once deployed. */
|
|
35
60
|
nameAttribute?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The attribute naming the namespace a container belongs to. A
|
|
63
|
+
* BigQuery table is always addressed through its dataset, so two
|
|
64
|
+
* tables called `orders` in two datasets are two containers.
|
|
65
|
+
*/
|
|
66
|
+
scopeAttribute?: string;
|
|
36
67
|
/** Whether the fields it declares are every field an item has. */
|
|
37
68
|
fieldSet: "exhaustive" | "partial" | "none";
|
|
38
69
|
/** The attributes that state what identifies an item, in key order. */
|
|
@@ -45,6 +76,24 @@ interface StorageResource {
|
|
|
45
76
|
nameAttribute: string;
|
|
46
77
|
typeAttribute: string;
|
|
47
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* An attribute stating every field as JSON, one object per field. A
|
|
81
|
+
* schema written this way is every field the item has, so reading one
|
|
82
|
+
* makes the contract exhaustive whatever `fieldSet` says.
|
|
83
|
+
*/
|
|
84
|
+
fieldsFromJson?: {
|
|
85
|
+
/** The attribute whose value is a JSON list of field objects. */
|
|
86
|
+
attribute: string;
|
|
87
|
+
/** The key of one entry that says what the field is called. */
|
|
88
|
+
nameKey: string;
|
|
89
|
+
/** The key of one entry that gives the field its type. */
|
|
90
|
+
typeKey?: string;
|
|
91
|
+
/** The key that says a field is always set, and the values that do. */
|
|
92
|
+
requires?: {
|
|
93
|
+
key: string;
|
|
94
|
+
values: string[];
|
|
95
|
+
};
|
|
96
|
+
};
|
|
48
97
|
/**
|
|
49
98
|
* How another way in says what it can serve. A DynamoDB index copies
|
|
50
99
|
* some of an item rather than all of it, and a reader asking for
|
|
@@ -67,35 +116,42 @@ interface MessageBusResource {
|
|
|
67
116
|
nameAttribute?: string;
|
|
68
117
|
}
|
|
69
118
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
119
|
+
* How the deployed metric type is spelled, with each `{...}` standing
|
|
120
|
+
* for the value at that attribute. A CloudWatch metric is identified by
|
|
121
|
+
* its namespace and its name together, so a template says where both
|
|
122
|
+
* come from: `"{metric_transformation.namespace}/{metric_transformation.name}"`.
|
|
123
|
+
* A hole the resource leaves unset makes the whole identity unknown, so
|
|
124
|
+
* the summary pairs with nothing rather than with a half-spelled name.
|
|
74
125
|
*/
|
|
75
|
-
|
|
76
|
-
/** The attribute path whose value says which one it is. */
|
|
77
|
-
attribute: string;
|
|
78
|
-
/** What each value the provider can write there means. */
|
|
79
|
-
means: Record<string, T>;
|
|
80
|
-
}
|
|
126
|
+
type MetricTypeTemplate = string;
|
|
81
127
|
/** A named series of measurements a resource declares. */
|
|
82
128
|
interface MetricResource {
|
|
83
129
|
kind: "metric";
|
|
84
130
|
/** Which system the series lives in: cloud-monitoring. */
|
|
85
131
|
metricSystem: string;
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* How the deployed metric type is spelled, with `{name}` standing
|
|
90
|
-
* for the declared name. That string is what a resource reading the
|
|
91
|
-
* metric spells, so it is the identity the two sides share.
|
|
92
|
-
*/
|
|
93
|
-
metricTypeTemplate: string;
|
|
132
|
+
/** How the string both sides spell is built from the resource. */
|
|
133
|
+
metricTypeTemplate: MetricTypeTemplate;
|
|
94
134
|
/** Which attribute says whether one measurement is a number or a histogram. */
|
|
95
135
|
values?: AttributeMeaning<MetricValueShape>;
|
|
96
136
|
/** Which attribute says what a measurement covers. */
|
|
97
137
|
accumulates?: AttributeMeaning<MetricAccumulation>;
|
|
98
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* How a reading says which metric it is about. A CloudWatch alarm
|
|
141
|
+
* writes the namespace and the name in attributes of its own; a Cloud
|
|
142
|
+
* Monitoring condition states a query, and the metric is one value
|
|
143
|
+
* inside it.
|
|
144
|
+
*/
|
|
145
|
+
type MetricIdentity = {
|
|
146
|
+
from: "attributes";
|
|
147
|
+
template: MetricTypeTemplate;
|
|
148
|
+
} | {
|
|
149
|
+
from: "query";
|
|
150
|
+
/** The attribute whose query says which metric this is about. */
|
|
151
|
+
attribute: string;
|
|
152
|
+
/** The key inside that query whose value is the metric's type. */
|
|
153
|
+
key: string;
|
|
154
|
+
};
|
|
99
155
|
/**
|
|
100
156
|
* A resource that reads a metric another resource declares. One
|
|
101
157
|
* resource usually states several readings, each in its own block and
|
|
@@ -104,12 +160,13 @@ interface MetricResource {
|
|
|
104
160
|
interface MetricReadingResource {
|
|
105
161
|
kind: "metric-reading";
|
|
106
162
|
metricSystem: string;
|
|
107
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* The blocks one reading is written inside, outermost first. An empty
|
|
165
|
+
* list means the resource is itself one reading.
|
|
166
|
+
*/
|
|
108
167
|
readingBlocks: string[];
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
/** The key inside that query whose value is the metric's type. */
|
|
112
|
-
queryIdentityKey: string;
|
|
168
|
+
/** How the reading spells the metric it is about. */
|
|
169
|
+
identifies: MetricIdentity;
|
|
113
170
|
/**
|
|
114
171
|
* The attribute whose presence means the reading compares the series
|
|
115
172
|
* against a value of this shape. A condition states a threshold, so
|
|
@@ -122,23 +179,98 @@ interface MetricReadingResource {
|
|
|
122
179
|
/** Which attribute says what the reading reduces each window to first. */
|
|
123
180
|
reducesTo?: AttributeMeaning<MetricValueShape>;
|
|
124
181
|
}
|
|
125
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Where a provider writes one process's environment. A map attribute
|
|
184
|
+
* gives the names as its keys; repeated entries each say what one
|
|
185
|
+
* variable is called and then what supplies it, a literal or a secret.
|
|
186
|
+
*/
|
|
187
|
+
type EnvDeclaration = {
|
|
188
|
+
style: "map";
|
|
189
|
+
attribute: string;
|
|
190
|
+
} | {
|
|
191
|
+
style: "entries";
|
|
192
|
+
/** The block one entry is written as, as a dotted path. */
|
|
193
|
+
block: string;
|
|
194
|
+
/** The attribute stating what the variable is called. */
|
|
195
|
+
nameAttribute: string;
|
|
196
|
+
/** The attribute stating the value, for an entry that writes one. */
|
|
197
|
+
valueAttribute?: string;
|
|
198
|
+
/** The attribute stating which secret supplies the value. */
|
|
199
|
+
secretAttribute?: string;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* How a platform spells the string that says which code it calls.
|
|
203
|
+
* `"module.export"` is a module path and an exported name split at the
|
|
204
|
+
* last dot, which is what Lambda takes. `"name"` is an exported name on
|
|
205
|
+
* its own, which says nothing about which file it is in.
|
|
206
|
+
*/
|
|
207
|
+
type HandlerSpelling = "module.export" | "name";
|
|
208
|
+
/** What the provider says one process runs. */
|
|
209
|
+
interface DeployableCode {
|
|
210
|
+
/** The attribute that says which function the platform calls. */
|
|
211
|
+
handler?: {
|
|
212
|
+
attribute: string;
|
|
213
|
+
spelling: HandlerSpelling;
|
|
214
|
+
};
|
|
215
|
+
/** The attribute that says which image a container runs. */
|
|
216
|
+
imageAttribute?: string;
|
|
217
|
+
}
|
|
218
|
+
/** A resource that deploys several processes, each with its own environment. */
|
|
219
|
+
interface DeployableContainers {
|
|
220
|
+
/** The blocks one container is written inside, outermost first. */
|
|
221
|
+
blocks: string[];
|
|
222
|
+
/** The attribute inside a container that says what it is called. */
|
|
223
|
+
nameAttribute?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Something that gets deployed and runs: a function, a container, a
|
|
227
|
+
* job. What it declares is the environment the process starts with, so
|
|
228
|
+
* code reading a variable the deployment never sets is a defect either
|
|
229
|
+
* side can be shown.
|
|
230
|
+
*
|
|
231
|
+
* The unit is the resource's label rather than the name it deploys
|
|
232
|
+
* under. The label is what the rest of the configuration refers to it
|
|
233
|
+
* as, the way a logical id is in CloudFormation, and it is what a
|
|
234
|
+
* variable pointing at the resource resolves to.
|
|
235
|
+
*/
|
|
236
|
+
interface DeployableResource {
|
|
237
|
+
kind: "deployable";
|
|
238
|
+
/** Which medium runs it, in the words a deployable unit is keyed by. */
|
|
239
|
+
deploymentTarget: DeployableUnit["deploymentTarget"];
|
|
240
|
+
/** Where each process is written, for a resource that deploys several. */
|
|
241
|
+
containers?: DeployableContainers;
|
|
242
|
+
/** Where the environment is written, inside the process. */
|
|
243
|
+
env?: EnvDeclaration[];
|
|
244
|
+
/** What the provider says the process runs. */
|
|
245
|
+
code?: DeployableCode;
|
|
246
|
+
/** The attribute stating the language runtime, verbatim. */
|
|
247
|
+
runtimeAttribute?: string;
|
|
248
|
+
/**
|
|
249
|
+
* Names the platform sets whatever the configuration says. An entry
|
|
250
|
+
* that states none takes the list for its deployment target, which
|
|
251
|
+
* is the one every other reader of that target uses. A product with
|
|
252
|
+
* a list of its own, Cloud Run against a bare container, states it.
|
|
253
|
+
*/
|
|
254
|
+
platformEnvVars?: readonly string[];
|
|
255
|
+
}
|
|
256
|
+
type TerraformResource = StorageResource | MessageBusResource | MetricResource | MetricReadingResource | DeployableResource;
|
|
126
257
|
/** One resource type, as one version range of one provider declares it. */
|
|
127
258
|
interface TerraformResourcePattern {
|
|
128
259
|
/** The resource type, spelled the way the provider spells it. */
|
|
129
260
|
resource: string;
|
|
130
261
|
/**
|
|
131
262
|
* An attribute that decides whether the entry describes the resource
|
|
132
|
-
* at all.
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
263
|
+
* at all. A Firestore database in Datastore mode speaks a different
|
|
264
|
+
* API, so it is not the store the Firestore entry describes. A value
|
|
265
|
+
* outside `equals`, or one built at deploy time, means the resource
|
|
266
|
+
* is not read, rather than read as something it may not be.
|
|
267
|
+
* `whenUnset` says what an absent attribute means; the default is not
|
|
268
|
+
* to read the resource.
|
|
138
269
|
*/
|
|
139
270
|
appliesWhen?: {
|
|
140
271
|
attribute: string;
|
|
141
|
-
|
|
272
|
+
/** The values that mean the entry describes this resource. */
|
|
273
|
+
equals?: string[];
|
|
142
274
|
whenUnset?: "read" | "skip";
|
|
143
275
|
};
|
|
144
276
|
/**
|
|
@@ -221,6 +353,26 @@ declare function filterCalls(query: FilterQuery): FilterCall[];
|
|
|
221
353
|
/** Read one filter string, or say what stopped the reading. */
|
|
222
354
|
declare function parseFilterQuery(source: string): FilterParse;
|
|
223
355
|
|
|
356
|
+
/**
|
|
357
|
+
* An attribute whose value is JSON.
|
|
358
|
+
*
|
|
359
|
+
* Several providers take a structure as a string rather than as blocks:
|
|
360
|
+
* a BigQuery table's schema, an ECS task's container definitions, an
|
|
361
|
+
* IAM policy document. Terraform gives an author two ways to write one,
|
|
362
|
+
* a literal string (usually a heredoc) and `jsonencode` over an HCL
|
|
363
|
+
* value, and the two arrive at this reader looking nothing alike. This
|
|
364
|
+
* turns both into the value the provider will see.
|
|
365
|
+
*
|
|
366
|
+
* A schema a file or a variable supplies is not written down anywhere
|
|
367
|
+
* this can read, so it comes back as null and the caller records
|
|
368
|
+
* nothing rather than guessing.
|
|
369
|
+
*/
|
|
370
|
+
/**
|
|
371
|
+
* The value an attribute states as JSON, or null when the attribute is
|
|
372
|
+
* missing or states something only a deploy can settle.
|
|
373
|
+
*/
|
|
374
|
+
declare function jsonAttributeValue(value: unknown): unknown;
|
|
375
|
+
|
|
224
376
|
/**
|
|
225
377
|
* The boundaries a Terraform configuration declares.
|
|
226
378
|
*
|
|
@@ -240,10 +392,21 @@ declare function parseFilterQuery(source: string): FilterParse;
|
|
|
240
392
|
interface TerraformReadOptions {
|
|
241
393
|
/** The packs that say what this configuration's resources are. */
|
|
242
394
|
packs: TerraformPack[];
|
|
395
|
+
/**
|
|
396
|
+
* The directory each deployable unit's code is in, by the instance
|
|
397
|
+
* name the unit is keyed by. A configuration says which handler runs
|
|
398
|
+
* and never which directory the artifact was built from, so a
|
|
399
|
+
* container whose image is built elsewhere has no code at all until
|
|
400
|
+
* somebody says where it is.
|
|
401
|
+
*/
|
|
402
|
+
codeScopes?: Record<string, string>;
|
|
243
403
|
}
|
|
244
404
|
/** Every boundary one Terraform configuration declares. */
|
|
245
405
|
declare function terraformToSummaries(source: string, sourceFile: string, options: TerraformReadOptions): BehavioralSummary[];
|
|
246
|
-
/**
|
|
406
|
+
/**
|
|
407
|
+
* Read one `.tf` file, or every one directly inside a directory, and
|
|
408
|
+
* every local module the configuration calls.
|
|
409
|
+
*/
|
|
247
410
|
declare function terraformFileToSummaries(target: string, options: TerraformReadOptions): BehavioralSummary[];
|
|
248
411
|
|
|
249
|
-
export { type AttributeMeaning, type FilterCall, type FilterParse, type FilterQuery, type FilterTerm, type MessageBusResource, type MetricReadingResource, type MetricResource, type StorageResource, type TerraformPack, type TerraformReadOptions, type TerraformResource, type TerraformResourcePattern, filterCalls, filterTerms, filterValuesFor, parseFilterQuery, terraformFileToSummaries, terraformToSummaries };
|
|
412
|
+
export { type AttributeMeaning, type DeployableCode, type DeployableContainers, type DeployableResource, type EnvDeclaration, type FilterCall, type FilterParse, type FilterQuery, type FilterTerm, type HandlerSpelling, type MessageBusResource, type MetricIdentity, type MetricReadingResource, type MetricResource, type MetricTypeTemplate, type StorageResource, type TerraformPack, type TerraformReadOptions, type TerraformResource, type TerraformResourcePattern, filterCalls, filterTerms, filterValuesFor, jsonAttributeValue, parseFilterQuery, terraformFileToSummaries, terraformToSummaries };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageBusTechnology, MetricValueShape, MetricAccumulation, BehavioralSummary } from '@suss/behavioral-ir';
|
|
1
|
+
import { DeployableUnit, MessageBusTechnology, MetricValueShape, MetricAccumulation, BehavioralSummary } from '@suss/behavioral-ir';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* What a pack says about the resources one Terraform provider declares.
|
|
@@ -13,11 +13,36 @@ import { MessageBusTechnology, MetricValueShape, MetricAccumulation, BehavioralS
|
|
|
13
13
|
* pack to ship code the reader cannot see into.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* An attribute whose value the pack translates into one of suss's own
|
|
18
|
+
* words. The reader takes the value at `attribute` and looks it up in
|
|
19
|
+
* `means`; a value the pack did not list says nothing, and so does one
|
|
20
|
+
* the configuration builds at deploy time.
|
|
21
|
+
*/
|
|
22
|
+
interface AttributeMeaning<T extends string> {
|
|
23
|
+
/** The attribute path whose value says which one it is. */
|
|
24
|
+
attribute: string;
|
|
25
|
+
/** What each value the provider can write there means. */
|
|
26
|
+
means: Record<string, T>;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a value has to equal a key of `means` or start with one.
|
|
29
|
+
* Cloud SQL writes an engine and a release together, `POSTGRES_15`,
|
|
30
|
+
* and the releases change every quarter, so a pack lists the prefix.
|
|
31
|
+
*/
|
|
32
|
+
matches?: "value" | "prefix";
|
|
33
|
+
/** What the resource means when it never set the attribute at all. */
|
|
34
|
+
whenUnset?: T;
|
|
35
|
+
}
|
|
16
36
|
/** A store a caller addresses by container and key. */
|
|
17
37
|
interface StorageResource {
|
|
18
38
|
kind: "storage";
|
|
19
|
-
/**
|
|
20
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Which store this is: dynamodb, s3. A resource that runs whichever
|
|
41
|
+
* engine one of its attributes picks says which attribute instead,
|
|
42
|
+
* and a value the pack does not list leaves the store with no engine
|
|
43
|
+
* on it rather than dropping the resource.
|
|
44
|
+
*/
|
|
45
|
+
storageSystem: string | AttributeMeaning<string>;
|
|
21
46
|
/** How a caller reaches it, when that is not the store's own name. */
|
|
22
47
|
transport?: string;
|
|
23
48
|
/**
|
|
@@ -33,6 +58,12 @@ interface StorageResource {
|
|
|
33
58
|
declares?: "container" | "store";
|
|
34
59
|
/** The attribute that says what the resource is called once deployed. */
|
|
35
60
|
nameAttribute?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The attribute naming the namespace a container belongs to. A
|
|
63
|
+
* BigQuery table is always addressed through its dataset, so two
|
|
64
|
+
* tables called `orders` in two datasets are two containers.
|
|
65
|
+
*/
|
|
66
|
+
scopeAttribute?: string;
|
|
36
67
|
/** Whether the fields it declares are every field an item has. */
|
|
37
68
|
fieldSet: "exhaustive" | "partial" | "none";
|
|
38
69
|
/** The attributes that state what identifies an item, in key order. */
|
|
@@ -45,6 +76,24 @@ interface StorageResource {
|
|
|
45
76
|
nameAttribute: string;
|
|
46
77
|
typeAttribute: string;
|
|
47
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* An attribute stating every field as JSON, one object per field. A
|
|
81
|
+
* schema written this way is every field the item has, so reading one
|
|
82
|
+
* makes the contract exhaustive whatever `fieldSet` says.
|
|
83
|
+
*/
|
|
84
|
+
fieldsFromJson?: {
|
|
85
|
+
/** The attribute whose value is a JSON list of field objects. */
|
|
86
|
+
attribute: string;
|
|
87
|
+
/** The key of one entry that says what the field is called. */
|
|
88
|
+
nameKey: string;
|
|
89
|
+
/** The key of one entry that gives the field its type. */
|
|
90
|
+
typeKey?: string;
|
|
91
|
+
/** The key that says a field is always set, and the values that do. */
|
|
92
|
+
requires?: {
|
|
93
|
+
key: string;
|
|
94
|
+
values: string[];
|
|
95
|
+
};
|
|
96
|
+
};
|
|
48
97
|
/**
|
|
49
98
|
* How another way in says what it can serve. A DynamoDB index copies
|
|
50
99
|
* some of an item rather than all of it, and a reader asking for
|
|
@@ -67,35 +116,42 @@ interface MessageBusResource {
|
|
|
67
116
|
nameAttribute?: string;
|
|
68
117
|
}
|
|
69
118
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
119
|
+
* How the deployed metric type is spelled, with each `{...}` standing
|
|
120
|
+
* for the value at that attribute. A CloudWatch metric is identified by
|
|
121
|
+
* its namespace and its name together, so a template says where both
|
|
122
|
+
* come from: `"{metric_transformation.namespace}/{metric_transformation.name}"`.
|
|
123
|
+
* A hole the resource leaves unset makes the whole identity unknown, so
|
|
124
|
+
* the summary pairs with nothing rather than with a half-spelled name.
|
|
74
125
|
*/
|
|
75
|
-
|
|
76
|
-
/** The attribute path whose value says which one it is. */
|
|
77
|
-
attribute: string;
|
|
78
|
-
/** What each value the provider can write there means. */
|
|
79
|
-
means: Record<string, T>;
|
|
80
|
-
}
|
|
126
|
+
type MetricTypeTemplate = string;
|
|
81
127
|
/** A named series of measurements a resource declares. */
|
|
82
128
|
interface MetricResource {
|
|
83
129
|
kind: "metric";
|
|
84
130
|
/** Which system the series lives in: cloud-monitoring. */
|
|
85
131
|
metricSystem: string;
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* How the deployed metric type is spelled, with `{name}` standing
|
|
90
|
-
* for the declared name. That string is what a resource reading the
|
|
91
|
-
* metric spells, so it is the identity the two sides share.
|
|
92
|
-
*/
|
|
93
|
-
metricTypeTemplate: string;
|
|
132
|
+
/** How the string both sides spell is built from the resource. */
|
|
133
|
+
metricTypeTemplate: MetricTypeTemplate;
|
|
94
134
|
/** Which attribute says whether one measurement is a number or a histogram. */
|
|
95
135
|
values?: AttributeMeaning<MetricValueShape>;
|
|
96
136
|
/** Which attribute says what a measurement covers. */
|
|
97
137
|
accumulates?: AttributeMeaning<MetricAccumulation>;
|
|
98
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* How a reading says which metric it is about. A CloudWatch alarm
|
|
141
|
+
* writes the namespace and the name in attributes of its own; a Cloud
|
|
142
|
+
* Monitoring condition states a query, and the metric is one value
|
|
143
|
+
* inside it.
|
|
144
|
+
*/
|
|
145
|
+
type MetricIdentity = {
|
|
146
|
+
from: "attributes";
|
|
147
|
+
template: MetricTypeTemplate;
|
|
148
|
+
} | {
|
|
149
|
+
from: "query";
|
|
150
|
+
/** The attribute whose query says which metric this is about. */
|
|
151
|
+
attribute: string;
|
|
152
|
+
/** The key inside that query whose value is the metric's type. */
|
|
153
|
+
key: string;
|
|
154
|
+
};
|
|
99
155
|
/**
|
|
100
156
|
* A resource that reads a metric another resource declares. One
|
|
101
157
|
* resource usually states several readings, each in its own block and
|
|
@@ -104,12 +160,13 @@ interface MetricResource {
|
|
|
104
160
|
interface MetricReadingResource {
|
|
105
161
|
kind: "metric-reading";
|
|
106
162
|
metricSystem: string;
|
|
107
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* The blocks one reading is written inside, outermost first. An empty
|
|
165
|
+
* list means the resource is itself one reading.
|
|
166
|
+
*/
|
|
108
167
|
readingBlocks: string[];
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
/** The key inside that query whose value is the metric's type. */
|
|
112
|
-
queryIdentityKey: string;
|
|
168
|
+
/** How the reading spells the metric it is about. */
|
|
169
|
+
identifies: MetricIdentity;
|
|
113
170
|
/**
|
|
114
171
|
* The attribute whose presence means the reading compares the series
|
|
115
172
|
* against a value of this shape. A condition states a threshold, so
|
|
@@ -122,23 +179,98 @@ interface MetricReadingResource {
|
|
|
122
179
|
/** Which attribute says what the reading reduces each window to first. */
|
|
123
180
|
reducesTo?: AttributeMeaning<MetricValueShape>;
|
|
124
181
|
}
|
|
125
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Where a provider writes one process's environment. A map attribute
|
|
184
|
+
* gives the names as its keys; repeated entries each say what one
|
|
185
|
+
* variable is called and then what supplies it, a literal or a secret.
|
|
186
|
+
*/
|
|
187
|
+
type EnvDeclaration = {
|
|
188
|
+
style: "map";
|
|
189
|
+
attribute: string;
|
|
190
|
+
} | {
|
|
191
|
+
style: "entries";
|
|
192
|
+
/** The block one entry is written as, as a dotted path. */
|
|
193
|
+
block: string;
|
|
194
|
+
/** The attribute stating what the variable is called. */
|
|
195
|
+
nameAttribute: string;
|
|
196
|
+
/** The attribute stating the value, for an entry that writes one. */
|
|
197
|
+
valueAttribute?: string;
|
|
198
|
+
/** The attribute stating which secret supplies the value. */
|
|
199
|
+
secretAttribute?: string;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* How a platform spells the string that says which code it calls.
|
|
203
|
+
* `"module.export"` is a module path and an exported name split at the
|
|
204
|
+
* last dot, which is what Lambda takes. `"name"` is an exported name on
|
|
205
|
+
* its own, which says nothing about which file it is in.
|
|
206
|
+
*/
|
|
207
|
+
type HandlerSpelling = "module.export" | "name";
|
|
208
|
+
/** What the provider says one process runs. */
|
|
209
|
+
interface DeployableCode {
|
|
210
|
+
/** The attribute that says which function the platform calls. */
|
|
211
|
+
handler?: {
|
|
212
|
+
attribute: string;
|
|
213
|
+
spelling: HandlerSpelling;
|
|
214
|
+
};
|
|
215
|
+
/** The attribute that says which image a container runs. */
|
|
216
|
+
imageAttribute?: string;
|
|
217
|
+
}
|
|
218
|
+
/** A resource that deploys several processes, each with its own environment. */
|
|
219
|
+
interface DeployableContainers {
|
|
220
|
+
/** The blocks one container is written inside, outermost first. */
|
|
221
|
+
blocks: string[];
|
|
222
|
+
/** The attribute inside a container that says what it is called. */
|
|
223
|
+
nameAttribute?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Something that gets deployed and runs: a function, a container, a
|
|
227
|
+
* job. What it declares is the environment the process starts with, so
|
|
228
|
+
* code reading a variable the deployment never sets is a defect either
|
|
229
|
+
* side can be shown.
|
|
230
|
+
*
|
|
231
|
+
* The unit is the resource's label rather than the name it deploys
|
|
232
|
+
* under. The label is what the rest of the configuration refers to it
|
|
233
|
+
* as, the way a logical id is in CloudFormation, and it is what a
|
|
234
|
+
* variable pointing at the resource resolves to.
|
|
235
|
+
*/
|
|
236
|
+
interface DeployableResource {
|
|
237
|
+
kind: "deployable";
|
|
238
|
+
/** Which medium runs it, in the words a deployable unit is keyed by. */
|
|
239
|
+
deploymentTarget: DeployableUnit["deploymentTarget"];
|
|
240
|
+
/** Where each process is written, for a resource that deploys several. */
|
|
241
|
+
containers?: DeployableContainers;
|
|
242
|
+
/** Where the environment is written, inside the process. */
|
|
243
|
+
env?: EnvDeclaration[];
|
|
244
|
+
/** What the provider says the process runs. */
|
|
245
|
+
code?: DeployableCode;
|
|
246
|
+
/** The attribute stating the language runtime, verbatim. */
|
|
247
|
+
runtimeAttribute?: string;
|
|
248
|
+
/**
|
|
249
|
+
* Names the platform sets whatever the configuration says. An entry
|
|
250
|
+
* that states none takes the list for its deployment target, which
|
|
251
|
+
* is the one every other reader of that target uses. A product with
|
|
252
|
+
* a list of its own, Cloud Run against a bare container, states it.
|
|
253
|
+
*/
|
|
254
|
+
platformEnvVars?: readonly string[];
|
|
255
|
+
}
|
|
256
|
+
type TerraformResource = StorageResource | MessageBusResource | MetricResource | MetricReadingResource | DeployableResource;
|
|
126
257
|
/** One resource type, as one version range of one provider declares it. */
|
|
127
258
|
interface TerraformResourcePattern {
|
|
128
259
|
/** The resource type, spelled the way the provider spells it. */
|
|
129
260
|
resource: string;
|
|
130
261
|
/**
|
|
131
262
|
* An attribute that decides whether the entry describes the resource
|
|
132
|
-
* at all.
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
263
|
+
* at all. A Firestore database in Datastore mode speaks a different
|
|
264
|
+
* API, so it is not the store the Firestore entry describes. A value
|
|
265
|
+
* outside `equals`, or one built at deploy time, means the resource
|
|
266
|
+
* is not read, rather than read as something it may not be.
|
|
267
|
+
* `whenUnset` says what an absent attribute means; the default is not
|
|
268
|
+
* to read the resource.
|
|
138
269
|
*/
|
|
139
270
|
appliesWhen?: {
|
|
140
271
|
attribute: string;
|
|
141
|
-
|
|
272
|
+
/** The values that mean the entry describes this resource. */
|
|
273
|
+
equals?: string[];
|
|
142
274
|
whenUnset?: "read" | "skip";
|
|
143
275
|
};
|
|
144
276
|
/**
|
|
@@ -221,6 +353,26 @@ declare function filterCalls(query: FilterQuery): FilterCall[];
|
|
|
221
353
|
/** Read one filter string, or say what stopped the reading. */
|
|
222
354
|
declare function parseFilterQuery(source: string): FilterParse;
|
|
223
355
|
|
|
356
|
+
/**
|
|
357
|
+
* An attribute whose value is JSON.
|
|
358
|
+
*
|
|
359
|
+
* Several providers take a structure as a string rather than as blocks:
|
|
360
|
+
* a BigQuery table's schema, an ECS task's container definitions, an
|
|
361
|
+
* IAM policy document. Terraform gives an author two ways to write one,
|
|
362
|
+
* a literal string (usually a heredoc) and `jsonencode` over an HCL
|
|
363
|
+
* value, and the two arrive at this reader looking nothing alike. This
|
|
364
|
+
* turns both into the value the provider will see.
|
|
365
|
+
*
|
|
366
|
+
* A schema a file or a variable supplies is not written down anywhere
|
|
367
|
+
* this can read, so it comes back as null and the caller records
|
|
368
|
+
* nothing rather than guessing.
|
|
369
|
+
*/
|
|
370
|
+
/**
|
|
371
|
+
* The value an attribute states as JSON, or null when the attribute is
|
|
372
|
+
* missing or states something only a deploy can settle.
|
|
373
|
+
*/
|
|
374
|
+
declare function jsonAttributeValue(value: unknown): unknown;
|
|
375
|
+
|
|
224
376
|
/**
|
|
225
377
|
* The boundaries a Terraform configuration declares.
|
|
226
378
|
*
|
|
@@ -240,10 +392,21 @@ declare function parseFilterQuery(source: string): FilterParse;
|
|
|
240
392
|
interface TerraformReadOptions {
|
|
241
393
|
/** The packs that say what this configuration's resources are. */
|
|
242
394
|
packs: TerraformPack[];
|
|
395
|
+
/**
|
|
396
|
+
* The directory each deployable unit's code is in, by the instance
|
|
397
|
+
* name the unit is keyed by. A configuration says which handler runs
|
|
398
|
+
* and never which directory the artifact was built from, so a
|
|
399
|
+
* container whose image is built elsewhere has no code at all until
|
|
400
|
+
* somebody says where it is.
|
|
401
|
+
*/
|
|
402
|
+
codeScopes?: Record<string, string>;
|
|
243
403
|
}
|
|
244
404
|
/** Every boundary one Terraform configuration declares. */
|
|
245
405
|
declare function terraformToSummaries(source: string, sourceFile: string, options: TerraformReadOptions): BehavioralSummary[];
|
|
246
|
-
/**
|
|
406
|
+
/**
|
|
407
|
+
* Read one `.tf` file, or every one directly inside a directory, and
|
|
408
|
+
* every local module the configuration calls.
|
|
409
|
+
*/
|
|
247
410
|
declare function terraformFileToSummaries(target: string, options: TerraformReadOptions): BehavioralSummary[];
|
|
248
411
|
|
|
249
|
-
export { type AttributeMeaning, type FilterCall, type FilterParse, type FilterQuery, type FilterTerm, type MessageBusResource, type MetricReadingResource, type MetricResource, type StorageResource, type TerraformPack, type TerraformReadOptions, type TerraformResource, type TerraformResourcePattern, filterCalls, filterTerms, filterValuesFor, parseFilterQuery, terraformFileToSummaries, terraformToSummaries };
|
|
412
|
+
export { type AttributeMeaning, type DeployableCode, type DeployableContainers, type DeployableResource, type EnvDeclaration, type FilterCall, type FilterParse, type FilterQuery, type FilterTerm, type HandlerSpelling, type MessageBusResource, type MetricIdentity, type MetricReadingResource, type MetricResource, type MetricTypeTemplate, type StorageResource, type TerraformPack, type TerraformReadOptions, type TerraformResource, type TerraformResourcePattern, filterCalls, filterTerms, filterValuesFor, jsonAttributeValue, parseFilterQuery, terraformFileToSummaries, terraformToSummaries };
|