alchemy 0.54.0 → 0.55.1

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.
Files changed (102) hide show
  1. package/bin/alchemy.js +38717 -11847
  2. package/lib/aws/ec2/index.d.ts +10 -0
  3. package/lib/aws/ec2/index.d.ts.map +1 -0
  4. package/lib/aws/ec2/index.js +10 -0
  5. package/lib/aws/ec2/index.js.map +1 -0
  6. package/lib/aws/ec2/internet-gateway-attachment.d.ts +150 -0
  7. package/lib/aws/ec2/internet-gateway-attachment.d.ts.map +1 -0
  8. package/lib/aws/ec2/internet-gateway-attachment.js +248 -0
  9. package/lib/aws/ec2/internet-gateway-attachment.js.map +1 -0
  10. package/lib/aws/ec2/internet-gateway.d.ts +132 -0
  11. package/lib/aws/ec2/internet-gateway.d.ts.map +1 -0
  12. package/lib/aws/ec2/internet-gateway.js +311 -0
  13. package/lib/aws/ec2/internet-gateway.js.map +1 -0
  14. package/lib/aws/ec2/nat-gateway.d.ts +145 -0
  15. package/lib/aws/ec2/nat-gateway.d.ts.map +1 -0
  16. package/lib/aws/ec2/nat-gateway.js +618 -0
  17. package/lib/aws/ec2/nat-gateway.js.map +1 -0
  18. package/lib/aws/ec2/route-table-association.d.ts +134 -0
  19. package/lib/aws/ec2/route-table-association.d.ts.map +1 -0
  20. package/lib/aws/ec2/route-table-association.js +364 -0
  21. package/lib/aws/ec2/route-table-association.js.map +1 -0
  22. package/lib/aws/ec2/route-table.d.ts +94 -0
  23. package/lib/aws/ec2/route-table.d.ts.map +1 -0
  24. package/lib/aws/ec2/route-table.js +253 -0
  25. package/lib/aws/ec2/route-table.js.map +1 -0
  26. package/lib/aws/ec2/route.d.ts +130 -0
  27. package/lib/aws/ec2/route.d.ts.map +1 -0
  28. package/lib/aws/ec2/route.js +253 -0
  29. package/lib/aws/ec2/route.js.map +1 -0
  30. package/lib/aws/ec2/security-group-rule.d.ts +84 -0
  31. package/lib/aws/ec2/security-group-rule.d.ts.map +1 -0
  32. package/lib/aws/ec2/security-group-rule.js +123 -0
  33. package/lib/aws/ec2/security-group-rule.js.map +1 -0
  34. package/lib/aws/ec2/security-group.d.ts +84 -0
  35. package/lib/aws/ec2/security-group.d.ts.map +1 -0
  36. package/lib/aws/ec2/security-group.js +207 -0
  37. package/lib/aws/ec2/security-group.js.map +1 -0
  38. package/lib/aws/ec2/subnet.d.ts +110 -0
  39. package/lib/aws/ec2/subnet.d.ts.map +1 -0
  40. package/lib/aws/ec2/subnet.js +336 -0
  41. package/lib/aws/ec2/subnet.js.map +1 -0
  42. package/lib/aws/ec2/utils.d.ts +15 -0
  43. package/lib/aws/ec2/utils.d.ts.map +1 -0
  44. package/lib/aws/ec2/utils.js +79 -0
  45. package/lib/aws/ec2/utils.js.map +1 -0
  46. package/lib/aws/ec2/vpc.d.ts +160 -0
  47. package/lib/aws/ec2/vpc.d.ts.map +1 -0
  48. package/lib/aws/ec2/vpc.js +453 -0
  49. package/lib/aws/ec2/vpc.js.map +1 -0
  50. package/lib/aws/index.d.ts +7 -0
  51. package/lib/aws/index.d.ts.map +1 -1
  52. package/lib/aws/index.js +8 -0
  53. package/lib/aws/index.js.map +1 -1
  54. package/lib/aws/utils.d.ts +25 -0
  55. package/lib/aws/utils.d.ts.map +1 -0
  56. package/lib/aws/utils.js +89 -0
  57. package/lib/aws/utils.js.map +1 -0
  58. package/lib/build-date.d.ts +6 -0
  59. package/lib/build-date.d.ts.map +1 -0
  60. package/lib/build-date.js +8 -0
  61. package/lib/build-date.js.map +1 -0
  62. package/lib/cloudflare/worker-metadata.d.ts +1 -1
  63. package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
  64. package/lib/cloudflare/worker-metadata.js +1 -0
  65. package/lib/cloudflare/worker-metadata.js.map +1 -1
  66. package/lib/cloudflare/worker.d.ts +0 -2
  67. package/lib/cloudflare/worker.d.ts.map +1 -1
  68. package/lib/cloudflare/worker.js +1 -1
  69. package/lib/cloudflare/worker.js.map +1 -1
  70. package/lib/util/params.d.ts +5 -0
  71. package/lib/util/params.d.ts.map +1 -0
  72. package/lib/util/params.js +30 -0
  73. package/lib/util/params.js.map +1 -0
  74. package/lib/util/timeout.d.ts +31 -0
  75. package/lib/util/timeout.d.ts.map +1 -0
  76. package/lib/util/timeout.js +109 -0
  77. package/lib/util/timeout.js.map +1 -0
  78. package/lib/util/xml.d.ts +5 -0
  79. package/lib/util/xml.d.ts.map +1 -0
  80. package/lib/util/xml.js +8 -0
  81. package/lib/util/xml.js.map +1 -0
  82. package/package.json +7 -5
  83. package/src/aws/ec2/index.ts +9 -0
  84. package/src/aws/ec2/internet-gateway-attachment.ts +468 -0
  85. package/src/aws/ec2/internet-gateway.ts +557 -0
  86. package/src/aws/ec2/nat-gateway.ts +1123 -0
  87. package/src/aws/ec2/route-table-association.ts +747 -0
  88. package/src/aws/ec2/route-table.ts +452 -0
  89. package/src/aws/ec2/route.ts +447 -0
  90. package/src/aws/ec2/security-group-rule.ts +229 -0
  91. package/src/aws/ec2/security-group.ts +418 -0
  92. package/src/aws/ec2/subnet.ts +625 -0
  93. package/src/aws/ec2/utils.ts +102 -0
  94. package/src/aws/ec2/vpc.ts +969 -0
  95. package/src/aws/index.ts +9 -0
  96. package/src/aws/utils.ts +137 -0
  97. package/src/build-date.ts +8 -0
  98. package/src/cloudflare/worker-metadata.ts +1 -1
  99. package/src/cloudflare/worker.ts +1 -1
  100. package/src/util/params.ts +33 -0
  101. package/src/util/timeout.ts +178 -0
  102. package/src/util/xml.ts +7 -0
