# BastionHostLinuxProps

Properties of the bastion host.

Extends: BastionHostLinuxProps
Used as props by: BastionHostLinux

- Source: [`aws-ec2/lib/bastion-host.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ec2/lib/bastion-host.ts#L28)
- Type last changed: v2.172.0 · 7 Dec 2024

## Example

```ts
const host = new ec2.BastionHostLinux(this, 'BastionHost', {
  vpc,
  blockDevices: [{
    deviceName: '/dev/sdh',
    volume: ec2.BlockDeviceVolume.ebs(10, {
      encrypted: true,
    }),
  }],
});
```

## Properties

- `availabilityZone`: string — In which AZ to place the instance within the VPC.

  **Default:** Random zone.

- `blockDevices`: [BlockDevice](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.BlockDevice.html)[] — Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes.

  **Default:** Uses the block device mapping of the AMI

  Each instance that is launched has an associated root device volume,
  either an Amazon EBS volume or an instance store volume.
  You can use block device mappings to specify additional EBS volumes or
  instance store volumes to attach to an instance when it is launched.

- `init`: [CloudFormationInit](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.CloudFormationInit.html) — Apply the given CloudFormation Init configuration to the instance at startup.

  **Default:** no CloudFormation init

- `initOptions`: [ApplyCloudFormationInitOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ApplyCloudFormationInitOptions.html) — Use the given options for applying CloudFormation Init.

  **Default:** default options

  Describes the configsets to use and the timeout to wait

- `instanceName`: string = 'BastionHost' — The name of the instance.

- `instanceType`: [InstanceType](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.InstanceType.html) = 't3.nano' — Type of instance to launch.

- `machineImage`: [IMachineImage](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IMachineImage.html) — The machine image to use, assumed to have SSM Agent preinstalled.

  **Default:** An Amazon Linux 2023 image if the `@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault` feature flag is enabled. Otherwise, an Amazon Linux 2 image. In both cases, the image is kept up-to-date automatically (the instance may be replaced on every deployment) and already has SSM Agent installed.

- `requireImdsv2`: boolean = false — Whether IMDSv2 should be required on this instance.

- `securityGroup`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html) — Security Group to assign to this instance.

  **Default:** create new security group with no inbound and all outbound traffic allowed

- `subnetSelection`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — Select the subnets to run the bastion host in.

  **Default:** private subnets of the supplied VPC

  Set this to PUBLIC if you need to connect to this instance via the internet and cannot use SSM.
  You have to allow port 22 manually by using the connections field

- `userDataCausesReplacement`: boolean — Determines whether changes to the UserData will force instance replacement.

  **Default:** `true` if `initOptions` is specified, otherwise `false`.

  Depending on the EC2 instance type, modifying the UserData may either restart
  or replace the instance:

  - Instance store-backed instances are replaced.
  - EBS-backed instances are restarted.

  Note that by default, restarting does not execute the updated UserData, so an alternative
  mechanism is needed to ensure the instance re-executes the UserData.

  When set to `true`, the instance's Logical ID will depend on the UserData, causing
  CloudFormation to replace the instance if the UserData changes.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — VPC to launch the instance in.
