Skip to content

Commit 0c306a7

Browse files
feat: Allow passing a machine image directly. (#29)
* Allow passing a machine image directly. * Ran build
1 parent 4363d90 commit 0c306a7

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

API.md

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
BastionHostLinux,
55
CfnRoute,
66
CloudFormationInit,
7+
IMachineImage,
78
InitCommand,
89
InitElement,
910
InstanceType,
@@ -113,6 +114,12 @@ export interface TailscaleBastionProps {
113114
* @default false
114115
*/
115116
readonly cachedInContext?: boolean;
117+
118+
/**
119+
* If you want to completely opt out of getting the latest Amazon Linux AMI and instead need to specify one yourself, pass it in here.
120+
* We'll use the one you specify instead of the default.
121+
*/
122+
readonly ami?: IMachineImage;
116123
}
117124

118125
export class TailscaleBastion extends Construct {
@@ -133,17 +140,22 @@ export class TailscaleBastion extends Construct {
133140
advertiseRoute,
134141
cpuType,
135142
cachedInContext,
143+
ami,
136144
} = props;
137145

138146
const authKeyCommand = this.computeTsKeyCli(tailscaleCredentials);
147+
const machineImage = ami ?? MachineImage.latestAmazonLinux2023({
148+
cpuType: cpuType ?? AmazonLinuxCpuType.X86_64,
149+
cachedInContext: cachedInContext ?? false,
150+
});
139151

140152
const bastion = new BastionHostLinux(this, 'BastionHost', {
141153
vpc,
142154
availabilityZone,
143155
instanceName: instanceName ?? 'BastionHostTailscale',
144156
securityGroup,
145157
instanceType,
146-
machineImage: MachineImage.latestAmazonLinux2023({ cpuType: cpuType ?? AmazonLinuxCpuType.X86_64, cachedInContext: cachedInContext ?? false }),
158+
machineImage,
147159
subnetSelection: subnetSelection ?? { subnetType: SubnetType.PUBLIC },
148160
init: CloudFormationInit.fromElements(
149161
// Configure IP forwarding

0 commit comments

Comments
 (0)