BastionHostLinuxProps

class aws_cdk.aws_ec2.BastionHostLinuxProps(*, vpc, availability_zone=None, block_devices=None, init=None, init_options=None, instance_name=None, instance_type=None, machine_image=None, require_imdsv2=None, security_group=None, subnet_selection=None, user_data_causes_replacement=None)

Bases: object

Properties of the bastion host.

Parameters:
  • vpc (IVpc) – VPC to launch the instance in.

  • availability_zone (Optional[str]) – In which AZ to place the instance within the VPC. Default: - Random zone.

  • block_devices (Optional[Sequence[Union[BlockDevice, Dict[str, Any]]]]) – Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes. 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. Default: - Uses the block device mapping of the AMI

  • init (Optional[CloudFormationInit]) – Apply the given CloudFormation Init configuration to the instance at startup. Default: - no CloudFormation init

  • init_options (Union[ApplyCloudFormationInitOptions, Dict[str, Any], None]) – Use the given options for applying CloudFormation Init. Describes the configsets to use and the timeout to wait Default: - default options

  • instance_name (Optional[str]) – The name of the instance. Default: ‘BastionHost’

  • instance_type (Optional[InstanceType]) – Type of instance to launch. Default: ‘t3.nano’

  • machine_image (Optional[IMachineImage]) – The machine image to use, assumed to have SSM Agent preinstalled. Default: - An Amazon Linux 2 image which is kept up-to-date automatically (the instance may be replaced on every deployment) and already has SSM Agent installed.

  • require_imdsv2 (Optional[bool]) – Whether IMDSv2 should be required on this instance. Default: - false

  • security_group (Optional[ISecurityGroup]) – Security Group to assign to this instance. Default: - create new security group with no inbound and all outbound traffic allowed

  • subnet_selection (Union[SubnetSelection, Dict[str, Any], None]) – Select the subnets to run the bastion host in. 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 Default: - private subnets of the supplied VPC

  • user_data_causes_replacement (Optional[bool]) – Determines whether changes to the UserData will force instance replacement. 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. Default: - true if initOptions is specified, otherwise false.

ExampleMetadata:

fixture=with-vpc infused

Example:

host = ec2.BastionHostLinux(self, "BastionHost",
    vpc=vpc,
    block_devices=[ec2.BlockDevice(
        device_name="/dev/sdh",
        volume=ec2.BlockDeviceVolume.ebs(10,
            encrypted=True
        )
    )]
)

Attributes

availability_zone

In which AZ to place the instance within the VPC.

Default:
  • Random zone.

block_devices

Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes.

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.

Default:
  • Uses the block device mapping of the AMI

See:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html

init

Apply the given CloudFormation Init configuration to the instance at startup.

Default:
  • no CloudFormation init

init_options

Use the given options for applying CloudFormation Init.

Describes the configsets to use and the timeout to wait

Default:
  • default options

instance_name

The name of the instance.

Default:

‘BastionHost’

instance_type

Type of instance to launch.

Default:

‘t3.nano’

machine_image

The machine image to use, assumed to have SSM Agent preinstalled.

Default:

  • An Amazon Linux 2 image which is kept up-to-date automatically (the instance

may be replaced on every deployment) and already has SSM Agent installed.

require_imdsv2

Whether IMDSv2 should be required on this instance.

Default:
  • false

security_group

Security Group to assign to this instance.

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

subnet_selection

Select the subnets to run the bastion host in.

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

Default:
  • private subnets of the supplied VPC

user_data_causes_replacement

Determines whether changes to the UserData will force instance replacement.

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.

Default:
  • true if initOptions is specified, otherwise false.

vpc

VPC to launch the instance in.