@ttoss/cloud-vpc 0.1.47 → 0.1.49

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,48 +1,18 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- "use strict";
3
-
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", {
9
- value,
10
- configurable: true
2
+ Object.defineProperty(exports, Symbol.toStringTag, {
3
+ value: 'Module'
11
4
  });
12
- var __export = (target, all) => {
13
- for (var name in all) __defProp(target, name, {
14
- get: all[name],
15
- enumerable: true
16
- });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
- get: () => from[key],
22
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
- });
24
- }
25
- return to;
26
- };
27
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
28
- value: true
29
- }), mod);
30
5
 
31
- // src/index.ts
32
- var index_exports = {};
33
- __export(index_exports, {
34
- createVpcTemplate: () => createVpcTemplate
35
- });
36
- module.exports = __toCommonJS(index_exports);
37
- var NUMBER_OF_AVAILABILITY_ZONES = 3;
38
- var PUBLIC_ROUTER_TABLE_LOGICAL_ID = "PublicRouteTable";
39
- var PRIVATE_ROUTER_TABLE_LOGICAL_ID = "PrivateRouteTable";
40
- var createVpcTemplate = /* @__PURE__ */__name(({
6
+ //#region src/index.ts
7
+ const NUMBER_OF_AVAILABILITY_ZONES = 3;
8
+ const PUBLIC_ROUTER_TABLE_LOGICAL_ID = "PublicRouteTable";
9
+ const PRIVATE_ROUTER_TABLE_LOGICAL_ID = "PrivateRouteTable";
10
+ const createVpcTemplate = ({
41
11
  cidrBlock,
42
12
  createPublicSubnets = true
43
13
  }) => {
44
14
  const totalOfSubnetsOnEachType = 2;
45
- const getSubnetResource = /* @__PURE__ */__name(({
15
+ const getSubnetResource = ({
46
16
  number,
47
17
  isPublic
48
18
  }) => {
@@ -50,10 +20,16 @@ var createVpcTemplate = /* @__PURE__ */__name(({
50
20
  const key = `${subnetType}Subnet${number}`;
51
21
  const routerTableAssociationKey = `${subnetType}Subnet${number}RouteTableAssociation`;
52
22
  const index = (isPublic ? 0 : 1) * totalOfSubnetsOnEachType + number - 1;
23
+ /**
24
+ * It's because AWS infrastructure has a minimum of 3 availability zones
25
+ * in each region. So, we need to calculate the index of the availability
26
+ * zone based on the number of subnets and the type of subnet.
27
+ *
28
+ * https://aws.amazon.com/about-aws/global-infrastructure/regions_az/
29
+ */
53
30
  const azIndex = index % NUMBER_OF_AVAILABILITY_ZONES;
54
31
  const cidrSubBlockCount = 2 * totalOfSubnetsOnEachType;
55
- const cidrPrefixLength = parseInt(cidrBlock.split("/")[1], 10);
56
- const cidrSubBlockBits = 32 - cidrPrefixLength - Math.ceil(Math.log2(cidrSubBlockCount));
32
+ const cidrSubBlockBits = 32 - parseInt(cidrBlock.split("/")[1], 10) - Math.ceil(Math.log2(cidrSubBlockCount));
57
33
  let resources = {
58
34
  [key]: {
59
35
  Type: "AWS::EC2::Subnet",
@@ -92,18 +68,14 @@ var createVpcTemplate = /* @__PURE__ */__name(({
92
68
  }
93
69
  }
94
70
  };
95
- if (isPublic) {
96
- resources = {
97
- ...resources
98
- };
99
- }
100
- if (!isPublic) {
101
- resources = {
102
- ...resources
103
- };
104
- }
71
+ if (isPublic) resources = {
72
+ ...resources
73
+ };
74
+ if (!isPublic) resources = {
75
+ ...resources
76
+ };
105
77
  return resources;
106
- }, "getSubnetResource");
78
+ };
107
79
  const template = {
108
80
  AWSTemplateFormatVersion: "2010-09-09",
109
81
  Description: "VPC, Subnets, and Route Tables for the project.",
@@ -256,8 +228,7 @@ var createVpcTemplate = /* @__PURE__ */__name(({
256
228
  };
257
229
  }
258
230
  return template;
259
- }, "createVpcTemplate");
260
- // Annotate the CommonJS export names for ESM import in node:
261
- 0 && (module.exports = {
262
- createVpcTemplate
263
- });
231
+ };
232
+
233
+ //#endregion
234
+ exports.createVpcTemplate = createVpcTemplate;
@@ -0,0 +1,13 @@
1
+
2
+ import { CloudFormationTemplate } from "@ttoss/cloudformation";
3
+
4
+ //#region src/index.d.ts
5
+ declare const createVpcTemplate: ({
6
+ cidrBlock,
7
+ createPublicSubnets
8
+ }: {
9
+ cidrBlock: string;
10
+ createPublicSubnets?: boolean;
11
+ }) => CloudFormationTemplate;
12
+ //#endregion
13
+ export { type CloudFormationTemplate, createVpcTemplate };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,13 @@
1
- import { CloudFormationTemplate } from '@ttoss/cloudformation';
2
- export { CloudFormationTemplate } from '@ttoss/cloudformation';
3
1
 
4
- declare const createVpcTemplate: ({ cidrBlock, createPublicSubnets, }: {
5
- cidrBlock: string;
6
- createPublicSubnets?: boolean;
7
- }) => CloudFormationTemplate;
2
+ import { CloudFormationTemplate } from "@ttoss/cloudformation";
8
3
 
9
- export { createVpcTemplate };
4
+ //#region src/index.d.ts
5
+ declare const createVpcTemplate: ({
6
+ cidrBlock,
7
+ createPublicSubnets
8
+ }: {
9
+ cidrBlock: string;
10
+ createPublicSubnets?: boolean;
11
+ }) => CloudFormationTemplate;
12
+ //#endregion
13
+ export { type CloudFormationTemplate, createVpcTemplate };
@@ -1,20 +1,14 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", {
4
- value,
5
- configurable: true
6
- });
7
-
8
- // src/index.ts
9
- var NUMBER_OF_AVAILABILITY_ZONES = 3;
10
- var PUBLIC_ROUTER_TABLE_LOGICAL_ID = "PublicRouteTable";
11
- var PRIVATE_ROUTER_TABLE_LOGICAL_ID = "PrivateRouteTable";
12
- var createVpcTemplate = /* @__PURE__ */__name(({
2
+ //#region src/index.ts
3
+ const NUMBER_OF_AVAILABILITY_ZONES = 3;
4
+ const PUBLIC_ROUTER_TABLE_LOGICAL_ID = "PublicRouteTable";
5
+ const PRIVATE_ROUTER_TABLE_LOGICAL_ID = "PrivateRouteTable";
6
+ const createVpcTemplate = ({
13
7
  cidrBlock,
14
8
  createPublicSubnets = true
15
9
  }) => {
16
10
  const totalOfSubnetsOnEachType = 2;
17
- const getSubnetResource = /* @__PURE__ */__name(({
11
+ const getSubnetResource = ({
18
12
  number,
19
13
  isPublic
20
14
  }) => {
@@ -22,10 +16,16 @@ var createVpcTemplate = /* @__PURE__ */__name(({
22
16
  const key = `${subnetType}Subnet${number}`;
23
17
  const routerTableAssociationKey = `${subnetType}Subnet${number}RouteTableAssociation`;
24
18
  const index = (isPublic ? 0 : 1) * totalOfSubnetsOnEachType + number - 1;
19
+ /**
20
+ * It's because AWS infrastructure has a minimum of 3 availability zones
21
+ * in each region. So, we need to calculate the index of the availability
22
+ * zone based on the number of subnets and the type of subnet.
23
+ *
24
+ * https://aws.amazon.com/about-aws/global-infrastructure/regions_az/
25
+ */
25
26
  const azIndex = index % NUMBER_OF_AVAILABILITY_ZONES;
26
27
  const cidrSubBlockCount = 2 * totalOfSubnetsOnEachType;
27
- const cidrPrefixLength = parseInt(cidrBlock.split("/")[1], 10);
28
- const cidrSubBlockBits = 32 - cidrPrefixLength - Math.ceil(Math.log2(cidrSubBlockCount));
28
+ const cidrSubBlockBits = 32 - parseInt(cidrBlock.split("/")[1], 10) - Math.ceil(Math.log2(cidrSubBlockCount));
29
29
  let resources = {
30
30
  [key]: {
31
31
  Type: "AWS::EC2::Subnet",
@@ -64,18 +64,14 @@ var createVpcTemplate = /* @__PURE__ */__name(({
64
64
  }
65
65
  }
66
66
  };
67
- if (isPublic) {
68
- resources = {
69
- ...resources
70
- };
71
- }
72
- if (!isPublic) {
73
- resources = {
74
- ...resources
75
- };
76
- }
67
+ if (isPublic) resources = {
68
+ ...resources
69
+ };
70
+ if (!isPublic) resources = {
71
+ ...resources
72
+ };
77
73
  return resources;
78
- }, "getSubnetResource");
74
+ };
79
75
  const template = {
80
76
  AWSTemplateFormatVersion: "2010-09-09",
81
77
  Description: "VPC, Subnets, and Route Tables for the project.",
@@ -228,5 +224,7 @@ var createVpcTemplate = /* @__PURE__ */__name(({
228
224
  };
229
225
  }
230
226
  return template;
231
- }, "createVpcTemplate");
227
+ };
228
+
229
+ //#endregion
232
230
  export { createVpcTemplate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/cloud-vpc",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "description": "Deploy a VPC with public and private subnets",
5
5
  "keywords": [
6
6
  "aws",
@@ -28,21 +28,21 @@
28
28
  "dist"
29
29
  ],
30
30
  "dependencies": {
31
- "@ttoss/cloudformation": "^0.13.3"
31
+ "@ttoss/cloudformation": "^0.13.5"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/jest": "^30.0.0",
35
35
  "jest": "^30.3.0",
36
- "tsup": "^8.5.1",
37
- "@ttoss/config": "^1.37.11",
38
- "@ttoss/test-utils": "^4.2.11"
36
+ "tsdown": "^0.22.0",
37
+ "@ttoss/test-utils": "^4.2.13",
38
+ "@ttoss/config": "^1.37.13"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public",
42
42
  "provenance": true
43
43
  },
44
44
  "scripts": {
45
- "build": "tsup",
45
+ "build": "tsdown",
46
46
  "test": "jest --projects tests/unit"
47
47
  }
48
48
  }
package/dist/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { CloudFormationTemplate } from '@ttoss/cloudformation';
2
- export { CloudFormationTemplate } from '@ttoss/cloudformation';
3
-
4
- declare const createVpcTemplate: ({ cidrBlock, createPublicSubnets, }: {
5
- cidrBlock: string;
6
- createPublicSubnets?: boolean;
7
- }) => CloudFormationTemplate;
8
-
9
- export { createVpcTemplate };