BastionHostLinux

class aws_cdk.aws_ec2.BastionHostLinux(scope, id, *, vpc, availability_zone=None, block_devices=None, instance_name=None, instance_type=None, machine_image=None, security_group=None, subnet_selection=None)

Bases: aws_cdk.core.Resource

(experimental) This creates a linux bastion host you can use to connect to other instances or services in your VPC.

The recommended way to connect to the bastion host is by using AWS Systems Manager Session Manager.

The operating system is Amazon Linux 2 with the latest SSM agent installed

You can also configure this bastion host to allow connections via SSH

Stability

experimental

Resource

AWS::EC2::Instance

Parameters
  • scope (Construct) –

  • id (str) –

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

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

  • block_devices (Optional[List[BlockDevice]]) – (experimental) 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

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

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

  • machine_image (Optional[IMachineImage]) – (experimental) The machine image to use. Default: - An Amazon Linux 2 image which is kept up-to-date automatically (the instance may be replaced on every deployment).

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

  • subnet_selection (Optional[SubnetSelection]) – (experimental) 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

Stability

experimental

Methods

allow_ssh_access_from(*peer)

(experimental) Allow SSH access from the given peer or peers.

Necessary if you want to connect to the instance using ssh. If not called, you should use SSM Session Manager to connect to the instance.

Parameters

peer (IPeer) –

Stability

experimental

Return type

None

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

connections

(experimental) Allows specify security group connections for the instance.

Stability

experimental

Return type

Connections

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

Return type

ResourceEnvironment

grant_principal

(experimental) The principal to grant permissions to.

Stability

experimental

Return type

IPrincipal

instance

(experimental) The underlying instance resource.

Stability

experimental

Return type

Instance

instance_availability_zone

(experimental) The availability zone the instance was launched in.

Stability

experimental

Attribute

true

Return type

str

instance_id

(experimental) The instance’s ID.

Stability

experimental

Attribute

true

Return type

str

instance_private_dns_name

(experimental) Private DNS name for this instance.

Stability

experimental

Attribute

true

Return type

str

instance_private_ip

(experimental) Private IP for this instance.

Stability

experimental

Attribute

true

Return type

str

instance_public_dns_name

(experimental) Publicly-routable DNS name for this instance.

(May be an empty string if the instance does not have a public name).

Stability

experimental

Attribute

true

Return type

str

instance_public_ip

(experimental) Publicly-routable IP address for this instance.

(May be an empty string if the instance does not have a public IP).

Stability

experimental

Attribute

true

Return type

str

node

The construct tree node associated with this construct.

Return type

ConstructNode

role

(experimental) The IAM role assumed by the instance.

Stability

experimental

Return type

IRole

stack

(experimental) The stack in which this resource is defined.

Stability

experimental

Return type

Stack

Static Methods

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool