Skip to content

Commit

Permalink
feat: configurable CPU type (#20)
Browse files Browse the repository at this point in the history
* feat: allow cpu type to be passed

* Formatting fixes

* chore: self mutation

Signed-off-by: github-actions <[email protected]>

---------

Signed-off-by: github-actions <[email protected]>
Co-authored-by: Dan Reiland <[email protected]>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
3 people authored Aug 19, 2023
1 parent d4b4eff commit dbbde4e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
14 changes: 14 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import { CfnOutput, Fn, Stack, Token } from 'aws-cdk-lib';
import { BastionHostLinux, CloudFormationInit, InitCommand, ISecurityGroup, Peer, Port, SubnetSelection, IVpc, InstanceType, SubnetType, InitElement, CfnRoute, MachineImage } from 'aws-cdk-lib/aws-ec2';
import {
AmazonLinuxCpuType,
BastionHostLinux,
CfnRoute,
CloudFormationInit,
InitCommand,
InitElement,
InstanceType,
ISecurityGroup,
IVpc,
MachineImage,
Peer,
Port,
SubnetSelection,
SubnetType,
} from 'aws-cdk-lib/aws-ec2';
import { ISecret } from 'aws-cdk-lib/aws-secretsmanager';
import { Construct } from 'constructs';

Expand Down Expand Up @@ -68,6 +83,12 @@ export interface TailscaleBastionProps {
* @default 't3.nano'
*/
readonly instanceType?: InstanceType;
/**
* CPU Type of the instance.
*
* @default AmazonLinuxCpuType.X86_64
*/
readonly cpuType?: AmazonLinuxCpuType;
/**
* Additional cloudformation init actions to perform during startup.
*/
Expand Down Expand Up @@ -100,6 +121,7 @@ export class TailscaleBastion extends Construct {
additionalInit,
incomingRoutes,
advertiseRoute,
cpuType,
} = props;

const authKeyCommand = this.computeTsKeyCli(tailscaleCredentials);
Expand All @@ -110,7 +132,7 @@ export class TailscaleBastion extends Construct {
instanceName: instanceName ?? 'BastionHostTailscale',
securityGroup,
instanceType,
machineImage: MachineImage.latestAmazonLinux2023(),
machineImage: MachineImage.latestAmazonLinux2023({ cpuType: cpuType ?? AmazonLinuxCpuType.X86_64 }),
subnetSelection: subnetSelection ?? { subnetType: SubnetType.PUBLIC },
init: CloudFormationInit.fromElements(
// Configure IP forwarding
Expand Down

0 comments on commit dbbde4e

Please sign in to comment.