@ydkn/pulumi-components 0.5.16 → 0.6.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.
@@ -1,12 +1,17 @@
1
1
  import * as pulumi from "@pulumi/pulumi";
2
2
  import { ComponentResource } from "../common";
3
+ import { Node } from "../node";
3
4
  import * as netbird from "../netbird";
4
5
  export interface NetbirdAgentArgs extends netbird.AgentArgs {
5
6
  clusterName: pulumi.Input<string>;
7
+ nodes: pulumi.Input<pulumi.Input<Node>[]>;
8
+ networkId: pulumi.Input<number>;
9
+ routedSubnets?: pulumi.Input<pulumi.Input<string>[]>;
6
10
  }
7
11
  export declare class NetbirdAgent extends ComponentResource {
8
12
  private readonly netbird;
9
13
  private readonly firewall;
14
+ private readonly networkRoutes;
10
15
  /**
11
16
  * Create a new Netbird agent resource.
12
17
  * @param name The name of the Netbird agent resource.
@@ -14,5 +19,6 @@ export declare class NetbirdAgent extends ComponentResource {
14
19
  * @param opts A bag of options that control this resource's behavior.
15
20
  */
16
21
  constructor(name: string, args: NetbirdAgentArgs, opts?: pulumi.ComponentResourceOptions);
22
+ private static gatewayNodes;
17
23
  }
18
24
  //# sourceMappingURL=netbirdAgent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"netbirdAgent.d.ts","sourceRoot":"","sources":["../../../lib/hcloud/netbirdAgent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,gBAAiB,SAAQ,OAAO,CAAC,SAAS;IACzD,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;CACnC;AAED,qBAAa,YAAa,SAAQ,iBAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAE3C;;;;;OAKG;gBACS,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,wBAAwB;CA2BzF"}
1
+ {"version":3,"file":"netbirdAgent.d.ts","sourceRoot":"","sources":["../../../lib/hcloud/netbirdAgent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,gBAAiB,SAAQ,OAAO,CAAC,SAAS;IACzD,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;CACtD;AAED,qBAAa,YAAa,SAAQ,iBAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAuC;IAErE;;;;;OAKG;gBACS,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,wBAAwB;IA2DxF,OAAO,CAAC,MAAM,CAAC,YAAY;CAgB5B"}
@@ -27,10 +27,12 @@ exports.NetbirdAgent = void 0;
27
27
  const pulumi = __importStar(require("@pulumi/pulumi"));
28
28
  const hcloud = __importStar(require("@pulumi/hcloud"));
29
29
  const common_1 = require("../common");
30
+ const wireguard_1 = require("../wireguard");
30
31
  const netbird = __importStar(require("../netbird"));
31
32
  class NetbirdAgent extends common_1.ComponentResource {
32
33
  netbird;
33
34
  firewall;
35
+ networkRoutes;
34
36
  /**
35
37
  * Create a new Netbird agent resource.
36
38
  * @param name The name of the Netbird agent resource.
@@ -41,6 +43,7 @@ class NetbirdAgent extends common_1.ComponentResource {
41
43
  super("hcloud:netbird:agent", name, args, opts);
42
44
  const hcloudOpts = this.opts(hcloud.Provider);
43
45
  this.netbird = new netbird.Agent(name, args, { ...opts, parent: this });
46
+ const gatewayNodes = NetbirdAgent.gatewayNodes(args.nodes);
44
47
  this.firewall = new hcloud.Firewall(name, {
45
48
  name,
46
49
  applyTos: [{ labelSelector: pulumi.interpolate `cluster=${args.clusterName}` }],
@@ -54,8 +57,34 @@ class NetbirdAgent extends common_1.ComponentResource {
54
57
  },
55
58
  ],
56
59
  }, hcloudOpts);
60
+ this.networkRoutes = pulumi.all([gatewayNodes, args.routedSubnets]).apply(([gatewayNodes, subnets]) => pulumi.all(gatewayNodes ?? []).apply((gatewayNodes) => {
61
+ const gatewayIPs = gatewayNodes.map((node) => node.privateIpv4Address);
62
+ if (gatewayIPs.length === 0) {
63
+ return pulumi.output([]);
64
+ }
65
+ return pulumi.all(subnets ?? []).apply((subnets) => {
66
+ const peerIPRanges = [];
67
+ for (const subnet of subnets) {
68
+ if (subnet.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}$/)) {
69
+ peerIPRanges.push(subnet);
70
+ }
71
+ }
72
+ return peerIPRanges.map((peerIPRange) => new hcloud.NetworkRoute(`${name}-${peerIPRange}`, { networkId: args.networkId, destination: peerIPRange, gateway: gatewayIPs[0] }, { ...hcloudOpts, deleteBeforeReplace: true }));
73
+ });
74
+ }));
57
75
  this.registerOutputs();
58
76
  }
77
+ static gatewayNodes(nodes) {
78
+ return pulumi.all([nodes]).apply(([nodes]) => pulumi.all(nodes ?? []).apply((nodes) => {
79
+ return nodes
80
+ .filter((node) => node.id !== undefined &&
81
+ node.labels !== undefined &&
82
+ node.labels[wireguard_1.Wireguard.gatewayLabel] !== undefined &&
83
+ node.labels[wireguard_1.Wireguard.gatewayLabel] === wireguard_1.Wireguard.gatewayLabelValue &&
84
+ node.privateIpv4Address !== undefined)
85
+ .map((node) => pulumi.output(node));
86
+ }));
87
+ }
59
88
  }
60
89
  exports.NetbirdAgent = NetbirdAgent;
61
90
  //# sourceMappingURL=netbirdAgent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"netbirdAgent.js","sourceRoot":"","sources":["../../../lib/hcloud/netbirdAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAyC;AACzC,uDAAyC;AACzC,sCAA8C;AAC9C,oDAAsC;AAMtC,MAAa,YAAa,SAAQ,0BAAiB;IAChC,OAAO,CAAgB;IACvB,QAAQ,CAAkB;IAE3C;;;;;OAKG;IACH,YAAY,IAAY,EAAE,IAAsB,EAAE,IAAsC;QACtF,KAAK,CAAC,sBAAsB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAExE,IAAI,CAAC,QAAQ,GAAG,IAAI,MAAM,CAAC,QAAQ,CACjC,IAAI,EACJ;YACE,IAAI;YACJ,QAAQ,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,WAAW,CAAA,WAAW,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YAC9E,KAAK,EAAE;gBACL;oBACE,WAAW,EAAE,KAAK;oBAClB,SAAS,EAAE,IAAI;o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