@@ -0,0 +1,84 @@
1
+ import type { Context } from "../../context.ts";
2
+ import { Resource } from "../../resource.ts";
3
+ import type { SecurityGroup } from "./security-group.ts";
4
+ /**
5
+ * Properties for creating or updating a Security Group Rule
6
+ */
7
+ export interface SecurityGroupRuleProps {
8
+ /**
9
+ * The security group to apply the rule to.
10
+ */
11
+ securityGroup: SecurityGroup | string;
12
+ /**
13
+ * The type of rule, either 'ingress' (inbound) or 'egress' (outbound).
14
+ */
15
+ type: "ingress" | "egress";
16
+ /**
17
+ * The IP protocol name (tcp, udp, icmp, icmpv6) or number.
18
+ * Use '-1' to specify all protocols.
19
+ */
20
+ protocol: string;
21
+ /**
22
+ * The start of the port range for the rule.
23
+ * For ICMP, this is the ICMP type number. A value of -1 indicates all types.
24
+ */
25
+ fromPort: number;
26
+ /**
27
+ * The end of the port range for the rule.
28
+ * For ICMP, this is the ICMP code. A value of -1 indicates all codes.
29
+ */
30
+ toPort: number;
31
+ /**
32
+ * The IPv4 CIDR ranges to allow.
33
+ */
34
+ cidrBlocks?: string[];
35
+ /**
36
+ * The source security group IDs to allow.
37
+ */
38
+ sourceSecurityGroups?: (SecurityGroup | string)[];
39
+ /**
40
+ * A description for the rule.
41
+ */
42
+ description?: string;
43
+ }
44
+ /**
45
+ * Output returned after Security Group Rule creation/update
46
+ */
47
+ export interface SecurityGroupRule extends Resource<"aws::SecurityGroupRule">, SecurityGroupRuleProps {
48
+ /**
49
+ * A unique identifier for the rule resource.
50
+ */
51
+ ruleId: string;
52
+ }
53
+ /**
54
+ * AWS Security Group Rule Resource
55
+ *
56
+ * Manages a single ingress or egress rule for a security group.
57
+ *
58
+ * @example
59
+ * // A rule to allow HTTP traffic from anywhere
60
+ * const httpRule = await SecurityGroupRule("web-sg-http-rule", {
61
+ * securityGroup: webSecurityGroup,
62
+ * type: "ingress",
63
+ * protocol: "tcp",
64
+ * fromPort: 80,
65
+ * toPort: 80,
66
+ * cidrBlocks: ["0.0.0.0/0"],
67
+ * description: "Allow HTTP access from anywhere"
68
+ * });
69
+ *
70
+ * @example
71
+ * // A rule to allow a database security group to receive traffic
72
+ * // from a web server security group on the MySQL port.
73
+ * const dbAccessRule = await SecurityGroupRule("db-access-from-web", {
74
+ * securityGroup: dbSecurityGroup,
75
+ * type: "ingress",
76
+ * protocol: "tcp",
77
+ * fromPort: 3306,
78
+ * toPort: 3306,
79
+ * sourceSecurityGroups: [webSecurityGroup],
80
+ * description: "Allow MySQL access from web servers"
81
+ * });
82
+ */
83
+ export declare const SecurityGroupRule: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<SecurityGroupRule>, _id: string, props: SecurityGroupRuleProps) => Promise<SecurityGroupRule>);
84
+ //# sourceMappingURL=security-group-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-group-rule.d.ts","sourceRoot":"","sources":["../../../src/aws/ec2/security-group-rule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,aAAa,EAAE,aAAa,GAAG,MAAM,CAAC;IAEtC;;OAEG;IACH,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAE3B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB;;OAEG;IACH,oBAAoB,CAAC,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC;IAElD;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBACf,SAAQ,QAAQ,CAAC,wBAAwB,CAAC,EACxC,sBAAsB;IACxB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,iBAAiB,yFAGpB,OAAO,CAAC,iBAAiB,CAAC,OAC3B,MAAM,SACJ,sBAAsB,KAC5B,OAAO,CAAC,iBAAiB,CAAC,CA4D9B,CAAC"}
@@ -0,0 +1,123 @@
1
+ import { XMLParser } from "fast-xml-parser";
2
+ import { Resource } from "../../resource.js";
3
+ import { ignore } from "../../util/ignore.js";
4
+ import { callEC2Api, createEC2Client } from "./utils.js";
5
+ /**
6
+ * AWS Security Group Rule Resource
7
+ *
8
+ * Manages a single ingress or egress rule for a security group.
9
+ *
10
+ * @example
11
+ * // A rule to allow HTTP traffic from anywhere
12
+ * const httpRule = await SecurityGroupRule("web-sg-http-rule", {
13
+ * securityGroup: webSecurityGroup,
14
+ * type: "ingress",
15
+ * protocol: "tcp",
16
+ * fromPort: 80,
17
+ * toPort: 80,
18
+ * cidrBlocks: ["0.0.0.0/0"],
19
+ * description: "Allow HTTP access from anywhere"
20
+ * });
21
+ *
22
+ * @example
23
+ * // A rule to allow a database security group to receive traffic
24
+ * // from a web server security group on the MySQL port.
25
+ * const dbAccessRule = await SecurityGroupRule("db-access-from-web", {
26
+ * securityGroup: dbSecurityGroup,
27
+ * type: "ingress",
28
+ * protocol: "tcp",
29
+ * fromPort: 3306,
30
+ * toPort: 3306,
31
+ * sourceSecurityGroups: [webSecurityGroup],
32
+ * description: "Allow MySQL access from web servers"
33
+ * });
34
+ */
35
+ export const SecurityGroupRule = Resource("aws::SecurityGroupRule", async function (_id, props) {
36
+ const client = await createEC2Client();
37
+ const groupId = typeof props.securityGroup === "string"
38
+ ? props.securityGroup
39
+ : props.securityGroup.groupId;
40
+ // A deterministic ID for the rule based on its properties
41
+ const ruleId = `${groupId}-${props.type}-${props.protocol}-${props.fromPort}-${props.toPort}-${(props.cidrBlocks || []).join("-")}-${(props.sourceSecurityGroups || [])
42
+ .map((sg) => (typeof sg === "string" ? sg : sg.groupId))
43
+ .join("-")}`;
44
+ if (this.phase === "delete") {
45
+ const revokeParams = convertRuleToApiParams(props, groupId);
46
+ const action = props.type === "ingress"
47
+ ? "RevokeSecurityGroupIngress"
48
+ : "RevokeSecurityGroupEgress";
49
+ // Ignore errors if the rule doesn't exist, as it's already deleted.
50
+ await ignore("InvalidPermission.NotFound", async () => {
51
+ await callEC2Api(client, action, parseSecurityGroupRuleXmlResponse, revokeParams);
52
+ });
53
+ return this.destroy();
54
+ }
55
+ // For both create and update, we authorize the rule.
56
+ // The resource framework handles replacement by calling delete then create.
57
+ // The AuthorizeSecurityGroup* API calls are idempotent, so calling this on
58
+ // an existing rule will not cause an error.
59
+ const authorizeParams = convertRuleToApiParams(props, groupId);
60
+ const action = props.type === "ingress"
61
+ ? "AuthorizeSecurityGroupIngress"
62
+ : "AuthorizeSecurityGroupEgress";
63
+ // There is no "pending" state for a security group rule. The API call
64
+ // is synchronous, and success is determined by the response.
65
+ await callEC2Api(client, action, parseSecurityGroupRuleXmlResponse, authorizeParams);
66
+ return this({
67
+ ruleId,
68
+ ...props,
69
+ });
70
+ });
71
+ // --- Helper Functions and Interfaces ---
72
+ /**
73
+ * Parse XML responses for Security Group Rule operations
74
+ */
75
+ function parseSecurityGroupRuleXmlResponse(xmlText) {
76
+ const parser = new XMLParser({
77
+ ignoreAttributes: true,
78
+ parseAttributeValue: true,
79
+ parseTagValue: true,
80
+ });
81
+ const parsed = parser.parse(xmlText);
82
+ const result = {};
83
+ if (parsed.AuthorizeSecurityGroupIngressResponse ||
84
+ parsed.AuthorizeSecurityGroupEgressResponse ||
85
+ parsed.RevokeSecurityGroupIngressResponse ||
86
+ parsed.RevokeSecurityGroupEgressResponse) {
87
+ result.success = parsed.return === "true" || parsed.return === true;
88
+ }
89
+ return result;
90
+ }
91
+ /**
92
+ * Convert rule properties to the flat format required by the AWS API.
93
+ */
94
+ function convertRuleToApiParams(props, groupId) {
95
+ const params = {
96
+ GroupId: groupId,
97
+ "IpPermissions.1.IpProtocol": props.protocol,
98
+ "IpPermissions.1.FromPort": props.fromPort.toString(),
99
+ "IpPermissions.1.ToPort": props.toPort.toString(),
100
+ };
101
+ const prefix = "IpPermissions.1";
102
+ if (props.cidrBlocks && props.cidrBlocks.length > 0) {
103
+ props.cidrBlocks.forEach((cidr, index) => {
104
+ const rangePrefix = `${prefix}.IpRanges.${index + 1}`;
105
+ params[`${rangePrefix}.CidrIp`] = cidr;
106
+ if (props.description) {
107
+ params[`${rangePrefix}.Description`] = props.description;
108
+ }
109
+ });
110
+ }
111
+ if (props.sourceSecurityGroups && props.sourceSecurityGroups.length > 0) {
112
+ props.sourceSecurityGroups.forEach((sg, index) => {
113
+ const groupPrefix = `${prefix}.UserIdGroupPairs.${index + 1}`;
114
+ params[`${groupPrefix}.GroupId`] =
115
+ typeof sg === "string" ? sg : sg.groupId;
116
+ if (props.description) {
117
+ params[`${groupPrefix}.Description`] = props.description;
118
+ }
119
+ });
120
+ }
121
+ return params;
122
+ }
123
+ //# sourceMappingURL=security-group-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-group-rule.js","sourceRoot":"","sources":["../../../src/aws/ec2/security-group-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA8DzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CACvC,wBAAwB,EACxB,KAAK,WAEH,GAAW,EACX,KAA6B;IAE7B,MAAM,MAAM,GAAG,MAAM,eAAe,EAAE,CAAC;IACvC,MAAM,OAAO,GACX,OAAO,KAAK,CAAC,aAAa,KAAK,QAAQ;QACrC,CAAC,CAAC,KAAK,CAAC,aAAa;QACrB,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;IAElC,0DAA0D;IAC1D,MAAM,MAAM,GAAG,GAAG,OAAO,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,QAAQ,IACvD,KAAK,CAAC,QACR,IAAI,KAAK,CAA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CAAC;gBACtB,MAAM,CAAC,GAAG,WAAW,cAAc,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC;YAC3D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,KAAK,CAAC,oBAAoB,IAAI,KAAK,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxE,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;YAC/C,MAAM,WAAW,GAAG,GAAG,MAAM,qBAAqB,KAAK,GAAG,CAAC,EAAE,CAAC;YAC9D,MAAM,CAAC,GAAG,WAAW,UAAU,CAAC;gBAC9B,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC;YAC3C,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;gBACtB,MAAM,CAAC,GAAG,WAAW,cAAc,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC;YAC3D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,84 @@
1
+ import type { Context } from "../../context.ts";
2
+ import { Resource } from "../../resource.ts";
3
+ import { type TimeoutConfig } from "../../util/timeout.ts";
4
+ import type { Vpc } from "./vpc.ts";
5
+ /**
6
+ * Security Group timeout constants
7
+ */
8
+ export declare const SECURITY_GROUP_TIMEOUT: TimeoutConfig;
9
+ /**
10
+ * Properties for creating or updating a Security Group
11
+ */
12
+ export interface SecurityGroupProps {
13
+ /**
14
+ * The VPC to create the security group in.
15
+ */
16
+ vpc: Vpc | string;
17
+ /**
18
+ * The name of the security group.
19
+ */
20
+ groupName: string;
21
+ /**
22
+ * The description of the security group.
23
+ */
24
+ description: string;
25
+ /**
26
+ * Tags to apply to the security group.
27
+ */
28
+ tags?: Record<string, string>;
29
+ /**
30
+ * Timeout configuration for Security Group operations.
31
+ * @default Security Group-specific sensible defaults (30 attempts, 1000ms delay)
32
+ */
33
+ timeout?: Partial<TimeoutConfig>;
34
+ }
35
+ /**
36
+ * Output returned after Security Group creation/update
37
+ */
38
+ export interface SecurityGroup extends Resource<"aws::SecurityGroup">, SecurityGroupProps {
39
+ /**
40
+ * The ID of the security group.
41
+ */
42
+ groupId: string;
43
+ /**
44
+ * The ID of the VPC the security group belongs to.
45
+ */
46
+ vpcId: string;
47
+ /**
48
+ * The AWS account ID that owns the security group.
49
+ */
50
+ ownerId: string;
51
+ }
52
+ /**
53
+ * AWS Security Group Resource
54
+ *
55
+ * Creates and manages security groups. Acts as a virtual firewall for EC2
56
+ * instances and other AWS resources. Rules are managed separately using the
57
+ * `SecurityGroupRule` resource.
58
+ *
59
+ * @example
60
+ * // Create a web server security group
61
+ * const webSecurityGroup = await SecurityGroup("web-sg", {
62
+ * vpc: mainVpc,
63
+ * groupName: "web-server-sg",
64
+ * description: "Security group for web servers",
65
+ * tags: {
66
+ * Name: "web-server-security-group",
67
+ * Environment: "production"
68
+ * }
69
+ * });
70
+ *
71
+ * @example
72
+ * // Separately, define a rule to allow HTTP traffic
73
+ * const httpRule = await SecurityGroupRule("web-sg-http-rule", {
74
+ * securityGroup: webSecurityGroup,
75
+ * type: "ingress",
76
+ * protocol: "tcp",
77
+ * fromPort: 80,
78
+ * toPort: 80,
79
+ * cidrBlocks: ["0.0.0.0/0"],
80
+ * description: "Allow HTTP access from anywhere"
81
+ * });
82
+ */
83
+ export declare const SecurityGroup: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<SecurityGroup>, _id: string, props: SecurityGroupProps) => Promise<SecurityGroup>);
84
+ //# sourceMappingURL=security-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-group.d.ts","sourceRoot":"","sources":["../../../src/aws/ec2/security-group.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAGpC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,aACf,SAAQ,QAAQ,CAAC,oBAAoB,CAAC,EACpC,kBAAkB;IACpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,aAAa,yFAGhB,OAAO,CAAC,aAAa,CAAC,OACvB,MAAM,SACJ,kBAAkB,KACxB,OAAO,CAAC,aAAa,CAAC,CAoH1B,CAAC"}
@@ -0,0 +1,207 @@
1
+ import { XMLParser } from "fast-xml-parser";
2
+ import { Resource } from "../../resource.js";
3
+ import { ignore } from "../../util/ignore.js";
4
+ import { mergeTimeoutConfig, waitForResourceState, } from "../../util/timeout.js";
5
+ import { callEC2Api, createEC2Client } from "./utils.js";
6
+ /**
7
+ * Security Group timeout constants
8
+ */
9
+ export const SECURITY_GROUP_TIMEOUT = {
10
+ maxAttempts: 30,
11
+ delayMs: 1000, // 1 second - Security Groups are fast resources
12
+ };
13
+ /**
14
+ * AWS Security Group Resource
15
+ *
16
+ * Creates and manages security groups. Acts as a virtual firewall for EC2
17
+ * instances and other AWS resources. Rules are managed separately using the
18
+ * `SecurityGroupRule` resource.
19
+ *
20
+ * @example
21
+ * // Create a web server security group
22
+ * const webSecurityGroup = await SecurityGroup("web-sg", {
23
+ * vpc: mainVpc,
24
+ * groupName: "web-server-sg",
25
+ * description: "Security group for web servers",
26
+ * tags: {
27
+ * Name: "web-server-security-group",
28
+ * Environment: "production"
29
+ * }
30
+ * });
31
+ *
32
+ * @example
33
+ * // Separately, define a rule to allow HTTP traffic
34
+ * const httpRule = await SecurityGroupRule("web-sg-http-rule", {
35
+ * securityGroup: webSecurityGroup,
36
+ * type: "ingress",
37
+ * protocol: "tcp",
38
+ * fromPort: 80,
39
+ * toPort: 80,
40
+ * cidrBlocks: ["0.0.0.0/0"],
41
+ * description: "Allow HTTP access from anywhere"
42
+ * });
43
+ */
44
+ export const SecurityGroup = Resource("aws::SecurityGroup", async function (_id, props) {
45
+ const client = await createEC2Client();
46
+ const vpcId = typeof props.vpc === "string" ? props.vpc : props.vpc.vpcId;
47
+ const timeoutConfig = mergeTimeoutConfig(SECURITY_GROUP_TIMEOUT, props.timeout);
48
+ if (this.phase === "delete") {
49
+ if (this.output?.groupId) {
50
+ console.log(`🗑️ Deleting Security Group: ${this.output.groupId}`);
51
+ await ignore(["InvalidGroupId.NotFound", "DependencyViolation"], async () => {
52
+ await callEC2Api(client, "DeleteSecurityGroup", parseSecurityGroupXmlResponse, {
53
+ GroupId: this.output.groupId,
54
+ });
55
+ });
56
+ await waitForSecurityGroupDeleted(client, this.output.groupId, timeoutConfig);
57
+ console.log(` ✅ Security Group ${this.output.groupId} deletion completed`);
58
+ }
59
+ return this.destroy();
60
+ }
61
+ let securityGroup;
62
+ if (this.phase === "update" && this.output?.groupId) {
63
+ // Get existing security group
64
+ const response = await callEC2Api(client, "DescribeSecurityGroups", parseSecurityGroupXmlResponse, {
65
+ "GroupId.1": this.output.groupId,
66
+ });
67
+ if (!response.SecurityGroups?.[0]) {
68
+ throw new Error(`Security Group ${this.output.groupId} not found`);
69
+ }
70
+ securityGroup = response.SecurityGroups[0];
71
+ }
72
+ else {
73
+ // Create new security group
74
+ const createParams = {
75
+ GroupName: props.groupName,
76
+ GroupDescription: props.description,
77
+ VpcId: vpcId,
78
+ };
79
+ // Add tags if specified
80
+ if (props.tags) {
81
+ createParams.TagSpecifications = [
82
+ {
83
+ ResourceType: "security-group",
84
+ Tags: Object.entries(props.tags).map(([Key, Value]) => ({
85
+ Key,
86
+ Value,
87
+ })),
88
+ },
89
+ ];
90
+ }
91
+ const response = await callEC2Api(client, "CreateSecurityGroup", parseSecurityGroupXmlResponse, convertCreateSecurityGroupParamsToAwsFormat(createParams));
92
+ if (!response.GroupId) {
93
+ throw new Error("Failed to create security group");
94
+ }
95
+ // Wait for the security group to be available
96
+ await waitForSecurityGroupAvailable(client, response.GroupId, timeoutConfig);
97
+ // Get the full security group details
98
+ const sgResponse = await callEC2Api(client, "DescribeSecurityGroups", parseSecurityGroupXmlResponse, {
99
+ "GroupId.1": response.GroupId,
100
+ });
101
+ if (!sgResponse.SecurityGroups?.[0]) {
102
+ throw new Error("Failed to retrieve created security group");
103
+ }
104
+ securityGroup = sgResponse.SecurityGroups[0];
105
+ }
106
+ return this({
107
+ groupId: securityGroup.GroupId,
108
+ vpcId: securityGroup.VpcId,
109
+ ownerId: securityGroup.OwnerId,
110
+ ...props,
111
+ vpc: vpcId,
112
+ });
113
+ });
114
+ /**
115
+ * Parse XML responses specifically for Security Group operations
116
+ */
117
+ function parseSecurityGroupXmlResponse(xmlText) {
118
+ const parser = new XMLParser({
119
+ ignoreAttributes: true,
120
+ parseAttributeValue: true,
121
+ parseTagValue: true,
122
+ trimValues: true,
123
+ });
124
+ const parsed = parser.parse(xmlText);
125
+ const result = {};
126
+ if (parsed.CreateSecurityGroupResponse) {
127
+ result.GroupId = parsed.CreateSecurityGroupResponse.groupId;
128
+ }
129
+ if (parsed.DescribeSecurityGroupsResponse) {
130
+ const securityGroupSet = parsed.DescribeSecurityGroupsResponse.securityGroupInfo;
131
+ if (securityGroupSet?.item) {
132
+ const securityGroups = Array.isArray(securityGroupSet.item)
133
+ ? securityGroupSet.item
134
+ : [securityGroupSet.item];
135
+ result.SecurityGroups = securityGroups.map((sg) => ({
136
+ GroupId: sg.groupId,
137
+ GroupName: sg.groupName,
138
+ Description: sg.groupDescription,
139
+ VpcId: sg.vpcId,
140
+ OwnerId: sg.ownerId,
141
+ }));
142
+ }
143
+ else {
144
+ result.SecurityGroups = [];
145
+ }
146
+ }
147
+ if (parsed.DeleteSecurityGroupResponse) {
148
+ result.success = true;
149
+ }
150
+ return result;
151
+ }
152
+ /**
153
+ * Convert CreateSecurityGroupParams to the format required by the AWS API.
154
+ */
155
+ function convertCreateSecurityGroupParamsToAwsFormat(params) {
156
+ const awsParams = {
157
+ GroupName: params.GroupName,
158
+ GroupDescription: params.GroupDescription,
159
+ VpcId: params.VpcId,
160
+ };
161
+ if (params.DryRun !== undefined) {
162
+ awsParams.DryRun = params.DryRun.toString();
163
+ }
164
+ if (params.TagSpecifications) {
165
+ params.TagSpecifications.forEach((tagSpec, specIndex) => {
166
+ const specNum = specIndex + 1;
167
+ awsParams[`TagSpecification.${specNum}.ResourceType`] =
168
+ tagSpec.ResourceType;
169
+ tagSpec.Tags.forEach((tag, tagIndex) => {
170
+ const tagNum = tagIndex + 1;
171
+ awsParams[`TagSpecification.${specNum}.Tag.${tagNum}.Key`] = tag.Key;
172
+ awsParams[`TagSpecification.${specNum}.Tag.${tagNum}.Value`] =
173
+ tag.Value;
174
+ });
175
+ });
176
+ }
177
+ return awsParams;
178
+ }
179
+ /**
180
+ * Wait for a security group to become available.
181
+ */
182
+ async function waitForSecurityGroupAvailable(client, groupId, timeoutConfig) {
183
+ const checkFunction = async () => {
184
+ const response = await callEC2Api(client, "DescribeSecurityGroups", parseSecurityGroupXmlResponse, { "GroupId.1": groupId });
185
+ return response.SecurityGroups?.[0];
186
+ };
187
+ await waitForResourceState(checkFunction, (sg) => !!sg, timeoutConfig, groupId, "Security Group", "to be available");
188
+ }
189
+ /**
190
+ * Wait for a security group to be deleted.
191
+ */
192
+ async function waitForSecurityGroupDeleted(client, groupId, timeoutConfig) {
193
+ const checkFunction = async () => {
194
+ try {
195
+ const response = await callEC2Api(client, "DescribeSecurityGroups", parseSecurityGroupXmlResponse, { "GroupId.1": groupId });
196
+ return response.SecurityGroups?.[0];
197
+ }
198
+ catch (error) {
199
+ if (error.code === "InvalidGroup.NotFound") {
200
+ return undefined;
201
+ }
202
+ throw error;
203
+ }
204
+ };
205
+ await waitForResourceState(checkFunction, (sg) => !sg, timeoutConfig, groupId, "Security Group", "to be deleted");
206
+ }
207
+ //# sourceMappingURL=security-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-group.js","sourceRoot":"","sources":["../../../src/aws/ec2/security-group.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAElB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGzD;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,IAAI,EAAE,gDAAgD;CAChE,CAAC;AAuDF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CACnC,oBAAoB,EACpB,KAAK,WAEH,GAAW,EACX,KAAyB;IAEzB,MAAM,MAAM,GAAG,MAAM,eAAe,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,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E,CAAC,CAAC,EAAE,EACX,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,eAAe,CAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,110 @@
1
+ import type { Context } from "../../context.ts";
2
+ import { Resource } from "../../resource.ts";
3
+ import { type TimeoutConfig } from "../../util/timeout.ts";
4
+ import type { Vpc } from "./vpc.ts";
5
+ /**
6
+ * Properties for creating or updating a Subnet
7
+ */
8
+ export interface SubnetProps {
9
+ /**
10
+ * The VPC to create the subnet in
11
+ */
12
+ vpc: Vpc | string;
13
+ /**
14
+ * The CIDR block for the subnet
15
+ */
16
+ cidrBlock: string;
17
+ /**
18
+ * The availability zone for the subnet
19
+ */
20
+ availabilityZone: string;
21
+ /**
22
+ * Whether instances launched in this subnet should be assigned a public IP address
23
+ * @default false
24
+ */
25
+ mapPublicIpOnLaunch?: boolean;
26
+ /**
27
+ * Tags to apply to the subnet
28
+ */
29
+ tags?: Record<string, string>;
30
+ /**
31
+ * Timeout configuration for subnet operations
32
+ * @default Subnet-specific sensible defaults (30 attempts, 1000ms delay)
33
+ */
34
+ timeout?: Partial<TimeoutConfig>;
35
+ }
36
+ /**
37
+ * Output returned after Subnet creation/update
38
+ */
39
+ export interface Subnet extends Resource<"aws::Subnet">, SubnetProps {
40
+ /**
41
+ * The ID of the subnet
42
+ */
43
+ subnetId: string;
44
+ /**
45
+ * The ID of the VPC the subnet belongs to
46
+ */
47
+ vpcId: string;
48
+ /**
49
+ * The current state of the subnet
50
+ */
51
+ state: "pending" | "available";
52
+ /**
53
+ * The number of available IP addresses in the subnet
54
+ */
55
+ availableIpAddressCount: number;
56
+ /**
57
+ * Whether this is the default subnet for the availability zone
58
+ */
59
+ defaultForAz: boolean;
60
+ }
61
+ /**
62
+ * AWS Subnet Resource
63
+ *
64
+ * Creates and manages subnets within a VPC. Subnets are used to segment
65
+ * your VPC into smaller networks for organizing resources.
66
+ *
67
+ * @example
68
+ * // Create a public subnet for web servers
69
+ * const publicSubnet = await Subnet("public-subnet", {
70
+ * vpc: myVpc,
71
+ * cidrBlock: "10.0.1.0/24",
72
+ * availabilityZone: process.env.AWS_REGION ? `${process.env.AWS_REGION}a` : "us-east-1a",
73
+ * mapPublicIpOnLaunch: true,
74
+ * tags: {
75
+ * Name: "public-subnet",
76
+ * Type: "public"
77
+ * }
78
+ * });
79
+ *
80
+ * @example
81
+ * // Create a private subnet for databases
82
+ * const privateSubnet = await Subnet("private-subnet", {
83
+ * vpc: myVpc,
84
+ * cidrBlock: "10.0.2.0/24",
85
+ * availabilityZone: "us-west-2b",
86
+ * mapPublicIpOnLaunch: false,
87
+ * tags: {
88
+ * Name: "private-subnet",
89
+ * Type: "private"
90
+ * }
91
+ * });
92
+ *
93
+ * @example
94
+ * // Create a subnet with custom timeout configuration
95
+ * const customSubnet = await Subnet("custom-subnet", {
96
+ * vpc: myVpc,
97
+ * cidrBlock: "10.0.3.0/24",
98
+ * availabilityZone: "us-west-2c",
99
+ * timeout: {
100
+ * maxAttempts: 50,
101
+ * delayMs: 500
102
+ * }
103
+ * });
104
+ */
105
+ export declare const Subnet: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<Subnet>, _id: string, props: SubnetProps) => Promise<Subnet>);
106
+ /**
107
+ * Subnet timeout constants
108
+ */
109
+ export declare const SUBNET_TIMEOUT: TimeoutConfig;
110
+ //# sourceMappingURL=subnet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subnet.d.ts","sourceRoot":"","sources":["../../../src/aws/ec2/subnet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG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