@intentius/chant-lexicon-aws 0.124.104 → 0.124.105
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/dist/health.d.ts +7 -0
- package/dist/health.js +37 -16
- package/dist/integrity.json +2 -2
- package/dist/manifest.json +1 -1
- package/package.json +2 -2
package/dist/health.d.ts
CHANGED
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Both go through the read transport's endpoint rule, so `AWS_ENDPOINT_URL`
|
|
15
15
|
* (Floci) answers them.
|
|
16
|
+
*
|
|
17
|
+
* A terraform root's or pulumi stack's resources come with
|
|
18
|
+
* `options.physicalIds` (#5338): a health check's id and a service's ARN, as
|
|
19
|
+
* the engine recorded them. The stack list is then not read. A service is
|
|
20
|
+
* described in the region its ARN names.
|
|
16
21
|
*/
|
|
17
22
|
import type { HealthEntry, HealthReadOptions, HealthReadResult } from "@intentius/chant/lexicon";
|
|
18
23
|
import { type AwsReadClientOptions } from "./api/read-client.js";
|
|
@@ -57,4 +62,6 @@ export interface EcsServiceState {
|
|
|
57
62
|
export declare function ecsServiceEntry(service: EcsServiceState, observedAt: string): HealthEntry;
|
|
58
63
|
/** The cluster a service ARN names: `service/<cluster>/<name>`, or the default cluster for the old `service/<name>` form. */
|
|
59
64
|
export declare function clusterOfServiceArn(arn: string): string;
|
|
65
|
+
/** The region an ARN names (`arn:aws:ecs:<region>:...`), or undefined for one that names none. */
|
|
66
|
+
export declare function regionOfArn(arn: string): string | undefined;
|
|
60
67
|
export declare function observeHealthAws(options: AwsHealthOptions): Promise<HealthReadResult>;
|
package/dist/health.js
CHANGED
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Both go through the read transport's endpoint rule, so `AWS_ENDPOINT_URL`
|
|
15
15
|
* (Floci) answers them.
|
|
16
|
+
*
|
|
17
|
+
* A terraform root's or pulumi stack's resources come with
|
|
18
|
+
* `options.physicalIds` (#5338): a health check's id and a service's ARN, as
|
|
19
|
+
* the engine recorded them. The stack list is then not read. A service is
|
|
20
|
+
* described in the region its ARN names.
|
|
16
21
|
*/
|
|
17
22
|
import { AwsReadError, describeStackResources, requestHeaders, serviceUrl, withChainCredentials, withEndpointOverride, xmlError, xmlLeaves, } from "./api/read-client.js";
|
|
18
23
|
import { resolveCredentials, signRequest } from "./api/signing.js";
|
|
@@ -83,6 +88,11 @@ export function clusterOfServiceArn(arn) {
|
|
|
83
88
|
const parts = resource.split("/");
|
|
84
89
|
return parts.length >= 3 ? parts[1] : "default";
|
|
85
90
|
}
|
|
91
|
+
/** The region an ARN names (`arn:aws:ecs:<region>:...`), or undefined for one that names none. */
|
|
92
|
+
export function regionOfArn(arn) {
|
|
93
|
+
const region = arn.startsWith("arn:") ? arn.split(":")[3] : undefined;
|
|
94
|
+
return region ? region : undefined;
|
|
95
|
+
}
|
|
86
96
|
function holeFrom(type, err) {
|
|
87
97
|
const detail = err instanceof AwsReadError && err.code ? `${err.code}: ${err.message}` : err instanceof Error ? err.message : String(err);
|
|
88
98
|
const reason = /credential|token|expired|AccessDenied|not authorized|Unauthorized/i.test(detail) ? "no-credentials" : "read-failed";
|
|
@@ -142,19 +152,27 @@ export async function observeHealthAws(options) {
|
|
|
142
152
|
return { entities, unobserved, absent };
|
|
143
153
|
const stackName = options.stack ?? options.environment;
|
|
144
154
|
let physical;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
155
|
+
if (options.physicalIds) {
|
|
156
|
+
// An engine's records (#5338): a terraform root's state or a pulumi
|
|
157
|
+
// stack's export already hold each id, so no stack is read.
|
|
158
|
+
physical = new Map(Object.entries(options.physicalIds));
|
|
148
159
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
unobserved[name] = holeFrom(entityType, err);
|
|
154
|
-
unobserved[name].detail = `DescribeStackResources failed for stack "${stackName}": ${unobserved[name].detail}`;
|
|
160
|
+
else
|
|
161
|
+
try {
|
|
162
|
+
const resources = await describeStackResources(stackName, client);
|
|
163
|
+
physical = new Map(resources.filter((r) => r.physicalId).map((r) => [r.logicalId, r.physicalId]));
|
|
155
164
|
}
|
|
156
|
-
|
|
157
|
-
|
|
165
|
+
catch (err) {
|
|
166
|
+
if (err instanceof AwsReadError && stackDoesNotExist(err.message))
|
|
167
|
+
return { entities, unobserved, absent: [...options.entities.keys()] };
|
|
168
|
+
for (const [name, { entityType }] of options.entities) {
|
|
169
|
+
unobserved[name] = holeFrom(entityType, err);
|
|
170
|
+
unobserved[name].detail = `DescribeStackResources failed for stack "${stackName}": ${unobserved[name].detail}`;
|
|
171
|
+
}
|
|
172
|
+
return { entities, unobserved, absent };
|
|
173
|
+
}
|
|
174
|
+
// Keyed by cluster and the region the ARN names, so a service recorded in
|
|
175
|
+
// another region than the ambient one is described there.
|
|
158
176
|
const services = new Map();
|
|
159
177
|
const checks = [];
|
|
160
178
|
for (const [name, { entityType }] of options.entities) {
|
|
@@ -165,9 +183,11 @@ export async function observeHealthAws(options) {
|
|
|
165
183
|
}
|
|
166
184
|
if (entityType === "AWS::ECS::Service") {
|
|
167
185
|
const cluster = clusterOfServiceArn(id);
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
services.
|
|
186
|
+
const region = options.physicalIds ? regionOfArn(id) : undefined;
|
|
187
|
+
const key = `${cluster}\u0000${region ?? ""}`;
|
|
188
|
+
const group = services.get(key) ?? { cluster, ...(region ? { region } : {}), members: [] };
|
|
189
|
+
group.members.push({ name, arn: id });
|
|
190
|
+
services.set(key, group);
|
|
171
191
|
}
|
|
172
192
|
else if (entityType === "AWS::Route53::HealthCheck") {
|
|
173
193
|
checks.push({ name, id });
|
|
@@ -184,12 +204,13 @@ export async function observeHealthAws(options) {
|
|
|
184
204
|
unobserved[name] = holeFrom("AWS::Route53::HealthCheck", err);
|
|
185
205
|
}
|
|
186
206
|
}));
|
|
187
|
-
await Promise.all([...services].map(async (
|
|
207
|
+
await Promise.all([...services.values()].map(async ({ cluster, region, members }) => {
|
|
208
|
+
const scoped = region ? { ...client, region } : client;
|
|
188
209
|
// DescribeServices takes at most ten services per call.
|
|
189
210
|
for (let i = 0; i < members.length; i += 10) {
|
|
190
211
|
const batch = members.slice(i, i + 10);
|
|
191
212
|
try {
|
|
192
|
-
const { services: found, failures } = await describeServices(cluster, batch.map((m) => m.arn),
|
|
213
|
+
const { services: found, failures } = await describeServices(cluster, batch.map((m) => m.arn), scoped, http);
|
|
193
214
|
for (const member of batch) {
|
|
194
215
|
const service = found.find((s) => s.serviceArn === member.arn || s.serviceArn?.endsWith(`/${member.arn.split("/").pop()}`));
|
|
195
216
|
const failure = failures.find((f) => f.arn === member.arn);
|
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "861ee54c647e9252e5a28f81abb1db14ae6ee223f2bec47d3e6d1748ec977266",
|
|
5
5
|
"meta.json": "7de63d55427041907cd0fbdc504fc496d381e2bfebeae2fe9d48f1847ed29faf",
|
|
6
6
|
"types/index.d.ts": "8651f9ae166668f4311eea1fe61c3fe235f345947951c1d23d1df24a4fd3384f",
|
|
7
7
|
"rules/hardcoded-region.ts": "957eadcaa9f39cc17d21437565d7a94607d9b082cf28918b178fa067f07498a9",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"skills/chant-aws-eks.md": "8789255709ff004ad0a875fd5999edcdc66fc6e33d710db058d9f42703bcfdfe",
|
|
76
76
|
"skills/chant-aws-carve-terraform.md": "a6f528c814024422744118abbfd9bbf26f3d60c599e90c3f186f8b76e1e38a51"
|
|
77
77
|
},
|
|
78
|
-
"composite": "
|
|
78
|
+
"composite": "bc24df9f98297780b4196fea31b964c877b9464b21e143bc5760cabce7de43fc"
|
|
79
79
|
}
|
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-aws",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.105",
|
|
4
4
|
"description": "AWS CloudFormation lexicon for chant — declarative IaC in TypeScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -82,6 +82,6 @@
|
|
|
82
82
|
"typescript": "^5.9.3"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
-
"@intentius/chant": "^0.124.
|
|
85
|
+
"@intentius/chant": "^0.124.110"
|
|
86
86
|
}
|
|
87
87
|
}
|