Skip to content

Commit

Permalink
feat(bastion-host): Make elastic IP optional
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach committed Nov 8, 2022
1 parent 4e1736d commit d77b578
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/bastion-host/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ export class BastionHost extends Construct {
});

// Assign elastic IP
new ec2.CfnEIP(this, "IP", {
instanceId: this.instance.instanceId,
tags: [{ key: "Name", value: stackName }],
});
if (props.createElasticIp) {
new ec2.CfnEIP(this, "IP", {
instanceId: this.instance.instanceId,
tags: [{ key: "Name", value: stackName }],
});
}

// Allow bastion host to connect to db
this.instance.connections.allowTo(
Expand Down Expand Up @@ -185,4 +187,11 @@ export interface BastionHostProps {
readonly userData: ec2.UserData;
readonly ipv4Allowlist: string[];
readonly sshPort?: number;

/**
* Whether or not an elastic IP should be created for the bastion host.
*
* @default true
*/
readonly createElasticIp?: boolean;
}

0 comments on commit d77b578

Please sign in to comment.