@ttoss/cloud-vpc 0.1.48 → 0.1.50
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/{index.js → index.cjs} +27 -56
- package/dist/index.d.cts +13 -0
- package/dist/index.d.mts +11 -7
- package/dist/{esm/index.js → index.mjs} +24 -26
- package/package.json +9 -9
- package/dist/index.d.ts +0 -9
|
@@ -1,48 +1,18 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 =
|
|
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
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
});
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
//#endregion
|
|
234
|
+
exports.createVpcTemplate = createVpcTemplate;
|
package/dist/index.d.cts
ADDED
|
@@ -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
|
-
|
|
5
|
-
cidrBlock: string;
|
|
6
|
-
createPublicSubnets?: boolean;
|
|
7
|
-
}) => CloudFormationTemplate;
|
|
2
|
+
import { CloudFormationTemplate } from "@ttoss/cloudformation";
|
|
8
3
|
|
|
9
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 =
|
|
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
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"description": "Deploy a VPC with public and private subnets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aws",
|
|
@@ -19,30 +19,30 @@
|
|
|
19
19
|
],
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"import": "./dist/
|
|
23
|
-
"require": "./dist/index.
|
|
24
|
-
"types": "./dist/index.d.
|
|
22
|
+
"import": "./dist/index.mjs",
|
|
23
|
+
"require": "./dist/index.cjs",
|
|
24
|
+
"types": "./dist/index.d.mts"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ttoss/cloudformation": "^0.13.
|
|
31
|
+
"@ttoss/cloudformation": "^0.13.6"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/jest": "^30.0.0",
|
|
35
35
|
"jest": "^30.3.0",
|
|
36
|
-
"
|
|
37
|
-
"@ttoss/
|
|
38
|
-
"@ttoss/
|
|
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": "
|
|
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 };
|