alchemy 0.60.2 → 0.62.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/README.md +1 -2
- package/bin/alchemy.js +1480 -1498
- package/bin/commands/init.ts +94 -25
- package/bin/services/execute-alchemy.ts +32 -23
- package/lib/alchemy.d.ts +2 -2
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +1 -0
- package/lib/alchemy.js.map +1 -1
- package/lib/aws/client-props.d.ts +149 -0
- package/lib/aws/client-props.d.ts.map +1 -0
- package/lib/aws/client-props.js +1 -0
- package/lib/aws/client-props.js.map +1 -0
- package/lib/aws/credentials.d.ts +68 -5
- package/lib/aws/credentials.d.ts.map +1 -1
- package/lib/aws/credentials.js +148 -0
- package/lib/aws/credentials.js.map +1 -1
- package/lib/aws/ec2/internet-gateway-attachment.d.ts +57 -3
- package/lib/aws/ec2/internet-gateway-attachment.d.ts.map +1 -1
- package/lib/aws/ec2/internet-gateway-attachment.js +57 -3
- package/lib/aws/ec2/internet-gateway-attachment.js.map +1 -1
- package/lib/aws/ec2/internet-gateway.d.ts +68 -40
- package/lib/aws/ec2/internet-gateway.d.ts.map +1 -1
- package/lib/aws/ec2/internet-gateway.js +68 -40
- package/lib/aws/ec2/internet-gateway.js.map +1 -1
- package/lib/aws/ec2/nat-gateway.d.ts +99 -18
- package/lib/aws/ec2/nat-gateway.d.ts.map +1 -1
- package/lib/aws/ec2/nat-gateway.js +113 -37
- package/lib/aws/ec2/nat-gateway.js.map +1 -1
- package/lib/aws/ec2/route-table-association.d.ts +1 -1
- package/lib/aws/ec2/route-table-association.js +1 -1
- package/lib/aws/ec2/route-table.d.ts +64 -1
- package/lib/aws/ec2/route-table.d.ts.map +1 -1
- package/lib/aws/ec2/route-table.js +64 -1
- package/lib/aws/ec2/route-table.js.map +1 -1
- package/lib/aws/ec2/route.d.ts +60 -1
- package/lib/aws/ec2/route.d.ts.map +1 -1
- package/lib/aws/ec2/route.js +60 -1
- package/lib/aws/ec2/route.js.map +1 -1
- package/lib/aws/ec2/security-group.d.ts +96 -3
- package/lib/aws/ec2/security-group.d.ts.map +1 -1
- package/lib/aws/ec2/security-group.js +96 -3
- package/lib/aws/ec2/security-group.js.map +1 -1
- package/lib/aws/ec2/subnet.d.ts +61 -3
- package/lib/aws/ec2/subnet.d.ts.map +1 -1
- package/lib/aws/ec2/subnet.js +61 -3
- package/lib/aws/ec2/subnet.js.map +1 -1
- package/lib/aws/ec2/utils.d.ts +10 -2
- package/lib/aws/ec2/utils.d.ts.map +1 -1
- package/lib/aws/ec2/utils.js +68 -7
- package/lib/aws/ec2/utils.js.map +1 -1
- package/lib/aws/ec2/vpc.d.ts +50 -2
- package/lib/aws/ec2/vpc.d.ts.map +1 -1
- package/lib/aws/ec2/vpc.js +50 -2
- package/lib/aws/ec2/vpc.js.map +1 -1
- package/lib/aws/index.d.ts +2 -0
- package/lib/aws/index.d.ts.map +1 -1
- package/lib/aws/index.js +2 -0
- package/lib/aws/index.js.map +1 -1
- package/lib/cloudflare/api-response.js +2 -2
- package/lib/cloudflare/api-response.js.map +1 -1
- package/lib/cloudflare/api.d.ts +19 -0
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +4 -0
- package/lib/cloudflare/api.js.map +1 -1
- package/lib/cloudflare/assets.d.ts.map +1 -1
- package/lib/cloudflare/assets.js +3 -4
- package/lib/cloudflare/assets.js.map +1 -1
- package/lib/cloudflare/bucket.d.ts +5 -3
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +28 -20
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/bundle/plugin-compat-warning.js +7 -7
- package/lib/cloudflare/bundle/plugin-compat-warning.js.map +1 -1
- package/lib/cloudflare/cloudflare-env-proxy.js.map +1 -1
- package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
- package/lib/cloudflare/compatibility-date.gen.js +1 -1
- package/lib/cloudflare/d1-migrations.d.ts.map +1 -1
- package/lib/cloudflare/d1-migrations.js +3 -2
- package/lib/cloudflare/d1-migrations.js.map +1 -1
- package/lib/cloudflare/index.d.ts +2 -1
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +2 -1
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/kv-namespace.d.ts +2 -2
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv-namespace.js.map +1 -1
- package/lib/cloudflare/miniflare/build-worker-options.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/build-worker-options.js +16 -3
- package/lib/cloudflare/miniflare/build-worker-options.js.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-controller.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-controller.js +3 -0
- package/lib/cloudflare/miniflare/miniflare-controller.js.map +1 -1
- package/lib/cloudflare/oauth.js +3 -3
- package/lib/cloudflare/oauth.js.map +1 -1
- package/lib/cloudflare/quick-tunnel.d.ts +17 -0
- package/lib/cloudflare/quick-tunnel.d.ts.map +1 -0
- package/lib/cloudflare/quick-tunnel.js +26 -0
- package/lib/cloudflare/quick-tunnel.js.map +1 -0
- package/lib/cloudflare/sveltekit/plugin.d.ts +2 -2
- package/lib/cloudflare/sveltekit/plugin.d.ts.map +1 -1
- package/lib/cloudflare/sveltekit/plugin.js +5 -4
- package/lib/cloudflare/sveltekit/plugin.js.map +1 -1
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +26 -97
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-bundle.d.ts.map +1 -1
- package/lib/cloudflare/worker-bundle.js +11 -9
- package/lib/cloudflare/worker-bundle.js.map +1 -1
- package/lib/cloudflare/worker-tail.d.ts.map +1 -1
- package/lib/cloudflare/worker-tail.js +6 -6
- package/lib/cloudflare/worker-tail.js.map +1 -1
- package/lib/resource.d.ts +1 -0
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js +13 -2
- package/lib/resource.js.map +1 -1
- package/lib/scope.d.ts +38 -1
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +44 -19
- package/lib/scope.js.map +1 -1
- package/lib/state/cloudflare-state-store.d.ts.map +1 -1
- package/lib/state/cloudflare-state-store.js +2 -1
- package/lib/state/cloudflare-state-store.js.map +1 -1
- package/lib/util/idempotent-spawn.d.ts +24 -0
- package/lib/util/idempotent-spawn.d.ts.map +1 -0
- package/lib/util/idempotent-spawn.js +237 -0
- package/lib/util/idempotent-spawn.js.map +1 -0
- package/lib/util/index.d.ts +2 -0
- package/lib/util/index.d.ts.map +1 -0
- package/lib/util/index.js +2 -0
- package/lib/util/index.js.map +1 -0
- package/lib/util/safe-fetch.d.ts +24 -0
- package/lib/util/safe-fetch.d.ts.map +1 -1
- package/lib/util/safe-fetch.js +72 -0
- package/lib/util/safe-fetch.js.map +1 -1
- package/package.json +9 -5
- package/src/alchemy.ts +3 -2
- package/src/aws/client-props.ts +156 -0
- package/src/aws/credentials.ts +165 -4
- package/src/aws/ec2/internet-gateway-attachment.ts +59 -4
- package/src/aws/ec2/internet-gateway.ts +70 -41
- package/src/aws/ec2/nat-gateway.ts +123 -33
- package/src/aws/ec2/route-table-association.ts +1 -1
- package/src/aws/ec2/route-table.ts +66 -2
- package/src/aws/ec2/route.ts +62 -2
- package/src/aws/ec2/security-group.ts +98 -4
- package/src/aws/ec2/subnet.ts +63 -4
- package/src/aws/ec2/utils.ts +73 -7
- package/src/aws/ec2/vpc.ts +52 -3
- package/src/aws/index.ts +2 -0
- package/src/cloudflare/api-response.ts +2 -2
- package/src/cloudflare/api.ts +23 -0
- package/src/cloudflare/assets.ts +3 -4
- package/src/cloudflare/bucket.ts +39 -29
- package/src/cloudflare/bundle/plugin-compat-warning.ts +7 -7
- package/src/cloudflare/cloudflare-env-proxy.ts +2 -2
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/d1-migrations.ts +4 -5
- package/src/cloudflare/index.ts +2 -1
- package/src/cloudflare/kv-namespace.ts +26 -27
- package/src/cloudflare/miniflare/build-worker-options.ts +16 -3
- package/src/cloudflare/miniflare/miniflare-controller.ts +4 -0
- package/src/cloudflare/oauth.ts +3 -3
- package/src/cloudflare/quick-tunnel.ts +30 -0
- package/src/cloudflare/sveltekit/plugin.ts +5 -5
- package/src/cloudflare/website.ts +30 -111
- package/src/cloudflare/worker-bundle.ts +11 -9
- package/src/cloudflare/worker-tail.ts +6 -8
- package/src/resource.ts +19 -2
- package/src/scope.ts +111 -20
- package/src/state/cloudflare-state-store.ts +2 -1
- package/src/util/idempotent-spawn.ts +303 -0
- package/src/util/index.ts +1 -0
- package/src/util/safe-fetch.ts +114 -0
- package/templates/rwsdk/package.json +1 -1
|
@@ -53,12 +53,15 @@ async function waitForInternetGatewayDeleted(client, internetGatewayId, timeoutC
|
|
|
53
53
|
* 1. Provide a target in your VPC route tables for internet-routable traffic
|
|
54
54
|
* 2. Perform network address translation (NAT) for instances with public IPv4 addresses
|
|
55
55
|
*
|
|
56
|
+
* Supports AWS credential overrides at the resource level, allowing you to deploy Internet Gateways
|
|
57
|
+
* to different AWS accounts or regions than the default scope configuration.
|
|
58
|
+
*
|
|
56
59
|
* @example
|
|
57
60
|
* ```typescript
|
|
58
61
|
* // Create a basic Internet Gateway
|
|
59
|
-
* const igw =
|
|
62
|
+
* const igw = await InternetGateway("main-igw", {
|
|
60
63
|
* tags: {
|
|
61
|
-
* Name: "
|
|
64
|
+
* Name: "main-internet-gateway",
|
|
62
65
|
* Environment: "production"
|
|
63
66
|
* }
|
|
64
67
|
* });
|
|
@@ -66,59 +69,49 @@ async function waitForInternetGatewayDeleted(client, internetGatewayId, timeoutC
|
|
|
66
69
|
*
|
|
67
70
|
* @example
|
|
68
71
|
* ```typescript
|
|
69
|
-
* // Create Internet Gateway with
|
|
70
|
-
* const
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
72
|
+
* // Create Internet Gateway with AWS credential overrides
|
|
73
|
+
* const crossAccountIgw = await InternetGateway("cross-account-igw", {
|
|
74
|
+
* // Override AWS credentials for this specific resource
|
|
75
|
+
* region: "us-east-1",
|
|
76
|
+
* profile: "production-account",
|
|
77
|
+
* tags: {
|
|
78
|
+
* Name: "cross-account-internet-gateway",
|
|
79
|
+
* Environment: "production"
|
|
75
80
|
* }
|
|
76
81
|
* });
|
|
77
82
|
* ```
|
|
78
83
|
*
|
|
79
84
|
* @example
|
|
80
85
|
* ```typescript
|
|
81
|
-
* // Create Internet Gateway
|
|
82
|
-
* const
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* vpcId: vpc.vpcId
|
|
87
|
-
* });
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```typescript
|
|
92
|
-
* // Access Internet Gateway properties
|
|
93
|
-
* const igw = new InternetGateway({ tags: { Name: "example-igw" } });
|
|
94
|
-
* logger.log(`Internet Gateway ID: ${igw.internetGatewayId}`);
|
|
95
|
-
* logger.log(`State: ${igw.state}`);
|
|
96
|
-
* ```
|
|
97
|
-
*
|
|
98
|
-
* Creates and manages Internet Gateways that provide internet access to VPCs.
|
|
99
|
-
* Note: Use InternetGatewayAttachment to attach the gateway to a VPC.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* // Create a basic Internet Gateway
|
|
103
|
-
* const igw = await InternetGateway("main-igw", {
|
|
86
|
+
* // Create Internet Gateway in different region with role assumption
|
|
87
|
+
* const multiRegionIgw = await InternetGateway("multi-region-igw", {
|
|
88
|
+
* region: "eu-west-1",
|
|
89
|
+
* roleArn: "arn:aws:iam::123456789012:role/CrossRegionRole",
|
|
90
|
+
* roleSessionName: "internet-gateway-deployment",
|
|
104
91
|
* tags: {
|
|
105
|
-
* Name: "
|
|
106
|
-
*
|
|
92
|
+
* Name: "eu-internet-gateway",
|
|
93
|
+
* Region: "europe"
|
|
107
94
|
* }
|
|
108
95
|
* });
|
|
96
|
+
* ```
|
|
109
97
|
*
|
|
110
98
|
* @example
|
|
111
|
-
*
|
|
112
|
-
*
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // Create Internet Gateway with explicit credentials
|
|
101
|
+
* const explicitCredsIgw = await InternetGateway("explicit-creds-igw", {
|
|
102
|
+
* accessKeyId: alchemy.secret("AKIAIOSFODNN7EXAMPLE"),
|
|
103
|
+
* secretAccessKey: alchemy.secret("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
|
|
104
|
+
* region: "us-west-2",
|
|
113
105
|
* tags: {
|
|
114
|
-
* Name: "
|
|
115
|
-
*
|
|
116
|
-
* Team: "backend"
|
|
106
|
+
* Name: "explicit-credentials-igw",
|
|
107
|
+
* Purpose: "testing"
|
|
117
108
|
* }
|
|
118
109
|
* });
|
|
110
|
+
* ```
|
|
119
111
|
*
|
|
120
112
|
* @example
|
|
121
|
-
*
|
|
113
|
+
* ```typescript
|
|
114
|
+
* // Create Internet Gateway with custom timeout configuration
|
|
122
115
|
* const customIgw = await InternetGateway("custom-igw", {
|
|
123
116
|
* timeout: {
|
|
124
117
|
* maxAttempts: 90,
|
|
@@ -129,9 +122,44 @@ async function waitForInternetGatewayDeleted(client, internetGatewayId, timeoutC
|
|
|
129
122
|
* Purpose: "high-availability"
|
|
130
123
|
* }
|
|
131
124
|
* });
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* // Create Internet Gateway and attach to VPC
|
|
130
|
+
* const vpc = await VPC("main-vpc", { cidrBlock: "10.0.0.0/16" });
|
|
131
|
+
* const igw = await InternetGateway("vpc-igw", {
|
|
132
|
+
* tags: { Name: "vpc-internet-gateway" }
|
|
133
|
+
* });
|
|
134
|
+
* const attachment = await InternetGatewayAttachment("igw-attachment", {
|
|
135
|
+
* internetGatewayId: igw.internetGatewayId,
|
|
136
|
+
* vpcId: vpc.vpcId
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // Multi-account deployment with scope-level and resource-level overrides
|
|
143
|
+
* await alchemy.run("production", {
|
|
144
|
+
* aws: { region: "us-west-2", profile: "main-account" }
|
|
145
|
+
* }, async () => {
|
|
146
|
+
* // This IGW uses scope credentials (main-account, us-west-2)
|
|
147
|
+
* const mainIgw = await InternetGateway("main-igw", {
|
|
148
|
+
* tags: { Name: "main-account-igw" }
|
|
149
|
+
* });
|
|
150
|
+
*
|
|
151
|
+
* // This IGW overrides to use different account
|
|
152
|
+
* const crossAccountIgw = await InternetGateway("cross-account-igw", {
|
|
153
|
+
* profile: "secondary-account",
|
|
154
|
+
* region: "us-east-1", // Also override region
|
|
155
|
+
* tags: { Name: "secondary-account-igw" }
|
|
156
|
+
* });
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
132
159
|
*/
|
|
133
160
|
export const InternetGateway = Resource("aws::InternetGateway", async function (_id, props) {
|
|
134
|
-
|
|
161
|
+
// Create EC2 client with credential resolution handled internally
|
|
162
|
+
const client = await createEC2Client(props);
|
|
135
163
|
const timeoutConfig = mergeTimeoutConfig(INTERNET_GATEWAY_TIMEOUT, props.timeout);
|
|
136
164
|
if (this.phase === "delete") {
|
|
137
165
|
if (this.output?.internetGatewayId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internet-gateway.js","sourceRoot":"","sources":["../../../src/aws/ec2/internet-gateway.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,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAElB,oBAAoB,GACrB,MAAM,uBAA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G,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;oBAChE,CAAC,CAAC,SAAS;gBACb,OAAO,EAAE,GAAG,CAAC,OAAO;aACrB,CAAC,CAAC,CAAC;QACN,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,IACE,MAAM,CAAC,6BAA6B;QACpC,MAAM,CAAC,6BAA6B;QACpC,MAAM,CAAC,6BAA6B,EACpC,CAAC;QACD,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Context } from "../../context.ts";
|
|
2
2
|
import { Resource } from "../../resource.ts";
|
|
3
3
|
import { type TimeoutConfig } from "../../util/timeout.ts";
|
|
4
|
+
import type { AwsClientProps } from "../client-props.ts";
|
|
4
5
|
import type { Subnet } from "./subnet.ts";
|
|
5
6
|
/**
|
|
6
7
|
* Properties for creating or updating a NAT Gateway
|
|
7
8
|
*/
|
|
8
|
-
export interface NatGatewayProps {
|
|
9
|
+
export interface NatGatewayProps extends AwsClientProps {
|
|
9
10
|
/**
|
|
10
11
|
* The subnet to create the NAT Gateway in (must be a public subnet)
|
|
11
12
|
*/
|
|
@@ -75,39 +76,94 @@ export interface NatGateway extends Resource<"aws::NatGateway">, NatGatewayProps
|
|
|
75
76
|
* if one is not provided. NAT Gateways are slow resources that can take
|
|
76
77
|
* up to 10 minutes to become available.
|
|
77
78
|
*
|
|
79
|
+
* Supports AWS credential overrides at the resource level, allowing you to deploy NAT Gateways
|
|
80
|
+
* to different AWS accounts or regions than the default scope configuration.
|
|
81
|
+
*
|
|
78
82
|
* @example
|
|
83
|
+
* ```typescript
|
|
79
84
|
* // Create a NAT Gateway with automatic Elastic IP allocation
|
|
80
85
|
* const natGateway = await NatGateway("main-nat", {
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
+
* subnet: publicSubnet,
|
|
87
|
+
* tags: {
|
|
88
|
+
* Name: "main-nat-gateway",
|
|
89
|
+
* Environment: "production"
|
|
90
|
+
* }
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* // Create NAT Gateway with AWS credential overrides
|
|
97
|
+
* const crossAccountNat = await NatGateway("cross-account-nat", {
|
|
98
|
+
* subnet: publicSubnet,
|
|
99
|
+
* // Override AWS credentials for this specific resource
|
|
100
|
+
* region: "us-east-1",
|
|
101
|
+
* profile: "production-account",
|
|
102
|
+
* tags: {
|
|
103
|
+
* Name: "cross-account-nat-gateway",
|
|
104
|
+
* Environment: "production"
|
|
105
|
+
* }
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* // Create NAT Gateway in different region with role assumption
|
|
112
|
+
* const multiRegionNat = await NatGateway("multi-region-nat", {
|
|
113
|
+
* subnet: euPublicSubnet,
|
|
114
|
+
* region: "eu-west-1",
|
|
115
|
+
* roleArn: "arn:aws:iam::123456789012:role/CrossRegionRole",
|
|
116
|
+
* roleSessionName: "nat-gateway-deployment",
|
|
117
|
+
* tags: {
|
|
118
|
+
* Name: "eu-nat-gateway",
|
|
119
|
+
* Region: "europe"
|
|
120
|
+
* }
|
|
86
121
|
* });
|
|
122
|
+
* ```
|
|
87
123
|
*
|
|
88
124
|
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* // Create NAT Gateway with explicit credentials
|
|
127
|
+
* const explicitCredsNat = await NatGateway("explicit-creds-nat", {
|
|
128
|
+
* subnet: testPublicSubnet,
|
|
129
|
+
* accessKeyId: alchemy.secret("AKIAIOSFODNN7EXAMPLE"),
|
|
130
|
+
* secretAccessKey: alchemy.secret("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
|
|
131
|
+
* region: "us-west-2",
|
|
132
|
+
* tags: {
|
|
133
|
+
* Name: "explicit-credentials-nat",
|
|
134
|
+
* Purpose: "testing"
|
|
135
|
+
* }
|
|
136
|
+
* });
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
89
141
|
* // Create a NAT Gateway with existing Elastic IP
|
|
90
142
|
* const natGateway = await NatGateway("custom-nat", {
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
143
|
+
* subnet: "subnet-12345678",
|
|
144
|
+
* allocationId: "eipalloc-12345678",
|
|
145
|
+
* connectivityType: "public",
|
|
146
|
+
* tags: {
|
|
147
|
+
* Name: "custom-nat-gateway"
|
|
148
|
+
* }
|
|
97
149
|
* });
|
|
150
|
+
* ```
|
|
98
151
|
*
|
|
99
152
|
* @example
|
|
153
|
+
* ```typescript
|
|
100
154
|
* // Create a private NAT Gateway (for VPC-to-VPC communication)
|
|
101
155
|
* const privateNat = await NatGateway("private-nat", {
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
156
|
+
* subnet: privateSubnet,
|
|
157
|
+
* connectivityType: "private",
|
|
158
|
+
* tags: {
|
|
159
|
+
* Name: "private-nat-gateway",
|
|
160
|
+
* Type: "internal"
|
|
161
|
+
* }
|
|
108
162
|
* });
|
|
163
|
+
* ```
|
|
109
164
|
*
|
|
110
165
|
* @example
|
|
166
|
+
* ```typescript
|
|
111
167
|
* // Create a NAT Gateway with custom timeout configuration
|
|
112
168
|
* const slowNat = await NatGateway("slow-nat", {
|
|
113
169
|
* subnet: publicSubnet,
|
|
@@ -119,8 +175,32 @@ export interface NatGateway extends Resource<"aws::NatGateway">, NatGatewayProps
|
|
|
119
175
|
* Name: "slow-nat-gateway"
|
|
120
176
|
* }
|
|
121
177
|
* });
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* // Multi-account deployment with scope-level and resource-level overrides
|
|
183
|
+
* await alchemy.run("production", {
|
|
184
|
+
* aws: { region: "us-west-2", profile: "main-account" }
|
|
185
|
+
* }, async () => {
|
|
186
|
+
* // This NAT Gateway uses scope credentials (main-account, us-west-2)
|
|
187
|
+
* const mainNat = await NatGateway("main-nat", {
|
|
188
|
+
* subnet: mainPublicSubnet,
|
|
189
|
+
* tags: { Name: "main-account-nat" }
|
|
190
|
+
* });
|
|
191
|
+
*
|
|
192
|
+
* // This NAT Gateway overrides to use different account
|
|
193
|
+
* const crossAccountNat = await NatGateway("cross-account-nat", {
|
|
194
|
+
* subnet: crossPublicSubnet,
|
|
195
|
+
* profile: "secondary-account",
|
|
196
|
+
* region: "us-east-1", // Also override region
|
|
197
|
+
* tags: { Name: "secondary-account-nat" }
|
|
198
|
+
* });
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
122
201
|
*
|
|
123
202
|
* @example
|
|
203
|
+
* ```typescript
|
|
124
204
|
* // Use NAT Gateway in route table for private subnet internet access
|
|
125
205
|
* const privateRoute = await Route("private-internet", {
|
|
126
206
|
* routeTable: privateRouteTable,
|
|
@@ -130,6 +210,7 @@ export interface NatGateway extends Resource<"aws::NatGateway">, NatGatewayProps
|
|
|
130
210
|
* Name: "private-to-internet"
|
|
131
211
|
* }
|
|
132
212
|
* });
|
|
213
|
+
* ```
|
|
133
214
|
*/
|
|
134
215
|
export declare const NatGateway: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<NatGateway>, _id: string, props: NatGatewayProps) => Promise<NatGateway>);
|
|
135
216
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nat-gateway.d.ts","sourceRoot":"","sources":["../../../src/aws/ec2/nat-gateway.ts"],"names":[],"mappings":"AACA,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;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"nat-gateway.d.ts","sourceRoot":"","sources":["../../../src/aws/ec2/nat-gateway.ts"],"names":[],"mappings":"AACA,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;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAExC;;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,UACf,SAAQ,QAAQ,CAAC,iBAAiB,CAAC,EACjC,eAAe;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;IAEnE;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+IG;AACH,eAAO,MAAM,UAAU,yFAGb,OAAO,CAAC,UAAU,CAAC,OACpB,MAAM,SACJ,eAAe,KACrB,OAAO,CAAC,UAAU,CAAC,CAmMvB,CAAC;AAqOF;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAGjC,CAAC"}
|
|
@@ -12,39 +12,94 @@ import { callEC2Api, createEC2Client } from "./utils.js";
|
|
|
12
12
|
* if one is not provided. NAT Gateways are slow resources that can take
|
|
13
13
|
* up to 10 minutes to become available.
|
|
14
14
|
*
|
|
15
|
+
* Supports AWS credential overrides at the resource level, allowing you to deploy NAT Gateways
|
|
16
|
+
* to different AWS accounts or regions than the default scope configuration.
|
|
17
|
+
*
|
|
15
18
|
* @example
|
|
19
|
+
* ```typescript
|
|
16
20
|
* // Create a NAT Gateway with automatic Elastic IP allocation
|
|
17
21
|
* const natGateway = await NatGateway("main-nat", {
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
22
|
+
* subnet: publicSubnet,
|
|
23
|
+
* tags: {
|
|
24
|
+
* Name: "main-nat-gateway",
|
|
25
|
+
* Environment: "production"
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Create NAT Gateway with AWS credential overrides
|
|
33
|
+
* const crossAccountNat = await NatGateway("cross-account-nat", {
|
|
34
|
+
* subnet: publicSubnet,
|
|
35
|
+
* // Override AWS credentials for this specific resource
|
|
36
|
+
* region: "us-east-1",
|
|
37
|
+
* profile: "production-account",
|
|
38
|
+
* tags: {
|
|
39
|
+
* Name: "cross-account-nat-gateway",
|
|
40
|
+
* Environment: "production"
|
|
41
|
+
* }
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* // Create NAT Gateway in different region with role assumption
|
|
48
|
+
* const multiRegionNat = await NatGateway("multi-region-nat", {
|
|
49
|
+
* subnet: euPublicSubnet,
|
|
50
|
+
* region: "eu-west-1",
|
|
51
|
+
* roleArn: "arn:aws:iam::123456789012:role/CrossRegionRole",
|
|
52
|
+
* roleSessionName: "nat-gateway-deployment",
|
|
53
|
+
* tags: {
|
|
54
|
+
* Name: "eu-nat-gateway",
|
|
55
|
+
* Region: "europe"
|
|
56
|
+
* }
|
|
23
57
|
* });
|
|
58
|
+
* ```
|
|
24
59
|
*
|
|
25
60
|
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Create NAT Gateway with explicit credentials
|
|
63
|
+
* const explicitCredsNat = await NatGateway("explicit-creds-nat", {
|
|
64
|
+
* subnet: testPublicSubnet,
|
|
65
|
+
* accessKeyId: alchemy.secret("AKIAIOSFODNN7EXAMPLE"),
|
|
66
|
+
* secretAccessKey: alchemy.secret("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
|
|
67
|
+
* region: "us-west-2",
|
|
68
|
+
* tags: {
|
|
69
|
+
* Name: "explicit-credentials-nat",
|
|
70
|
+
* Purpose: "testing"
|
|
71
|
+
* }
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
26
77
|
* // Create a NAT Gateway with existing Elastic IP
|
|
27
78
|
* const natGateway = await NatGateway("custom-nat", {
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
79
|
+
* subnet: "subnet-12345678",
|
|
80
|
+
* allocationId: "eipalloc-12345678",
|
|
81
|
+
* connectivityType: "public",
|
|
82
|
+
* tags: {
|
|
83
|
+
* Name: "custom-nat-gateway"
|
|
84
|
+
* }
|
|
34
85
|
* });
|
|
86
|
+
* ```
|
|
35
87
|
*
|
|
36
88
|
* @example
|
|
89
|
+
* ```typescript
|
|
37
90
|
* // Create a private NAT Gateway (for VPC-to-VPC communication)
|
|
38
91
|
* const privateNat = await NatGateway("private-nat", {
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
92
|
+
* subnet: privateSubnet,
|
|
93
|
+
* connectivityType: "private",
|
|
94
|
+
* tags: {
|
|
95
|
+
* Name: "private-nat-gateway",
|
|
96
|
+
* Type: "internal"
|
|
97
|
+
* }
|
|
45
98
|
* });
|
|
99
|
+
* ```
|
|
46
100
|
*
|
|
47
101
|
* @example
|
|
102
|
+
* ```typescript
|
|
48
103
|
* // Create a NAT Gateway with custom timeout configuration
|
|
49
104
|
* const slowNat = await NatGateway("slow-nat", {
|
|
50
105
|
* subnet: publicSubnet,
|
|
@@ -56,8 +111,32 @@ import { callEC2Api, createEC2Client } from "./utils.js";
|
|
|
56
111
|
* Name: "slow-nat-gateway"
|
|
57
112
|
* }
|
|
58
113
|
* });
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* // Multi-account deployment with scope-level and resource-level overrides
|
|
119
|
+
* await alchemy.run("production", {
|
|
120
|
+
* aws: { region: "us-west-2", profile: "main-account" }
|
|
121
|
+
* }, async () => {
|
|
122
|
+
* // This NAT Gateway uses scope credentials (main-account, us-west-2)
|
|
123
|
+
* const mainNat = await NatGateway("main-nat", {
|
|
124
|
+
* subnet: mainPublicSubnet,
|
|
125
|
+
* tags: { Name: "main-account-nat" }
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* // This NAT Gateway overrides to use different account
|
|
129
|
+
* const crossAccountNat = await NatGateway("cross-account-nat", {
|
|
130
|
+
* subnet: crossPublicSubnet,
|
|
131
|
+
* profile: "secondary-account",
|
|
132
|
+
* region: "us-east-1", // Also override region
|
|
133
|
+
* tags: { Name: "secondary-account-nat" }
|
|
134
|
+
* });
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
59
137
|
*
|
|
60
138
|
* @example
|
|
139
|
+
* ```typescript
|
|
61
140
|
* // Use NAT Gateway in route table for private subnet internet access
|
|
62
141
|
* const privateRoute = await Route("private-internet", {
|
|
63
142
|
* routeTable: privateRouteTable,
|
|
@@ -67,8 +146,11 @@ import { callEC2Api, createEC2Client } from "./utils.js";
|
|
|
67
146
|
* Name: "private-to-internet"
|
|
68
147
|
* }
|
|
69
148
|
* });
|
|
149
|
+
* ```
|
|
70
150
|
*/
|
|
71
151
|
export const NatGateway = Resource("aws::NatGateway", async function (_id, props) {
|
|
152
|
+
// Create EC2 client with credential resolution handled internally
|
|
153
|
+
const client = await createEC2Client(props);
|
|
72
154
|
const subnetId = typeof props.subnet === "string" ? props.subnet : props.subnet.subnetId;
|
|
73
155
|
const timeoutConfig = mergeTimeoutConfig(NAT_GATEWAY_TIMEOUT, props.timeout);
|
|
74
156
|
if (this.phase === "delete") {
|
|
@@ -76,26 +158,24 @@ export const NatGateway = Resource("aws::NatGateway", async function (_id, props
|
|
|
76
158
|
logger.log(`🗑️ Deleting NAT Gateway: ${this.output.natGatewayId}`);
|
|
77
159
|
// Delete NAT Gateway if it exists
|
|
78
160
|
await ignore("InvalidNatGatewayID.NotFound", async () => {
|
|
79
|
-
const client = await createEC2Client();
|
|
80
161
|
await callEC2Api(client, "DeleteNatGateway", parseNatGatewayXmlResponse, convertDeleteNatGatewayParamsToAwsFormat({
|
|
81
162
|
NatGatewayId: this.output.natGatewayId,
|
|
82
163
|
}));
|
|
83
164
|
});
|
|
84
165
|
// Wait for NAT Gateway to be deleted AND network interfaces to be cleaned up
|
|
85
166
|
logger.log(` Waiting for NAT Gateway ${this.output.natGatewayId} to be fully deleted...`);
|
|
86
|
-
await waitForNatGatewayFullyDeleted(this.output.natGatewayId, timeoutConfig);
|
|
167
|
+
await waitForNatGatewayFullyDeleted(this.output.natGatewayId, timeoutConfig, props);
|
|
87
168
|
logger.log(` ✅ NAT Gateway ${this.output.natGatewayId} deletion completed`);
|
|
88
169
|
// Release Elastic IP if we created it and it exists
|
|
89
170
|
if (this.output.createdElasticIp && this.output.allocationId) {
|
|
90
171
|
logger.log(` Releasing Elastic IP: ${this.output.allocationId}`);
|
|
91
172
|
await ignore(["InvalidAllocationID.NotFound", "InvalidAddress.NotFound"], async () => {
|
|
92
|
-
|
|
93
|
-
await callEC2Api(eipClient, "ReleaseAddress", parseNatGatewayXmlResponse, convertReleaseAddressParamsToAwsFormat({
|
|
173
|
+
await callEC2Api(client, "ReleaseAddress", parseNatGatewayXmlResponse, convertReleaseAddressParamsToAwsFormat({
|
|
94
174
|
AllocationId: this.output.allocationId,
|
|
95
175
|
}));
|
|
96
176
|
});
|
|
97
177
|
// Wait for the EIP to be fully released
|
|
98
|
-
await waitForEipReleased(this.output.allocationId, timeoutConfig);
|
|
178
|
+
await waitForEipReleased(this.output.allocationId, timeoutConfig, props);
|
|
99
179
|
logger.log(` ✅ Elastic IP ${this.output.allocationId} released successfully`);
|
|
100
180
|
}
|
|
101
181
|
}
|
|
@@ -107,7 +187,6 @@ export const NatGateway = Resource("aws::NatGateway", async function (_id, props
|
|
|
107
187
|
let publicIp;
|
|
108
188
|
if (this.phase === "update" && this.output?.natGatewayId) {
|
|
109
189
|
// Get existing NAT Gateway
|
|
110
|
-
const client = await createEC2Client();
|
|
111
190
|
const response = await callEC2Api(client, "DescribeNatGateways", parseNatGatewayXmlResponse, convertDescribeNatGatewaysParamsToAwsFormat({
|
|
112
191
|
NatGatewayIds: [this.output.natGatewayId],
|
|
113
192
|
}));
|
|
@@ -137,7 +216,6 @@ export const NatGateway = Resource("aws::NatGateway", async function (_id, props
|
|
|
137
216
|
},
|
|
138
217
|
];
|
|
139
218
|
}
|
|
140
|
-
const client = await createEC2Client();
|
|
141
219
|
const eipResponse = await callEC2Api(client, "AllocateAddress", parseNatGatewayXmlResponse, convertAllocateAddressParamsToAwsFormat(eipParams));
|
|
142
220
|
if (!eipResponse.AllocationId) {
|
|
143
221
|
throw new Error("Failed to allocate Elastic IP");
|
|
@@ -148,7 +226,6 @@ export const NatGateway = Resource("aws::NatGateway", async function (_id, props
|
|
|
148
226
|
}
|
|
149
227
|
else {
|
|
150
228
|
// Get public IP of existing allocation
|
|
151
|
-
const client = await createEC2Client();
|
|
152
229
|
const addressResponse = await callEC2Api(client, "DescribeAddresses", parseNatGatewayXmlResponse, convertDescribeAddressesParamsToAwsFormat({
|
|
153
230
|
AllocationIds: [allocationId],
|
|
154
231
|
}));
|
|
@@ -172,14 +249,13 @@ export const NatGateway = Resource("aws::NatGateway", async function (_id, props
|
|
|
172
249
|
},
|
|
173
250
|
];
|
|
174
251
|
}
|
|
175
|
-
const
|
|
176
|
-
const response = await callEC2Api(natClient, "CreateNatGateway", parseNatGatewayXmlResponse, convertCreateNatGatewayParamsToAwsFormat(createParams));
|
|
252
|
+
const response = await callEC2Api(client, "CreateNatGateway", parseNatGatewayXmlResponse, convertCreateNatGatewayParamsToAwsFormat(createParams));
|
|
177
253
|
if (!response.NatGateway) {
|
|
178
254
|
throw new Error("Failed to create NAT Gateway");
|
|
179
255
|
}
|
|
180
256
|
natGateway = response.NatGateway;
|
|
181
257
|
// Wait for NAT Gateway to be available
|
|
182
|
-
await waitForNatGatewayAvailable(natGateway.NatGatewayId, timeoutConfig);
|
|
258
|
+
await waitForNatGatewayAvailable(natGateway.NatGatewayId, timeoutConfig, props);
|
|
183
259
|
}
|
|
184
260
|
const result = this({
|
|
185
261
|
natGatewayId: natGateway.NatGatewayId,
|
|
@@ -198,9 +274,9 @@ export const NatGateway = Resource("aws::NatGateway", async function (_id, props
|
|
|
198
274
|
/**
|
|
199
275
|
* Wait for NAT Gateway to be in available state
|
|
200
276
|
*/
|
|
201
|
-
async function waitForNatGatewayAvailable(natGatewayId, timeoutConfig) {
|
|
277
|
+
async function waitForNatGatewayAvailable(natGatewayId, timeoutConfig, credentials) {
|
|
202
278
|
const checkFunction = async () => {
|
|
203
|
-
const client = await createEC2Client();
|
|
279
|
+
const client = await createEC2Client(credentials);
|
|
204
280
|
const response = await callEC2Api(client, "DescribeNatGateways", parseNatGatewayXmlResponse, convertDescribeNatGatewaysParamsToAwsFormat({
|
|
205
281
|
NatGatewayIds: [natGatewayId],
|
|
206
282
|
}));
|
|
@@ -218,10 +294,10 @@ async function waitForNatGatewayAvailable(natGatewayId, timeoutConfig) {
|
|
|
218
294
|
/**
|
|
219
295
|
* Wait for NAT Gateway to be deleted
|
|
220
296
|
*/
|
|
221
|
-
async function waitForNatGatewayDeleted(natGatewayId, timeoutConfig) {
|
|
297
|
+
async function waitForNatGatewayDeleted(natGatewayId, timeoutConfig, credentials) {
|
|
222
298
|
const checkFunction = async () => {
|
|
223
299
|
try {
|
|
224
|
-
const client = await createEC2Client();
|
|
300
|
+
const client = await createEC2Client(credentials);
|
|
225
301
|
const response = await callEC2Api(client, "DescribeNatGateways", parseNatGatewayXmlResponse, convertDescribeNatGatewaysParamsToAwsFormat({
|
|
226
302
|
NatGatewayIds: [natGatewayId],
|
|
227
303
|
}));
|
|
@@ -273,10 +349,10 @@ function parseDescribeNetworkInterfacesResponse(xmlText) {
|
|
|
273
349
|
/**
|
|
274
350
|
* Wait for an Elastic IP to be released.
|
|
275
351
|
*/
|
|
276
|
-
async function waitForEipReleased(allocationId, timeoutConfig) {
|
|
352
|
+
async function waitForEipReleased(allocationId, timeoutConfig, credentials) {
|
|
277
353
|
const checkFunction = async () => {
|
|
278
354
|
try {
|
|
279
|
-
const eipClient = await createEC2Client();
|
|
355
|
+
const eipClient = await createEC2Client(credentials);
|
|
280
356
|
const addressResponse = await callEC2Api(eipClient, "DescribeAddresses", parseNatGatewayXmlResponse, convertDescribeAddressesParamsToAwsFormat({
|
|
281
357
|
AllocationIds: [allocationId],
|
|
282
358
|
}));
|
|
@@ -298,13 +374,13 @@ async function waitForEipReleased(allocationId, timeoutConfig) {
|
|
|
298
374
|
/**
|
|
299
375
|
* Wait for NAT Gateway to be fully deleted including network interface cleanup
|
|
300
376
|
*/
|
|
301
|
-
async function waitForNatGatewayFullyDeleted(natGatewayId, timeoutConfig) {
|
|
377
|
+
async function waitForNatGatewayFullyDeleted(natGatewayId, timeoutConfig, credentials) {
|
|
302
378
|
// First wait for the NAT Gateway itself to be deleted
|
|
303
|
-
await waitForNatGatewayDeleted(natGatewayId, timeoutConfig);
|
|
379
|
+
await waitForNatGatewayDeleted(natGatewayId, timeoutConfig, credentials);
|
|
304
380
|
// Then wait for network interfaces to be cleaned up
|
|
305
381
|
const checkNetworkInterfaces = async () => {
|
|
306
382
|
try {
|
|
307
|
-
const client = await createEC2Client();
|
|
383
|
+
const client = await createEC2Client(credentials);
|
|
308
384
|
const response = await callEC2Api(client, "DescribeNetworkInterfaces", parseDescribeNetworkInterfacesResponse, {
|
|
309
385
|
"Filter.1.Name": "description",
|
|
310
386
|
"Filter.1.Value.1": `Interface for NAT Gateway ${natGatewayId}`,
|