Class: AWSCDK::EC2::BastionHostLinuxProps
- Inherits:
-
Jsii::Struct
- Object
- Jsii::Struct
- AWSCDK::EC2::BastionHostLinuxProps
- Defined in:
- ec2/bastion_host_linux_props.rb
Overview
Properties of the bastion host.
Instance Attribute Summary collapse
-
#availability_zone ⇒ String?
readonly
In which AZ to place the instance within the VPC.
-
#block_devices ⇒ Array<AWSCDK::EC2::BlockDevice>?
readonly
Specifies how block devices are exposed to the instance.
-
#init ⇒ AWSCDK::EC2::CloudFormationInit?
readonly
Apply the given CloudFormation Init configuration to the instance at startup.
-
#init_options ⇒ AWSCDK::EC2::ApplyCloudFormationInitOptions?
readonly
Use the given options for applying CloudFormation Init.
-
#instance_name ⇒ String?
readonly
The name of the instance.
-
#instance_type ⇒ AWSCDK::EC2::InstanceType?
readonly
Type of instance to launch.
-
#machine_image ⇒ AWSCDK::EC2::IMachineImage?
readonly
The machine image to use, assumed to have SSM Agent preinstalled.
-
#require_imdsv2 ⇒ Boolean?
readonly
Whether IMDSv2 should be required on this instance.
-
#security_group ⇒ AWSCDK::EC2::ISecurityGroup?
readonly
Security Group to assign to this instance.
-
#subnet_selection ⇒ AWSCDK::EC2::SubnetSelection?
readonly
Select the subnets to run the bastion host in.
-
#user_data_causes_replacement ⇒ Boolean?
readonly
Determines whether changes to the UserData will force instance replacement.
-
#vpc ⇒ AWSCDK::EC2::IVPC
readonly
VPC to launch the instance in.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(vpc:, availability_zone: nil, block_devices: nil, init: nil, init_options: nil, instance_name: nil, instance_type: nil, machine_image: nil, require_imdsv2: nil, security_group: nil, subnet_selection: nil, user_data_causes_replacement: nil) ⇒ BastionHostLinuxProps
constructor
A new instance of BastionHostLinuxProps.
- #to_jsii ⇒ Object
Constructor Details
#initialize(vpc:, availability_zone: nil, block_devices: nil, init: nil, init_options: nil, instance_name: nil, instance_type: nil, machine_image: nil, require_imdsv2: nil, security_group: nil, subnet_selection: nil, user_data_causes_replacement: nil) ⇒ BastionHostLinuxProps
Returns a new instance of BastionHostLinuxProps.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'ec2/bastion_host_linux_props.rb', line 19 def initialize(vpc:, availability_zone: nil, block_devices: nil, init: nil, init_options: nil, instance_name: nil, instance_type: nil, machine_image: nil, require_imdsv2: nil, security_group: nil, subnet_selection: nil, user_data_causes_replacement: nil) @vpc = vpc Jsii::Type.check_type(@vpc, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklWcGMifQ==")), "vpc") @availability_zone = availability_zone Jsii::Type.check_type(@availability_zone, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "availabilityZone") unless @availability_zone.nil? @block_devices = block_devices.is_a?(Array) ? block_devices.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::EC2::BlockDevice.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : block_devices Jsii::Type.check_type(@block_devices, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lYzIuQmxvY2tEZXZpY2UifSwia2luZCI6ImFycmF5In19")), "blockDevices") unless @block_devices.nil? @init = init Jsii::Type.check_type(@init, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkNsb3VkRm9ybWF0aW9uSW5pdCJ9")), "init") unless @init.nil? @init_options = .is_a?(Hash) ? ::AWSCDK::EC2::ApplyCloudFormationInitOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(@init_options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkFwcGx5Q2xvdWRGb3JtYXRpb25Jbml0T3B0aW9ucyJ9")), "initOptions") unless @init_options.nil? @instance_name = instance_name Jsii::Type.check_type(@instance_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "instanceName") unless @instance_name.nil? @instance_type = instance_type Jsii::Type.check_type(@instance_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluc3RhbmNlVHlwZSJ9")), "instanceType") unless @instance_type.nil? @machine_image = machine_image Jsii::Type.check_type(@machine_image, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklNYWNoaW5lSW1hZ2UifQ==")), "machineImage") unless @machine_image.nil? @require_imdsv2 = require_imdsv2 Jsii::Type.check_type(@require_imdsv2, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "requireImdsv2") unless @require_imdsv2.nil? @security_group = security_group Jsii::Type.check_type(@security_group, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklTZWN1cml0eUdyb3VwIn0=")), "securityGroup") unless @security_group.nil? @subnet_selection = subnet_selection.is_a?(Hash) ? ::AWSCDK::EC2::SubnetSelection.new(**subnet_selection.transform_keys(&:to_sym)) : subnet_selection Jsii::Type.check_type(@subnet_selection, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlN1Ym5ldFNlbGVjdGlvbiJ9")), "subnetSelection") unless @subnet_selection.nil? @user_data_causes_replacement = user_data_causes_replacement Jsii::Type.check_type(@user_data_causes_replacement, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "userDataCausesReplacement") unless @user_data_causes_replacement.nil? end |
Instance Attribute Details
#availability_zone ⇒ String? (readonly)
Default: - Random zone.
In which AZ to place the instance within the VPC.
54 55 56 |
# File 'ec2/bastion_host_linux_props.rb', line 54 def availability_zone @availability_zone end |
#block_devices ⇒ Array<AWSCDK::EC2::BlockDevice>? (readonly)
Default: - Uses the block device mapping of the AMI
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.
65 66 67 |
# File 'ec2/bastion_host_linux_props.rb', line 65 def block_devices @block_devices end |
#init ⇒ AWSCDK::EC2::CloudFormationInit? (readonly)
Default: - no CloudFormation init
Apply the given CloudFormation Init configuration to the instance at startup.
70 71 72 |
# File 'ec2/bastion_host_linux_props.rb', line 70 def init @init end |
#init_options ⇒ AWSCDK::EC2::ApplyCloudFormationInitOptions? (readonly)
Default: - default options
Use the given options for applying CloudFormation Init.
Describes the configsets to use and the timeout to wait
77 78 79 |
# File 'ec2/bastion_host_linux_props.rb', line 77 def @init_options end |
#instance_name ⇒ String? (readonly)
Default: 'BastionHost'
The name of the instance.
82 83 84 |
# File 'ec2/bastion_host_linux_props.rb', line 82 def instance_name @instance_name end |
#instance_type ⇒ AWSCDK::EC2::InstanceType? (readonly)
Default: 't3.nano'
Type of instance to launch.
87 88 89 |
# File 'ec2/bastion_host_linux_props.rb', line 87 def instance_type @instance_type end |
#machine_image ⇒ AWSCDK::EC2::IMachineImage? (readonly)
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.
The machine image to use, assumed to have SSM Agent preinstalled.
92 93 94 |
# File 'ec2/bastion_host_linux_props.rb', line 92 def machine_image @machine_image end |
#require_imdsv2 ⇒ Boolean? (readonly)
Default: - false
Whether IMDSv2 should be required on this instance.
97 98 99 |
# File 'ec2/bastion_host_linux_props.rb', line 97 def require_imdsv2 @require_imdsv2 end |
#security_group ⇒ AWSCDK::EC2::ISecurityGroup? (readonly)
Default: - create new security group with no inbound and all outbound traffic allowed
Security Group to assign to this instance.
102 103 104 |
# File 'ec2/bastion_host_linux_props.rb', line 102 def security_group @security_group end |
#subnet_selection ⇒ AWSCDK::EC2::SubnetSelection? (readonly)
Default: - private subnets of the supplied VPC
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
110 111 112 |
# File 'ec2/bastion_host_linux_props.rb', line 110 def subnet_selection @subnet_selection end |
#user_data_causes_replacement ⇒ Boolean? (readonly)
Default: - true if initOptions is specified, otherwise false.
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.
127 128 129 |
# File 'ec2/bastion_host_linux_props.rb', line 127 def user_data_causes_replacement @user_data_causes_replacement end |
#vpc ⇒ AWSCDK::EC2::IVPC (readonly)
VPC to launch the instance in.
49 50 51 |
# File 'ec2/bastion_host_linux_props.rb', line 49 def vpc @vpc end |
Class Method Details
.jsii_properties ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'ec2/bastion_host_linux_props.rb', line 129 def self.jsii_properties { :vpc => "vpc", :availability_zone => "availabilityZone", :block_devices => "blockDevices", :init => "init", :init_options => "initOptions", :instance_name => "instanceName", :instance_type => "instanceType", :machine_image => "machineImage", :require_imdsv2 => "requireImdsv2", :security_group => "securityGroup", :subnet_selection => "subnetSelection", :user_data_causes_replacement => "userDataCausesReplacement", } end |
Instance Method Details
#to_jsii ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'ec2/bastion_host_linux_props.rb', line 146 def to_jsii result = {} result.merge!({ "vpc" => @vpc, "availabilityZone" => @availability_zone, "blockDevices" => @block_devices, "init" => @init, "initOptions" => @init_options, "instanceName" => @instance_name, "instanceType" => @instance_type, "machineImage" => @machine_image, "requireImdsv2" => @require_imdsv2, "securityGroup" => @security_group, "subnetSelection" => @subnet_selection, "userDataCausesReplacement" => @user_data_causes_replacement, }) result.compact end |