Class Instance_
This represents a single EC2 instance.
Inherited Members
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Instance_ : Resource, IInstance, IResource, IConnectable, IGrantable
Syntax (vb)
Public Class Instance_
Inherits Resource
Implements IInstance, IResource, IConnectable, IGrantable
Remarks
ExampleMetadata: infused
Examples
IVpc vpc;
var lb = new LoadBalancer(this, "LB", new LoadBalancerProps {
Vpc = vpc,
InternetFacing = true
});
// instance to add as the target for load balancer.
var instance = new Instance(this, "targetInstance", new InstanceProps {
Vpc = vpc,
InstanceType = InstanceType.Of(InstanceClass.BURSTABLE2, InstanceSize.MICRO),
MachineImage = new AmazonLinuxImage(new AmazonLinuxImageProps { Generation = AmazonLinuxGeneration.AMAZON_LINUX_2 })
});
lb.AddTarget(new InstanceTarget(instance));
Synopsis
Constructors
Instance_(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Instance_(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Instance_(Construct, String, IInstanceProps) |
Properties
Connections | Allows specify security group connections for the instance. |
GrantPrincipal | The principal to grant permissions to. |
Instance | the underlying instance resource. |
InstanceAvailabilityZone | The availability zone the instance was launched in. |
InstanceId | The instance's ID. |
InstancePrivateDnsName | Private DNS name for this instance. |
InstancePrivateIp | Private IP for this instance. |
InstancePublicDnsName | Publicly-routable DNS name for this instance. |
InstancePublicIp | Publicly-routable IP address for this instance. |
OsType | The type of OS the instance is running. |
Role | The IAM role assumed by the instance. |
UserData | UserData for the instance. |
Methods
AddSecurityGroup(ISecurityGroup) | Add the security group to the instance. |
AddToRolePolicy(PolicyStatement) | Adds a statement to the IAM role assumed by the instance. |
AddUserData(String[]) | Add command to the startup script of the instance. |
ApplyCloudFormationInit(CloudFormationInit, IApplyCloudFormationInitOptions) | Use a CloudFormation Init configuration at instance startup. |
Constructors
Instance_(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Instance_(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Instance_(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Instance_(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Instance_(Construct, String, IInstanceProps)
public Instance_(Construct scope, string id, IInstanceProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props IInstanceProps
Properties
Connections
Allows specify security group connections for the instance.
public virtual Connections_ Connections { get; }
Property Value
GrantPrincipal
The principal to grant permissions to.
public virtual IPrincipal GrantPrincipal { get; }
Property Value
Instance
the underlying instance resource.
public virtual CfnInstance Instance { get; }
Property Value
InstanceAvailabilityZone
The availability zone the instance was launched in.
public virtual string InstanceAvailabilityZone { get; }
Property Value
System.String
Remarks
Attribute: true
InstanceId
The instance's ID.
public virtual string InstanceId { get; }
Property Value
System.String
Remarks
Attribute: true
InstancePrivateDnsName
Private DNS name for this instance.
public virtual string InstancePrivateDnsName { get; }
Property Value
System.String
Remarks
Attribute: true
InstancePrivateIp
Private IP for this instance.
public virtual string InstancePrivateIp { get; }
Property Value
System.String
Remarks
Attribute: true
InstancePublicDnsName
Publicly-routable DNS name for this instance.
public virtual string InstancePublicDnsName { get; }
Property Value
System.String
Remarks
(May be an empty string if the instance does not have a public name).
Attribute: true
InstancePublicIp
Publicly-routable IP address for this instance.
public virtual string InstancePublicIp { get; }
Property Value
System.String
Remarks
(May be an empty string if the instance does not have a public IP).
Attribute: true
OsType
The type of OS the instance is running.
public virtual OperatingSystemType OsType { get; }
Property Value
Role
UserData
Methods
AddSecurityGroup(ISecurityGroup)
Add the security group to the instance.
public virtual void AddSecurityGroup(ISecurityGroup securityGroup)
Parameters
- securityGroup ISecurityGroup
: The security group to add.
AddToRolePolicy(PolicyStatement)
Adds a statement to the IAM role assumed by the instance.
public virtual void AddToRolePolicy(PolicyStatement statement)
Parameters
- statement PolicyStatement
AddUserData(String[])
Add command to the startup script of the instance.
public virtual void AddUserData(params string[] commands)
Parameters
- commands System.String[]
Remarks
The command must be in the scripting language supported by the instance's OS (i.e. Linux/Windows).
ApplyCloudFormationInit(CloudFormationInit, IApplyCloudFormationInitOptions)
Use a CloudFormation Init configuration at instance startup.
public virtual void ApplyCloudFormationInit(CloudFormationInit init, IApplyCloudFormationInitOptions options = null)
Parameters
- init CloudFormationInit
- options IApplyCloudFormationInitOptions
Remarks
This does the following: