@microagi/alchemy-gcp 0.5.1 → 0.7.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/CHANGELOG.md +47 -0
- package/lib/Auth/Credentials.d.ts +10 -4
- package/lib/Auth/Credentials.d.ts.map +1 -1
- package/lib/Auth/Credentials.js +13 -4
- package/lib/Auth/Credentials.js.map +1 -1
- package/lib/Compute/Address.d.ts +97 -0
- package/lib/Compute/Address.d.ts.map +1 -0
- package/lib/Compute/Address.js +143 -0
- package/lib/Compute/Address.js.map +1 -0
- package/lib/Compute/Firewall.d.ts +108 -0
- package/lib/Compute/Firewall.d.ts.map +1 -0
- package/lib/Compute/Firewall.js +163 -0
- package/lib/Compute/Firewall.js.map +1 -0
- package/lib/Compute/ForwardingRule.d.ts +106 -0
- package/lib/Compute/ForwardingRule.d.ts.map +1 -0
- package/lib/Compute/ForwardingRule.js +152 -0
- package/lib/Compute/ForwardingRule.js.map +1 -0
- package/lib/Compute/index.d.ts +3 -0
- package/lib/Compute/index.d.ts.map +1 -1
- package/lib/Compute/index.js +3 -0
- package/lib/Compute/index.js.map +1 -1
- package/lib/Container/Cluster.d.ts +20 -0
- package/lib/Container/Cluster.d.ts.map +1 -1
- package/lib/Container/Cluster.js +5 -2
- package/lib/Container/Cluster.js.map +1 -1
- package/lib/Container/NodePool.d.ts +26 -1
- package/lib/Container/NodePool.d.ts.map +1 -1
- package/lib/Container/NodePool.js +45 -8
- package/lib/Container/NodePool.js.map +1 -1
- package/lib/Kubernetes/KubernetesManifest.d.ts +100 -0
- package/lib/Kubernetes/KubernetesManifest.d.ts.map +1 -0
- package/lib/Kubernetes/KubernetesManifest.js +131 -0
- package/lib/Kubernetes/KubernetesManifest.js.map +1 -0
- package/lib/Kubernetes/Secret.d.ts +96 -0
- package/lib/Kubernetes/Secret.d.ts.map +1 -0
- package/lib/Kubernetes/Secret.js +173 -0
- package/lib/Kubernetes/Secret.js.map +1 -0
- package/lib/Kubernetes/client.d.ts +62 -0
- package/lib/Kubernetes/client.d.ts.map +1 -0
- package/lib/Kubernetes/client.js +233 -0
- package/lib/Kubernetes/client.js.map +1 -0
- package/lib/Kubernetes/connection.d.ts +48 -0
- package/lib/Kubernetes/connection.d.ts.map +1 -0
- package/lib/Kubernetes/connection.js +93 -0
- package/lib/Kubernetes/connection.js.map +1 -0
- package/lib/Kubernetes/index.d.ts +3 -0
- package/lib/Kubernetes/index.d.ts.map +1 -0
- package/lib/Kubernetes/index.js +3 -0
- package/lib/Kubernetes/index.js.map +1 -0
- package/lib/ManagedLustre/Instance.d.ts.map +1 -1
- package/lib/ManagedLustre/Instance.js +25 -5
- package/lib/ManagedLustre/Instance.js.map +1 -1
- package/lib/Providers.d.ts +1 -1
- package/lib/Providers.d.ts.map +1 -1
- package/lib/Providers.js +11 -1
- package/lib/Providers.js.map +1 -1
- package/lib/Sqladmin/Instance.d.ts.map +1 -1
- package/lib/Sqladmin/Instance.js +28 -6
- package/lib/Sqladmin/Instance.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +3 -1
- package/src/Auth/Credentials.ts +15 -5
- package/src/Compute/Address.ts +288 -0
- package/src/Compute/Firewall.ts +330 -0
- package/src/Compute/ForwardingRule.ts +301 -0
- package/src/Compute/index.ts +3 -0
- package/src/Container/Cluster.ts +25 -2
- package/src/Container/NodePool.ts +87 -13
- package/src/Kubernetes/KubernetesManifest.ts +301 -0
- package/src/Kubernetes/Secret.ts +348 -0
- package/src/Kubernetes/client.ts +386 -0
- package/src/Kubernetes/connection.ts +180 -0
- package/src/Kubernetes/index.ts +2 -0
- package/src/ManagedLustre/Instance.ts +35 -6
- package/src/Providers.ts +24 -0
- package/src/Sqladmin/Instance.ts +36 -7
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,53 @@ All notable changes to `@microagi/alchemy-gcp`. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this package
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## 0.7.0 — 2026-06-16
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`GCP.KubernetesManifest`** — generic Alchemy resource for *any*
|
|
12
|
+
Kubernetes Kind/CRD, server-side-applied via
|
|
13
|
+
`Content-Type: application/apply-patch+yaml` with `fieldManager=alchemy`
|
|
14
|
+
and `force=true`. Kind → REST resource (plural + scope) resolved through
|
|
15
|
+
the apiserver's discovery endpoint, so built-ins and CRDs work without a
|
|
16
|
+
hard-coded kind→plural table. Adoption gated on the standard
|
|
17
|
+
`alchemy_app`/`alchemy_stage`/`alchemy_id` label triple.
|
|
18
|
+
|
|
19
|
+
- **`clusterLayer` (`src/Kubernetes/connection.ts`)** — wires a GKE
|
|
20
|
+
cluster into the typed `@distilled.cloud/kubernetes` SDK: ADC bearer
|
|
21
|
+
token (`Credentials`) + an `HttpClient` whose `FetchHttpClient.Fetch` is
|
|
22
|
+
overridden with a `node:https` fetch that trusts the per-cluster CA.
|
|
23
|
+
The stock fetch can't verify the GKE cert (it's signed by the
|
|
24
|
+
cluster's own CA, not a public root), so the override is required.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **`GCP.KubernetesSecret` convergence** — moved off the hand-rolled
|
|
29
|
+
client onto typed `@distilled.cloud/kubernetes` core/v1 ops. Reconcile
|
|
30
|
+
is now **create + replace (PUT)** with the observed `resourceVersion`
|
|
31
|
+
for optimistic concurrency, bounded `Conflict` retry (recursive on the
|
|
32
|
+
whole observe→write flow, up to 3 re-attempts), and read-modify-write
|
|
33
|
+
metadata that preserves foreign annotations/owner references/finalizers
|
|
34
|
+
(a PUT replaces the whole object, so spreading `...observed.metadata`
|
|
35
|
+
first and overlaying only what we manage is essential — without it
|
|
36
|
+
every reconcile would strip an `ownerReference` and break garbage
|
|
37
|
+
collection). Validation scripts in `scripts/validate-k8s-{connection,
|
|
38
|
+
secret,manifest}.ts` cover live cluster runs against `research-cluster-a`.
|
|
39
|
+
|
|
40
|
+
## 0.6.0 — 2026-06-14
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- **`GCP.KubernetesSecret`** — first Kubernetes resource in the
|
|
45
|
+
provider. Opaque Secret in a GKE cluster, driven via a hand-rolled
|
|
46
|
+
REST client with ADC bearer auth + per-cluster CA trust. Adoptable via
|
|
47
|
+
the standard alchemy-internal label triple.
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- **`Auth/Credentials.fromAuthProvider`** — same fix as `0.5.1`,
|
|
52
|
+
re-asserted against the freshly bumped workspace pins.
|
|
53
|
+
|
|
7
54
|
## 0.5.1 — 2026-06-08
|
|
8
55
|
|
|
9
56
|
### Fixed
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Credentials } from "@distilled.cloud/gcp";
|
|
2
|
+
import { AlchemyProfile } from "alchemy/Auth/Profile";
|
|
3
3
|
import * as Config from "effect/Config";
|
|
4
4
|
import * as Layer from "effect/Layer";
|
|
5
5
|
export { Credentials } from "@distilled.cloud/gcp";
|
|
@@ -12,8 +12,14 @@ export { Credentials } from "@distilled.cloud/gcp";
|
|
|
12
12
|
*
|
|
13
13
|
* Prefer {@link fromAuthProvider} when the stack runs through
|
|
14
14
|
* `alchemy login` / `ALCHEMY_PROFILE`.
|
|
15
|
+
*
|
|
16
|
+
* The `Credentials` service is lazy (its value is an `Effect<Config>`
|
|
17
|
+
* re-evaluated per SDK call), so minting happens at request time —
|
|
18
|
+
* `google-auth-library` caches and refreshes underneath. Failures
|
|
19
|
+
* become defects: the service channel carries no typed error, matching
|
|
20
|
+
* distilled's own `CredentialsFromEnv`.
|
|
15
21
|
*/
|
|
16
|
-
export declare const fromADC: (project?: string) => Layer.Layer<Credentials,
|
|
22
|
+
export declare const fromADC: (project?: string) => Layer.Layer<Credentials, never, never>;
|
|
17
23
|
/**
|
|
18
24
|
* Build a `Credentials` Layer that resolves GCP credentials via the
|
|
19
25
|
* Alchemy AuthProvider registry, using the active profile (from
|
|
@@ -25,5 +31,5 @@ export declare const fromADC: (project?: string) => Layer.Layer<Credentials, Con
|
|
|
25
31
|
* ultimately call `mintToken`, which is just a thin wrapper over
|
|
26
32
|
* `google-auth-library`.
|
|
27
33
|
*/
|
|
28
|
-
export declare const fromAuthProvider: () => Layer.Layer<Credentials,
|
|
34
|
+
export declare const fromAuthProvider: () => Layer.Layer<Credentials, Config.ConfigError | import("alchemy/Auth/AuthProvider").AuthError, import("alchemy").AuthProviders | AlchemyProfile>;
|
|
29
35
|
//# sourceMappingURL=Credentials.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Credentials.d.ts","sourceRoot":"","sources":["../../src/Auth/Credentials.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Credentials.d.ts","sourceRoot":"","sources":["../../src/Auth/Credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAmB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAQtC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASnD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,OAAO,GAAI,UAAU,MAAM,2CAIrC,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,sJAwB1B,CAAC"}
|
package/lib/Auth/Credentials.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigError, Credentials } from "@distilled.cloud/gcp";
|
|
2
2
|
import { getAuthProvider } from "alchemy/Auth/AuthProvider";
|
|
3
|
-
import { ALCHEMY_PROFILE,
|
|
3
|
+
import { ALCHEMY_PROFILE, AlchemyProfile } from "alchemy/Auth/Profile";
|
|
4
4
|
import * as Config from "effect/Config";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
import * as Layer from "effect/Layer";
|
|
@@ -18,8 +18,14 @@ const toConfigError = (e) => new ConfigError({
|
|
|
18
18
|
*
|
|
19
19
|
* Prefer {@link fromAuthProvider} when the stack runs through
|
|
20
20
|
* `alchemy login` / `ALCHEMY_PROFILE`.
|
|
21
|
+
*
|
|
22
|
+
* The `Credentials` service is lazy (its value is an `Effect<Config>`
|
|
23
|
+
* re-evaluated per SDK call), so minting happens at request time —
|
|
24
|
+
* `google-auth-library` caches and refreshes underneath. Failures
|
|
25
|
+
* become defects: the service channel carries no typed error, matching
|
|
26
|
+
* distilled's own `CredentialsFromEnv`.
|
|
21
27
|
*/
|
|
22
|
-
export const fromADC = (project) => Layer.
|
|
28
|
+
export const fromADC = (project) => Layer.succeed(Credentials, mintToken({ project }).pipe(Effect.mapError(toConfigError), Effect.orDie));
|
|
23
29
|
/**
|
|
24
30
|
* Build a `Credentials` Layer that resolves GCP credentials via the
|
|
25
31
|
* Alchemy AuthProvider registry, using the active profile (from
|
|
@@ -32,11 +38,14 @@ export const fromADC = (project) => Layer.effect(Credentials, mintToken({ projec
|
|
|
32
38
|
* `google-auth-library`.
|
|
33
39
|
*/
|
|
34
40
|
export const fromAuthProvider = () => Layer.effect(Credentials, Effect.gen(function* () {
|
|
35
|
-
const profile = yield*
|
|
41
|
+
const profile = yield* AlchemyProfile;
|
|
36
42
|
const auth = yield* getAuthProvider(GCP_AUTH_PROVIDER_NAME);
|
|
37
43
|
const profileName = yield* ALCHEMY_PROFILE;
|
|
38
44
|
const ci = yield* Config.boolean("CI").pipe(Config.withDefault(false));
|
|
39
45
|
const ctx = yield* Effect.context();
|
|
40
|
-
|
|
46
|
+
// The service value is itself an Effect (lazy credentials):
|
|
47
|
+
// profile/provider wiring resolves once at layer build, while
|
|
48
|
+
// loadOrConfigure + token read run per SDK call.
|
|
49
|
+
return profile.loadOrConfigure(auth, profileName, { ci }).pipe(Effect.flatMap((cfg) => auth.read(profileName, cfg)), Effect.map(({ accessToken, project }) => ({ accessToken, project })), Effect.mapError(toConfigError), Effect.provide(ctx), Effect.orDie);
|
|
41
50
|
}));
|
|
42
51
|
//# sourceMappingURL=Credentials.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Credentials.js","sourceRoot":"","sources":["../../src/Auth/Credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"Credentials.js","sourceRoot":"","sources":["../../src/Auth/Credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,sBAAsB,EAGtB,SAAS,GACV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,aAAa,GAAG,CAAC,CAAiC,EAAE,EAAE,CAC1D,IAAI,WAAW,CAAC;IACd,OAAO,EAAE,sCACN,CAA0B,EAAE,OAAO,IAAI,MAAM,CAAC,CAAC,CAClD,EAAE;CACH,CAAC,CAAC;AAEL;;;;;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AAa,CAAC,EAC9B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EACnB,MAAM,CAAC,KAAK,CACb,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Resource } from "alchemy";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import type * as GCP from "../Providers.ts";
|
|
4
|
+
/**
|
|
5
|
+
* A regional compute Address. The intended use here is a **Private
|
|
6
|
+
* Service Connect consumer endpoint IP** — a single internal address
|
|
7
|
+
* reserved in a subnet (`addressType=INTERNAL`, `purpose=GCE_ENDPOINT`)
|
|
8
|
+
* that a `ForwardingRule` then binds to a producer service attachment
|
|
9
|
+
* (e.g. a Cloud SQL instance in another VPC).
|
|
10
|
+
*
|
|
11
|
+
* For global PSA *ranges* (`purpose=VPC_PEERING`) use
|
|
12
|
+
* {@link GlobalAddress} — that is a different API surface
|
|
13
|
+
* (`globalAddresses` vs regional `addresses`).
|
|
14
|
+
*
|
|
15
|
+
* Adoption uses the labels field (Address carries `labels` +
|
|
16
|
+
* `labelFingerprint`).
|
|
17
|
+
*
|
|
18
|
+
* @section Reserving a PSC endpoint IP
|
|
19
|
+
* @example Internal address inside a subnet for a PSC forwarding rule
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const endpointIp = yield* GCP.Address("DbPscAddress", {
|
|
22
|
+
* project: hostProject.projectId,
|
|
23
|
+
* region: "europe-west1",
|
|
24
|
+
* subnetwork: pscSubnet.selfLink,
|
|
25
|
+
* address: "10.0.16.5",
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export type AddressProps = {
|
|
30
|
+
/** GCP project ID hosting the address. Immutable — replace if changed. */
|
|
31
|
+
project: string;
|
|
32
|
+
/** GCP region. Addresses are regional — a different region requires replace. */
|
|
33
|
+
region: string;
|
|
34
|
+
/**
|
|
35
|
+
* Address name. Defaults to `createPhysicalName({ id, lowercase: true,
|
|
36
|
+
* maxLength: 63 })`. Immutable — replace if changed.
|
|
37
|
+
*/
|
|
38
|
+
name?: string;
|
|
39
|
+
/** Description (free-form). Set on create; immutable. */
|
|
40
|
+
description?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Internal vs external. Defaults to `INTERNAL` (the only value that
|
|
43
|
+
* makes sense for a PSC endpoint IP). Immutable — replace.
|
|
44
|
+
*/
|
|
45
|
+
addressType?: "INTERNAL" | "EXTERNAL";
|
|
46
|
+
/**
|
|
47
|
+
* Address purpose. For a PSC endpoint IP use `GCE_ENDPOINT` (the
|
|
48
|
+
* default GCP assigns to plain internal addresses). Immutable — replace.
|
|
49
|
+
*/
|
|
50
|
+
purpose?: "GCE_ENDPOINT" | "SHARED_LOADBALANCER_VIP" | "DNS_RESOLVER";
|
|
51
|
+
/**
|
|
52
|
+
* URL of the subnetwork the address is allocated from. Pass
|
|
53
|
+
* `subnet.selfLink` from a `GCP.Subnetwork` to make alchemy sequence
|
|
54
|
+
* the address after the subnet. Required for INTERNAL addresses.
|
|
55
|
+
* Immutable — replace.
|
|
56
|
+
*/
|
|
57
|
+
subnetwork: string;
|
|
58
|
+
/**
|
|
59
|
+
* Explicit IP to reserve inside the subnet's range. If omitted, GCP
|
|
60
|
+
* picks one. Immutable — replace.
|
|
61
|
+
*/
|
|
62
|
+
address?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Resource labels. Alchemy internal labels (`alchemy_app`,
|
|
65
|
+
* `alchemy_stage`, `alchemy_id`) are merged on top automatically and
|
|
66
|
+
* are reserved. Mutable via `setLabels`.
|
|
67
|
+
*/
|
|
68
|
+
labels?: Record<string, string>;
|
|
69
|
+
};
|
|
70
|
+
export type AddressAttributes = {
|
|
71
|
+
/** Address name. */
|
|
72
|
+
name: string;
|
|
73
|
+
/** GCP project ID, threaded through from props for delete/read. */
|
|
74
|
+
project: string;
|
|
75
|
+
/** GCP region, threaded through from props for delete/read. */
|
|
76
|
+
region: string;
|
|
77
|
+
/** Server-defined URL. */
|
|
78
|
+
selfLink: string;
|
|
79
|
+
/** Server-assigned numeric id. */
|
|
80
|
+
id: string;
|
|
81
|
+
/** The reserved IP. */
|
|
82
|
+
address: string;
|
|
83
|
+
/** Address type. */
|
|
84
|
+
addressType: string | undefined;
|
|
85
|
+
/** Purpose. */
|
|
86
|
+
purpose: string | undefined;
|
|
87
|
+
/** Subnetwork URL. */
|
|
88
|
+
subnetwork: string | undefined;
|
|
89
|
+
/** Status: `RESERVING`, `RESERVED`, `IN_USE`. */
|
|
90
|
+
status: string | undefined;
|
|
91
|
+
/** Labels currently set, including the alchemy internals. */
|
|
92
|
+
labels: Record<string, string>;
|
|
93
|
+
};
|
|
94
|
+
export type Address = Resource<"GCP.Address", AddressProps, AddressAttributes, never, GCP.Providers>;
|
|
95
|
+
export declare const Address: import("alchemy").ResourceClass<Address>;
|
|
96
|
+
export declare const AddressProvider: () => import("effect/Layer").Layer<Provider.Provider<Address>, never, import("alchemy").Stack | import("alchemy").Stage | import("@distilled.cloud/gcp").Credentials | import("effect/unstable/http/HttpClient").HttpClient>;
|
|
97
|
+
//# sourceMappingURL=Address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Address.d.ts","sourceRoot":"","sources":["../../src/Compute/Address.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKnC,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAG7C,OAAO,KAAK,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,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Unowned } from "alchemy/AdoptPolicy";
|
|
4
|
+
import { deepEqual, isResolved, somePropsAreDifferent } from "alchemy/Diff";
|
|
5
|
+
import { createPhysicalName } from "alchemy/PhysicalName";
|
|
6
|
+
import * as Provider from "alchemy/Provider";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import { gcpInternalLabels, hasAlchemyLabels } from "../Tags.js";
|
|
9
|
+
import { makeAwaitRegionOperation } from "./Operations.js";
|
|
10
|
+
export const Address = Resource("GCP.Address");
|
|
11
|
+
const toAddressAttributes = (a, parent) => ({
|
|
12
|
+
name: a.name ?? "",
|
|
13
|
+
project: parent.project,
|
|
14
|
+
region: parent.region,
|
|
15
|
+
selfLink: a.selfLink ?? "",
|
|
16
|
+
id: a.id ?? "",
|
|
17
|
+
address: a.address ?? "",
|
|
18
|
+
addressType: a.addressType,
|
|
19
|
+
purpose: a.purpose,
|
|
20
|
+
subnetwork: a.subnetwork,
|
|
21
|
+
status: a.status,
|
|
22
|
+
labels: { ...(a.labels ?? {}) },
|
|
23
|
+
});
|
|
24
|
+
export const AddressProvider = () => Provider.effect(Address, Effect.gen(function* () {
|
|
25
|
+
const getAddresses = yield* compute.getAddresses;
|
|
26
|
+
const insertAddresses = yield* compute.insertAddresses;
|
|
27
|
+
const deleteAddresses = yield* compute.deleteAddresses;
|
|
28
|
+
const setLabelsAddresses = yield* compute.setLabelsAddresses;
|
|
29
|
+
const getRegionOperations = yield* compute.getRegionOperations;
|
|
30
|
+
const awaitOp = makeAwaitRegionOperation(getRegionOperations);
|
|
31
|
+
const observe = (project, region, name) => getAddresses({ project, region, address: name }).pipe(Effect.catchTag("NotFound", () => Effect.succeed(undefined)), Effect.catchTag("Forbidden", () => Effect.succeed(undefined)));
|
|
32
|
+
const syncLabels = Effect.fn(function* (args) {
|
|
33
|
+
if (deepEqual(args.observed.labels ?? {}, args.desired))
|
|
34
|
+
return;
|
|
35
|
+
const op = yield* setLabelsAddresses({
|
|
36
|
+
project: args.project,
|
|
37
|
+
region: args.region,
|
|
38
|
+
resource: args.observed.name ?? "",
|
|
39
|
+
body: {
|
|
40
|
+
labels: args.desired,
|
|
41
|
+
labelFingerprint: args.observed.labelFingerprint,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
if (op.name) {
|
|
45
|
+
yield* awaitOp(args.project, args.region, op.name, args.session);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
stables: ["name", "project", "region", "selfLink", "id", "address"],
|
|
50
|
+
diff: Effect.fn(function* ({ news, olds = {} }) {
|
|
51
|
+
if (!isResolved(news))
|
|
52
|
+
return undefined;
|
|
53
|
+
if (somePropsAreDifferent(olds, news, [
|
|
54
|
+
"project",
|
|
55
|
+
"region",
|
|
56
|
+
"name",
|
|
57
|
+
"addressType",
|
|
58
|
+
"purpose",
|
|
59
|
+
"subnetwork",
|
|
60
|
+
"address",
|
|
61
|
+
])) {
|
|
62
|
+
return { action: "replace" };
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}),
|
|
66
|
+
reconcile: Effect.fn(function* ({ id, news, session }) {
|
|
67
|
+
const internalLabels = yield* gcpInternalLabels(id);
|
|
68
|
+
const desiredName = news.name ??
|
|
69
|
+
(yield* createPhysicalName({ id, maxLength: 63 })).toLowerCase();
|
|
70
|
+
const desiredLabels = {
|
|
71
|
+
...(news.labels ?? {}),
|
|
72
|
+
...internalLabels,
|
|
73
|
+
};
|
|
74
|
+
let observed = yield* observe(news.project, news.region, desiredName);
|
|
75
|
+
if (!observed) {
|
|
76
|
+
const body = {
|
|
77
|
+
name: desiredName,
|
|
78
|
+
...(news.description ? { description: news.description } : {}),
|
|
79
|
+
addressType: news.addressType ?? "INTERNAL",
|
|
80
|
+
...(news.purpose ? { purpose: news.purpose } : {}),
|
|
81
|
+
subnetwork: news.subnetwork,
|
|
82
|
+
...(news.address ? { address: news.address } : {}),
|
|
83
|
+
labels: desiredLabels,
|
|
84
|
+
};
|
|
85
|
+
const op = yield* insertAddresses({
|
|
86
|
+
project: news.project,
|
|
87
|
+
region: news.region,
|
|
88
|
+
body,
|
|
89
|
+
}).pipe(Effect.catchTag("Conflict", () => Effect.succeed(undefined)));
|
|
90
|
+
if (op?.name) {
|
|
91
|
+
yield* awaitOp(news.project, news.region, op.name, session);
|
|
92
|
+
}
|
|
93
|
+
observed = yield* getAddresses({
|
|
94
|
+
project: news.project,
|
|
95
|
+
region: news.region,
|
|
96
|
+
address: desiredName,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
yield* syncLabels({
|
|
100
|
+
project: news.project,
|
|
101
|
+
region: news.region,
|
|
102
|
+
observed,
|
|
103
|
+
desired: desiredLabels,
|
|
104
|
+
session,
|
|
105
|
+
});
|
|
106
|
+
const final = yield* getAddresses({
|
|
107
|
+
project: news.project,
|
|
108
|
+
region: news.region,
|
|
109
|
+
address: desiredName,
|
|
110
|
+
});
|
|
111
|
+
return toAddressAttributes(final, {
|
|
112
|
+
project: news.project,
|
|
113
|
+
region: news.region,
|
|
114
|
+
});
|
|
115
|
+
}),
|
|
116
|
+
delete: Effect.fn(function* ({ output, session }) {
|
|
117
|
+
yield* deleteAddresses({
|
|
118
|
+
project: output.project,
|
|
119
|
+
region: output.region,
|
|
120
|
+
address: output.name,
|
|
121
|
+
}).pipe(Effect.flatMap((op) => op.name
|
|
122
|
+
? awaitOp(output.project, output.region, op.name, session)
|
|
123
|
+
: Effect.succeed(op)), Effect.catchTag("NotFound", () => Effect.void));
|
|
124
|
+
}),
|
|
125
|
+
read: Effect.fn(function* ({ id, output, olds }) {
|
|
126
|
+
const project = output?.project ?? olds?.project;
|
|
127
|
+
const region = output?.region ?? olds?.region;
|
|
128
|
+
if (!project || !region)
|
|
129
|
+
return undefined;
|
|
130
|
+
const name = output?.name ??
|
|
131
|
+
olds?.name ??
|
|
132
|
+
(yield* createPhysicalName({ id, maxLength: 63 })).toLowerCase();
|
|
133
|
+
const observed = yield* observe(project, region, name);
|
|
134
|
+
if (!observed)
|
|
135
|
+
return undefined;
|
|
136
|
+
const attrs = toAddressAttributes(observed, { project, region });
|
|
137
|
+
return (yield* hasAlchemyLabels(id, observed.labels))
|
|
138
|
+
? attrs
|
|
139
|
+
: Unowned(attrs);
|
|
140
|
+
}),
|
|
141
|
+
};
|
|
142
|
+
}));
|
|
143
|
+
//# sourceMappingURL=Address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Address.js","sourceRoot":"","sources":["../../src/Compute/Address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAqG3D,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAU,aAAa,CAAC,CAAC;AAExD,MAAM,mBAAmB,GAAG,CAC1B,CAAkB,EAClB,MAA2C,EACxB,EAAE,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE;IAClB,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,EAAE;IAC1B,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE;IACd,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,EAAE;I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B,CAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACnD,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Resource } from "alchemy";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import type * as GCP from "../Providers.ts";
|
|
4
|
+
/** One allow entry: a protocol plus optional port list. */
|
|
5
|
+
export type FirewallAllowed = {
|
|
6
|
+
/** `tcp` | `udp` | `icmp` | `esp` | `ah` | `sctp` | protocol number. */
|
|
7
|
+
IPProtocol: string;
|
|
8
|
+
/** Ports / ranges (`"8000"`, `"8000-8100"`). Omit = all ports. */
|
|
9
|
+
ports?: ReadonlyArray<string>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A VPC firewall rule (allow rules only — `denied` is not modelled;
|
|
13
|
+
* add it when a consumer needs it).
|
|
14
|
+
*
|
|
15
|
+
* Firewalls have no `labels` field, so adoption gating uses the
|
|
16
|
+
* alchemy marker embedded in `description` (same as `GCP.Network`).
|
|
17
|
+
* Unlike Network, firewall `description` IS mutable, and the sync step
|
|
18
|
+
* keeps the marker prefix in place on every reconcile.
|
|
19
|
+
*
|
|
20
|
+
* GCP rejects rules carrying BOTH `targetTags` and
|
|
21
|
+
* `targetServiceAccounts` — prefer service accounts for GKE node
|
|
22
|
+
* targeting: node tags embed a per-cluster random suffix and go stale
|
|
23
|
+
* on every cluster rebuild, while the compute default SA is stable.
|
|
24
|
+
*
|
|
25
|
+
* @section Creating a firewall rule
|
|
26
|
+
* @example GCLB health checks → GKE pods on 8000
|
|
27
|
+
* ```typescript
|
|
28
|
+
* yield* GCP.Firewall("LbHealthChecks", {
|
|
29
|
+
* project: host.projectId,
|
|
30
|
+
* network: vpc.selfLink,
|
|
31
|
+
* name: "k8s-app-hc",
|
|
32
|
+
* sourceRanges: ["130.211.0.0/22", "35.191.0.0/16"],
|
|
33
|
+
* allowed: [{ IPProtocol: "tcp", ports: ["8000"] }],
|
|
34
|
+
* targetServiceAccounts: [nodeSa],
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export type FirewallProps = {
|
|
39
|
+
/** GCP project ID hosting the rule. Immutable — replace if changed. */
|
|
40
|
+
project: string;
|
|
41
|
+
/**
|
|
42
|
+
* Rule name. Defaults to `createPhysicalName({ id, lowercase: true,
|
|
43
|
+
* maxLength: 63 })`. Immutable — replace if changed.
|
|
44
|
+
*/
|
|
45
|
+
name?: string;
|
|
46
|
+
/**
|
|
47
|
+
* VPC the rule attaches to — short name or selfLink. Immutable —
|
|
48
|
+
* replace if changed.
|
|
49
|
+
*/
|
|
50
|
+
network: string;
|
|
51
|
+
/** User-visible description (stored after the alchemy marker). Mutable. */
|
|
52
|
+
description?: string;
|
|
53
|
+
/** INGRESS (default) or EGRESS. Immutable — replace if changed. */
|
|
54
|
+
direction?: "INGRESS" | "EGRESS";
|
|
55
|
+
/** 0–65535, lower wins. GCP default 1000. Mutable. */
|
|
56
|
+
priority?: number;
|
|
57
|
+
/** Source CIDRs (INGRESS). Mutable. */
|
|
58
|
+
sourceRanges?: ReadonlyArray<string>;
|
|
59
|
+
/** Destination CIDRs (EGRESS). Mutable. */
|
|
60
|
+
destinationRanges?: ReadonlyArray<string>;
|
|
61
|
+
/** Allow entries. Required — this resource models allow rules only. Mutable. */
|
|
62
|
+
allowed: ReadonlyArray<FirewallAllowed>;
|
|
63
|
+
/**
|
|
64
|
+
* Instance network tags the rule applies to. Mutually exclusive with
|
|
65
|
+
* `targetServiceAccounts`. Mutable.
|
|
66
|
+
*/
|
|
67
|
+
targetTags?: ReadonlyArray<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Service accounts whose instances the rule applies to. Preferred
|
|
70
|
+
* over tags for GKE nodes (stable across cluster rebuilds). Mutually
|
|
71
|
+
* exclusive with `targetTags`. Mutable.
|
|
72
|
+
*/
|
|
73
|
+
targetServiceAccounts?: ReadonlyArray<string>;
|
|
74
|
+
/** Rule disabled (kept but not enforced). Mutable. */
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
};
|
|
77
|
+
export type FirewallAttributes = {
|
|
78
|
+
/** Rule name. */
|
|
79
|
+
name: string;
|
|
80
|
+
/** GCP project ID, threaded through from props for delete/read. */
|
|
81
|
+
project: string;
|
|
82
|
+
/** Server-defined URL. */
|
|
83
|
+
selfLink: string;
|
|
84
|
+
/** Server-assigned numeric id. */
|
|
85
|
+
id: string;
|
|
86
|
+
/** VPC selfLink the rule is attached to. */
|
|
87
|
+
network: string;
|
|
88
|
+
/** INGRESS / EGRESS. */
|
|
89
|
+
direction: string | undefined;
|
|
90
|
+
/** Effective priority. */
|
|
91
|
+
priority: number | undefined;
|
|
92
|
+
/** Source CIDRs. */
|
|
93
|
+
sourceRanges: ReadonlyArray<string> | undefined;
|
|
94
|
+
/** Allow entries. */
|
|
95
|
+
allowed: ReadonlyArray<FirewallAllowed> | undefined;
|
|
96
|
+
/** Target network tags. */
|
|
97
|
+
targetTags: ReadonlyArray<string> | undefined;
|
|
98
|
+
/** Target service accounts. */
|
|
99
|
+
targetServiceAccounts: ReadonlyArray<string> | undefined;
|
|
100
|
+
/** User description (alchemy marker stripped). */
|
|
101
|
+
description: string | undefined;
|
|
102
|
+
/** Disabled flag. */
|
|
103
|
+
disabled: boolean | undefined;
|
|
104
|
+
};
|
|
105
|
+
export type Firewall = Resource<"GCP.Firewall", FirewallProps, FirewallAttributes, never, GCP.Providers>;
|
|
106
|
+
export declare const Firewall: import("alchemy").ResourceClass<Firewall>;
|
|
107
|
+
export declare const FirewallProvider: () => import("effect/Layer").Layer<Provider.Provider<Firewall>, never, import("alchemy").Stack | import("alchemy").Stage | import("@distilled.cloud/gcp").Credentials | import("effect/unstable/http/HttpClient").HttpClient>;
|
|
108
|
+
//# sourceMappingURL=Firewall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