Skip to content

Commit d77b578

Browse files
committed
feat(bastion-host): Make elastic IP optional
1 parent 4e1736d commit d77b578

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/bastion-host/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ export class BastionHost extends Construct {
131131
});
132132

133133
// Assign elastic IP
134-
new ec2.CfnEIP(this, "IP", {
135-
instanceId: this.instance.instanceId,
136-
tags: [{ key: "Name", value: stackName }],
137-
});
134+
if (props.createElasticIp) {
135+
new ec2.CfnEIP(this, "IP", {
136+
instanceId: this.instance.instanceId,
137+
tags: [{ key: "Name", value: stackName }],
138+
});
139+
}
138140

139141
// Allow bastion host to connect to db
140142
this.instance.connections.allowTo(
@@ -185,4 +187,11 @@ export interface BastionHostProps {
185187
readonly userData: ec2.UserData;
186188
readonly ipv4Allowlist: string[];
187189
readonly sshPort?: number;
190+
191+
/**
192+
* Whether or not an elastic IP should be created for the bastion host.
193+
*
194+
* @default true
195+
*/
196+
readonly createElasticIp?: boolean;
188197
}

0 commit comments

Comments
 (0)