Interface IInstanceProps
Properties of an EC2 Instance.
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.AWS.EC2.dll
Syntax (csharp)
public interface IInstanceProps
Syntax (vb)
Public Interface IInstanceProps
Remarks
ExampleMetadata: infused
Examples
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
new Instance(this, "Instance", new InstanceProps {
Vpc = vpc,
InstanceType = instanceType,
MachineImage = machineImage,
// ...
BlockDevices = new [] { new BlockDevice {
DeviceName = "/dev/sda1",
Volume = BlockDeviceVolume.Ebs(50)
}, new BlockDevice {
DeviceName = "/dev/sdm",
Volume = BlockDeviceVolume.Ebs(100)
} }
});
Synopsis
Properties
AllowAllOutbound | Whether the instance could initiate connections to anywhere by default. |
AvailabilityZone | In which AZ to place the instance within the VPC. |
BlockDevices | Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes. |
DetailedMonitoring | Whether "Detailed Monitoring" is enabled for this instance Keep in mind that Detailed Monitoring results in extra charges. |
Init | Apply the given CloudFormation Init configuration to the instance at startup. |
InitOptions | Use the given options for applying CloudFormation Init. |
InstanceName | The name of the instance. |
InstanceType | Type of instance to launch. |
KeyName | Name of SSH keypair to grant access to instance. |
MachineImage | AMI to launch. |
PrivateIpAddress | Defines a private IP address to associate with an instance. |
PropagateTagsToVolumeOnCreation | Propagate the EC2 instance tags to the EBS volumes. |
RequireImdsv2 | Whether IMDSv2 should be required on this instance. |
ResourceSignalTimeout | The length of time to wait for the resourceSignalCount. |
Role | An IAM role to associate with the instance profile assigned to this Auto Scaling Group. |
SecurityGroup | Security Group to assign to this instance. |
SourceDestCheck | Specifies whether to enable an instance launched in a VPC to perform NAT. |
UserData | Specific UserData to use. |
UserDataCausesReplacement | Changes to the UserData force replacement. |
Vpc | VPC to launch the instance in. |
VpcSubnets | Where to place the instance within the VPC. |
Properties
AllowAllOutbound
Whether the instance could initiate connections to anywhere by default.
virtual Nullable<bool> AllowAllOutbound { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
This property is only used when you do not provide a security group.
Default: true
AvailabilityZone
In which AZ to place the instance within the VPC.
virtual string AvailabilityZone { get; }
Property Value
System.String
Remarks
Default: - Random zone.
BlockDevices
Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes.
virtual IBlockDevice[] BlockDevices { get; }
Property Value
Remarks
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
DetailedMonitoring
Whether "Detailed Monitoring" is enabled for this instance Keep in mind that Detailed Monitoring results in extra charges.
virtual Nullable<bool> DetailedMonitoring { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: - false
Init
Apply the given CloudFormation Init configuration to the instance at startup.
virtual CloudFormationInit Init { get; }
Property Value
Remarks
Default: - no CloudFormation init
InitOptions
Use the given options for applying CloudFormation Init.
virtual IApplyCloudFormationInitOptions InitOptions { get; }
Property Value
IApplyCloudFormationInitOptions
Remarks
Describes the configsets to use and the timeout to wait
Default: - default options
InstanceName
The name of the instance.
virtual string InstanceName { get; }
Property Value
System.String
Remarks
Default: - CDK generated name
InstanceType
KeyName
Name of SSH keypair to grant access to instance.
virtual string KeyName { get; }
Property Value
System.String
Remarks
Default: - No SSH access will be possible.
MachineImage
PrivateIpAddress
Defines a private IP address to associate with an instance.
virtual string PrivateIpAddress { get; }
Property Value
System.String
Remarks
Private IP should be available within the VPC that the instance is build within.
Default: - no association
PropagateTagsToVolumeOnCreation
Propagate the EC2 instance tags to the EBS volumes.
virtual Nullable<bool> PropagateTagsToVolumeOnCreation { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: - false
RequireImdsv2
Whether IMDSv2 should be required on this instance.
virtual Nullable<bool> RequireImdsv2 { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: - false
ResourceSignalTimeout
The length of time to wait for the resourceSignalCount.
virtual Duration ResourceSignalTimeout { get; }
Property Value
Remarks
The maximum value is 43200 (12 hours).
Default: Duration.minutes(5)
Role
An IAM role to associate with the instance profile assigned to this Auto Scaling Group.
virtual IRole Role { get; }
Property Value
Remarks
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
Examples
var role = new Role(this, "MyRole", new RoleProps {
AssumedBy = new ServicePrincipal("ec2.amazonaws.com")
});
SecurityGroup
Security Group to assign to this instance.
virtual ISecurityGroup SecurityGroup { get; }
Property Value
Remarks
Default: - create new security group
SourceDestCheck
Specifies whether to enable an instance launched in a VPC to perform NAT.
virtual Nullable<bool> SourceDestCheck { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
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
UserData
Specific UserData to use.
virtual UserData UserData { get; }
Property Value
Remarks
The UserData may still be mutated after creation.
Default: - A UserData object appropriate for the MachineImage's Operating System is created.
UserDataCausesReplacement
Changes to the UserData force replacement.
virtual Nullable<bool> UserDataCausesReplacement { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Depending the EC2 instance type, changing UserData either restarts the instance or replaces the instance.
By default, restarting does not execute the new UserData so you will need a different mechanism to ensure the instance is restarted.
Setting this to true
will make the instance's Logical ID depend on the
UserData, which will cause CloudFormation to replace it if the UserData
changes.
Default: - true iff initOptions
is specified, false otherwise.
Vpc
VpcSubnets
Where to place the instance within the VPC.
virtual ISubnetSelection VpcSubnets { get; }
Property Value
Remarks
Default: - Private subnets.