Class CfnInstance
Specifies an EC2 instance.
Inherited Members
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class CfnInstance : CfnResource, IInspectable, ITaggable
Syntax (vb)
Public Class CfnInstance
Inherits CfnResource
Implements IInspectable, ITaggable
Remarks
If an Elastic IP address is attached to your instance, AWS CloudFormation reattaches the Elastic IP address after it updates the instance. For more information about updating stacks, see AWS CloudFormation Stacks Updates .
See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instance.html
CloudformationResource: AWS::EC2::Instance
ExampleMetadata: fixture=_generated
Examples
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.EC2;
var cfnInstance = new CfnInstance(this, "MyCfnInstance", new CfnInstanceProps {
AdditionalInfo = "additionalInfo",
Affinity = "affinity",
AvailabilityZone = "availabilityZone",
BlockDeviceMappings = new [] { new BlockDeviceMappingProperty {
DeviceName = "deviceName",
// the properties below are optional
Ebs = new EbsProperty {
DeleteOnTermination = false,
Encrypted = false,
Iops = 123,
KmsKeyId = "kmsKeyId",
SnapshotId = "snapshotId",
VolumeSize = 123,
VolumeType = "volumeType"
},
NoDevice = new NoDeviceProperty { },
VirtualName = "virtualName"
} },
CpuOptions = new CpuOptionsProperty {
CoreCount = 123,
ThreadsPerCore = 123
},
CreditSpecification = new CreditSpecificationProperty {
CpuCredits = "cpuCredits"
},
DisableApiTermination = false,
EbsOptimized = false,
ElasticGpuSpecifications = new [] { new ElasticGpuSpecificationProperty {
Type = "type"
} },
ElasticInferenceAccelerators = new [] { new ElasticInferenceAcceleratorProperty {
Type = "type",
// the properties below are optional
Count = 123
} },
EnclaveOptions = new EnclaveOptionsProperty {
Enabled = false
},
HibernationOptions = new HibernationOptionsProperty {
Configured = false
},
HostId = "hostId",
HostResourceGroupArn = "hostResourceGroupArn",
IamInstanceProfile = "iamInstanceProfile",
ImageId = "imageId",
InstanceInitiatedShutdownBehavior = "instanceInitiatedShutdownBehavior",
InstanceType = "instanceType",
Ipv6AddressCount = 123,
Ipv6Addresses = new [] { new InstanceIpv6AddressProperty {
Ipv6Address = "ipv6Address"
} },
KernelId = "kernelId",
KeyName = "keyName",
LaunchTemplate = new LaunchTemplateSpecificationProperty {
Version = "version",
// the properties below are optional
LaunchTemplateId = "launchTemplateId",
LaunchTemplateName = "launchTemplateName"
},
LicenseSpecifications = new [] { new LicenseSpecificationProperty {
LicenseConfigurationArn = "licenseConfigurationArn"
} },
Monitoring = false,
NetworkInterfaces = new [] { new NetworkInterfaceProperty {
DeviceIndex = "deviceIndex",
// the properties below are optional
AssociateCarrierIpAddress = false,
AssociatePublicIpAddress = false,
DeleteOnTermination = false,
Description = "description",
GroupSet = new [] { "groupSet" },
Ipv6AddressCount = 123,
Ipv6Addresses = new [] { new InstanceIpv6AddressProperty {
Ipv6Address = "ipv6Address"
} },
NetworkInterfaceId = "networkInterfaceId",
PrivateIpAddress = "privateIpAddress",
PrivateIpAddresses = new [] { new PrivateIpAddressSpecificationProperty {
Primary = false,
PrivateIpAddress = "privateIpAddress"
} },
SecondaryPrivateIpAddressCount = 123,
SubnetId = "subnetId"
} },
PlacementGroupName = "placementGroupName",
PrivateDnsNameOptions = new PrivateDnsNameOptionsProperty {
EnableResourceNameDnsAaaaRecord = false,
EnableResourceNameDnsARecord = false,
HostnameType = "hostnameType"
},
PrivateIpAddress = "privateIpAddress",
PropagateTagsToVolumeOnCreation = false,
RamdiskId = "ramdiskId",
SecurityGroupIds = new [] { "securityGroupIds" },
SecurityGroups = new [] { "securityGroups" },
SourceDestCheck = false,
SsmAssociations = new [] { new SsmAssociationProperty {
DocumentName = "documentName",
// the properties below are optional
AssociationParameters = new [] { new AssociationParameterProperty {
Key = "key",
Value = new [] { "value" }
} }
} },
SubnetId = "subnetId",
Tags = new [] { new CfnTag {
Key = "key",
Value = "value"
} },
Tenancy = "tenancy",
UserData = "userData",
Volumes = new [] { new VolumeProperty {
Device = "device",
VolumeId = "volumeId"
} }
});
Synopsis
Constructors
CfnInstance(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CfnInstance(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
CfnInstance(Construct, String, ICfnInstanceProps) |
Properties
AdditionalInfo | This property is reserved for internal use. |
Affinity | Indicates whether the instance is associated with a dedicated host. |
AttrAvailabilityZone | |
AttrInstanceId | The ID of the instance. |
AttrPrivateDnsName | The private DNS name of the specified instance. |
AttrPrivateIp | The private IP address of the specified instance. |
AttrPublicDnsName | The public DNS name of the specified instance. |
AttrPublicIp | The public IP address of the specified instance. |
AttrState | The current state of the instance. |
AttrVpcId | The ID of the VPC in which the instance is running. |
AvailabilityZone | The Availability Zone of the instance. |
BlockDeviceMappings | The block device mapping entries that defines the block devices to attach to the instance at launch. |
CFN_RESOURCE_TYPE_NAME | The CloudFormation resource type name for this resource class. |
CfnProperties | |
CpuOptions | The CPU options for the instance. |
CreditSpecification | The credit option for CPU usage of the burstable performance instance. |
DisableApiTermination | If you set this parameter to |
EbsOptimized | Indicates whether the instance is optimized for Amazon EBS I/O. |
ElasticGpuSpecifications | An elastic GPU to associate with the instance. |
ElasticInferenceAccelerators | An elastic inference accelerator to associate with the instance. |
EnclaveOptions | Indicates whether the instance is enabled for AWS Nitro Enclaves. |
HibernationOptions | Indicates whether an instance is enabled for hibernation. |
HostId | If you specify host for the |
HostResourceGroupArn | The ARN of the host resource group in which to launch the instances. |
IamInstanceProfile | The name of an IAM instance profile. |
ImageId | The ID of the AMI. |
InstanceInitiatedShutdownBehavior | Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown). |
InstanceType | The instance type. |
Ipv6AddressCount | The number of IPv6 addresses to associate with the primary network interface. |
Ipv6Addresses | The IPv6 addresses from the range of the subnet to associate with the primary network interface. |
KernelId | The ID of the kernel. |
KeyName | The name of the key pair. |
LaunchTemplate | The launch template. |
LicenseSpecifications | The license configurations. |
Monitoring | Specifies whether detailed monitoring is enabled for the instance. |
NetworkInterfaces | The network interfaces to associate with the instance. |
PlacementGroupName | The name of an existing placement group that you want to launch the instance into (cluster | partition | spread). |
PrivateDnsNameOptions | The options for the instance hostname. |
PrivateIpAddress | The primary IPv4 address. |
PropagateTagsToVolumeOnCreation | Indicates whether to assign the tags from the instance to all of the volumes attached to the instance at launch. |
RamdiskId | The ID of the RAM disk to select. |
SecurityGroupIds | The IDs of the security groups. |
SecurityGroups | [Default VPC] The names of the security groups. |
SourceDestCheck | Enable or disable source/destination checks, which ensure that the instance is either the source or the destination of any traffic that it receives. |
SsmAssociations | The SSM document and parameter values in AWS Systems Manager to associate with this instance. To use this property, you must specify an IAM instance profile role for the instance. For more information, see Create an IAM instance profile for Systems Manager in the AWS Systems Manager User Guide . |
SubnetId | The ID of the subnet to launch the instance into. |
Tags | Tag Manager which manages the tags for this resource. |
TagsRaw | The tags to add to the instance. |
Tenancy | The tenancy of the instance. |
UserData | The parameters or scripts to store as user data. |
Volumes | The volumes to attach to the instance. |
Methods
Inspect(TreeInspector) | Examines the CloudFormation resource and discloses attributes. |
RenderProperties(IDictionary<String, Object>) |
Constructors
CfnInstance(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CfnInstance(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CfnInstance(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CfnInstance(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
CfnInstance(Construct, String, ICfnInstanceProps)
public CfnInstance(Construct scope, string id, ICfnInstanceProps props = null)
Parameters
- scope Constructs.Construct
Scope in which this resource is defined.
- id System.String
Construct identifier for this resource (unique in its scope).
- props ICfnInstanceProps
Resource properties.
Properties
AdditionalInfo
This property is reserved for internal use.
public virtual string AdditionalInfo { get; set; }
Property Value
System.String
Affinity
Indicates whether the instance is associated with a dedicated host.
public virtual string Affinity { get; set; }
Property Value
System.String
AttrAvailabilityZone
public virtual string AttrAvailabilityZone { get; }
Property Value
System.String
Remarks
CloudformationAttribute: AvailabilityZone
AttrInstanceId
The ID of the instance.
public virtual string AttrInstanceId { get; }
Property Value
System.String
Remarks
CloudformationAttribute: InstanceId
AttrPrivateDnsName
The private DNS name of the specified instance.
public virtual string AttrPrivateDnsName { get; }
Property Value
System.String
Remarks
For example: ip-10-24-34-0.ec2.internal
.
CloudformationAttribute: PrivateDnsName
AttrPrivateIp
The private IP address of the specified instance.
public virtual string AttrPrivateIp { get; }
Property Value
System.String
Remarks
For example: 10.24.34.0
.
CloudformationAttribute: PrivateIp
AttrPublicDnsName
The public DNS name of the specified instance.
public virtual string AttrPublicDnsName { get; }
Property Value
System.String
Remarks
For example: ec2-107-20-50-45.compute-1.amazonaws.com
.
CloudformationAttribute: PublicDnsName
AttrPublicIp
The public IP address of the specified instance.
public virtual string AttrPublicIp { get; }
Property Value
System.String
Remarks
For example: 192.0.2.0
.
CloudformationAttribute: PublicIp
AttrState
The current state of the instance.
public virtual IResolvable AttrState { get; }
Property Value
Remarks
CloudformationAttribute: State
AttrVpcId
The ID of the VPC in which the instance is running.
public virtual string AttrVpcId { get; }
Property Value
System.String
Remarks
CloudformationAttribute: VpcId
AvailabilityZone
The Availability Zone of the instance.
public virtual string AvailabilityZone { get; set; }
Property Value
System.String
BlockDeviceMappings
The block device mapping entries that defines the block devices to attach to the instance at launch.
public virtual object BlockDeviceMappings { get; set; }
Property Value
System.Object
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
public static string CFN_RESOURCE_TYPE_NAME { get; }
Property Value
System.String
CfnProperties
protected override IDictionary<string, object> CfnProperties { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>
Overrides
CpuOptions
The CPU options for the instance.
public virtual object CpuOptions { get; set; }
Property Value
System.Object
CreditSpecification
The credit option for CPU usage of the burstable performance instance.
public virtual object CreditSpecification { get; set; }
Property Value
System.Object
DisableApiTermination
If you set this parameter to true
, you can't terminate the instance using the Amazon EC2 console, CLI, or API;
public virtual object DisableApiTermination { get; set; }
Property Value
System.Object
EbsOptimized
Indicates whether the instance is optimized for Amazon EBS I/O.
public virtual object EbsOptimized { get; set; }
Property Value
System.Object
ElasticGpuSpecifications
An elastic GPU to associate with the instance.
public virtual object ElasticGpuSpecifications { get; set; }
Property Value
System.Object
ElasticInferenceAccelerators
An elastic inference accelerator to associate with the instance.
public virtual object ElasticInferenceAccelerators { get; set; }
Property Value
System.Object
EnclaveOptions
Indicates whether the instance is enabled for AWS Nitro Enclaves.
public virtual object EnclaveOptions { get; set; }
Property Value
System.Object
HibernationOptions
Indicates whether an instance is enabled for hibernation.
public virtual object HibernationOptions { get; set; }
Property Value
System.Object
HostId
If you specify host for the Affinity
property, the ID of a dedicated host that the instance is associated with.
public virtual string HostId { get; set; }
Property Value
System.String
HostResourceGroupArn
The ARN of the host resource group in which to launch the instances.
public virtual string HostResourceGroupArn { get; set; }
Property Value
System.String
IamInstanceProfile
The name of an IAM instance profile.
public virtual string IamInstanceProfile { get; set; }
Property Value
System.String
ImageId
The ID of the AMI.
public virtual string ImageId { get; set; }
Property Value
System.String
InstanceInitiatedShutdownBehavior
Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).
public virtual string InstanceInitiatedShutdownBehavior { get; set; }
Property Value
System.String
InstanceType
The instance type.
public virtual string InstanceType { get; set; }
Property Value
System.String
Remarks
For more information, see Instance types in the Amazon EC2 User Guide .
Ipv6AddressCount
The number of IPv6 addresses to associate with the primary network interface.
public virtual Nullable<double> Ipv6AddressCount { get; set; }
Property Value
System.Nullable<System.Double>
Ipv6Addresses
The IPv6 addresses from the range of the subnet to associate with the primary network interface.
public virtual object Ipv6Addresses { get; set; }
Property Value
System.Object
KernelId
The ID of the kernel.
public virtual string KernelId { get; set; }
Property Value
System.String
KeyName
The name of the key pair.
public virtual string KeyName { get; set; }
Property Value
System.String
Remarks
You can create a key pair using CreateKeyPair or ImportKeyPair .
LaunchTemplate
The launch template.
public virtual object LaunchTemplate { get; set; }
Property Value
System.Object
LicenseSpecifications
The license configurations.
public virtual object LicenseSpecifications { get; set; }
Property Value
System.Object
Monitoring
Specifies whether detailed monitoring is enabled for the instance.
public virtual object Monitoring { get; set; }
Property Value
System.Object
NetworkInterfaces
The network interfaces to associate with the instance.
public virtual object NetworkInterfaces { get; set; }
Property Value
System.Object
PlacementGroupName
The name of an existing placement group that you want to launch the instance into (cluster | partition | spread).
public virtual string PlacementGroupName { get; set; }
Property Value
System.String
PrivateDnsNameOptions
The options for the instance hostname.
public virtual object PrivateDnsNameOptions { get; set; }
Property Value
System.Object
PrivateIpAddress
The primary IPv4 address.
public virtual string PrivateIpAddress { get; set; }
Property Value
System.String
Remarks
You must specify a value from the IPv4 address range of the subnet.
PropagateTagsToVolumeOnCreation
Indicates whether to assign the tags from the instance to all of the volumes attached to the instance at launch.
public virtual object PropagateTagsToVolumeOnCreation { get; set; }
Property Value
System.Object
RamdiskId
The ID of the RAM disk to select.
public virtual string RamdiskId { get; set; }
Property Value
System.String
SecurityGroupIds
The IDs of the security groups.
public virtual string[] SecurityGroupIds { get; set; }
Property Value
System.String[]
SecurityGroups
[Default VPC] The names of the security groups.
public virtual string[] SecurityGroups { get; set; }
Property Value
System.String[]
Remarks
For a nondefault VPC, you must use security group IDs instead.
SourceDestCheck
Enable or disable source/destination checks, which ensure that the instance is either the source or the destination of any traffic that it receives.
public virtual object SourceDestCheck { get; set; }
Property Value
System.Object
SsmAssociations
The SSM document and parameter values in AWS Systems Manager to associate with this instance. To use this property, you must specify an IAM instance profile role for the instance. For more information, see Create an IAM instance profile for Systems Manager in the AWS Systems Manager User Guide .
public virtual object SsmAssociations { get; set; }
Property Value
System.Object
SubnetId
The ID of the subnet to launch the instance into.
public virtual string SubnetId { get; set; }
Property Value
System.String
Tags
Tag Manager which manages the tags for this resource.
public virtual TagManager Tags { get; }
Property Value
TagsRaw
The tags to add to the instance.
public virtual ICfnTag[] TagsRaw { get; set; }
Property Value
ICfnTag[]
Tenancy
The tenancy of the instance.
public virtual string Tenancy { get; set; }
Property Value
System.String
UserData
The parameters or scripts to store as user data.
public virtual string UserData { get; set; }
Property Value
System.String
Volumes
The volumes to attach to the instance.
public virtual object Volumes { get; set; }
Property Value
System.Object
Methods
Inspect(TreeInspector)
Examines the CloudFormation resource and discloses attributes.
public virtual void Inspect(TreeInspector inspector)
Parameters
- inspector TreeInspector
tree inspector to collect and process attributes.
RenderProperties(IDictionary<String, Object>)
protected override IDictionary<string, object> RenderProperties(IDictionary<string, object> props)
Parameters
- props System.Collections.Generic.IDictionary<System.String, System.Object>
Returns
System.Collections.Generic.IDictionary<System.String, System.Object>