InstanceProps

class aws_cdk.aws_ec2.InstanceProps(*, instance_type, machine_image, vpc, allow_all_outbound=None, availability_zone=None, instance_name=None, key_name=None, resource_signal_timeout=None, role=None, security_group=None, source_dest_check=None, user_data=None, vpc_subnets=None)

Bases: object

__init__(*, instance_type, machine_image, vpc, allow_all_outbound=None, availability_zone=None, instance_name=None, key_name=None, resource_signal_timeout=None, role=None, security_group=None, source_dest_check=None, user_data=None, vpc_subnets=None)

Properties of an EC2 Instance.

Parameters
  • instance_type (InstanceType) – Type of instance to launch.

  • machine_image (IMachineImage) – AMI to launch.

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

  • allow_all_outbound (Optional[bool]) – Whether the instance could initiate connections to anywhere by default. This property is only used when you do not provide a security group. Default: true

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

  • instance_name (Optional[str]) – The name of the instance. Default: - CDK generated name

  • key_name (Optional[str]) – Name of SSH keypair to grant access to instance. Default: - No SSH access will be possible.

  • resource_signal_timeout (Optional[Duration]) – The length of time to wait for the resourceSignalCount. The maximum value is 43200 (12 hours). Default: Duration.minutes(5)

  • role (Optional[IRole]) – An IAM role to associate with the instance profile assigned to this Auto Scaling Group. The role must be assumable by the service principal ec2.amazonaws.com: Default: - A role will automatically be created, it can be accessed via the role property

  • security_group (Optional[ISecurityGroup]) – Security Group to assign to this instance. Default: - create new security group

  • source_dest_check (Optional[bool]) – Specifies whether to enable an instance launched in a VPC to perform NAT. This controls whether source/destination checking is enabled on the instance. A value of true means that checking is enabled, and false means that checking is disabled. The value must be false for the instance to perform NAT. Default: true

  • user_data (Optional[UserData]) – Specific UserData to use. The UserData may still be mutated after creation. Default: - A UserData object appropriate for the MachineImage’s Operating System is created.

  • vpc_subnets (Optional[SubnetSelection]) – Where to place the instance within the VPC. Default: - Private subnets.

Attributes

allow_all_outbound

Whether the instance could initiate connections to anywhere by default. This property is only used when you do not provide a security group.

default :default: true

Return type

Optional[bool]

availability_zone

In which AZ to place the instance within the VPC.

default :default: - Random zone.

Return type

Optional[str]

instance_name

The name of the instance.

default :default: - CDK generated name

Return type

Optional[str]

instance_type

Type of instance to launch.

Return type

InstanceType

key_name

Name of SSH keypair to grant access to instance.

default :default: - No SSH access will be possible.

Return type

Optional[str]

machine_image

AMI to launch.

Return type

IMachineImage

resource_signal_timeout

The length of time to wait for the resourceSignalCount.

The maximum value is 43200 (12 hours).

default :default: Duration.minutes(5)

Return type

Optional[Duration]

role

An IAM role to associate with the instance profile assigned to this Auto Scaling Group.

The role must be assumable by the service principal ec2.amazonaws.com:

default :default: - A role will automatically be created, it can be accessed via the role property

Example::

# Example may have issues. See https://github.com/aws/jsii/issues/826 role = iam.Role(self, “MyRole”,

assumed_by=iam.ServicePrincipal(“ec2.amazonaws.com”)

)

Return type

Optional[IRole]

security_group

Security Group to assign to this instance.

default :default: - create new security group

Return type

Optional[ISecurityGroup]

source_dest_check

Specifies whether to enable an instance launched in a VPC to perform NAT. This controls whether source/destination checking is enabled on the instance. A value of true means that checking is enabled, and false means that checking is disabled. The value must be false for the instance to perform NAT.

default :default: true

Return type

Optional[bool]

user_data

Specific UserData to use.

The UserData may still be mutated after creation.

default :default:

  • A UserData object appropriate for the MachineImage’s Operating System is created.

Return type

Optional[UserData]

vpc

VPC to launch the instance in.

Return type

IVpc

vpc_subnets

Where to place the instance within the VPC.

default :default: - Private subnets.

Return type

Optional[SubnetSelection]