AWS::OpsWorks::Instance
Creates an Amazon Elastic Compute Cloud (Amazon EC2) instance for an AWS OpsWorks stack. Instances for AWS OpsWorks stacks handle the work of serving applications and balancing traffic, for example.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type": "AWS::OpsWorks::Instance", "Properties": { "AgentVersion" :String, "AmiId" :String, "Architecture" :String, "AutoScalingType" :String, "AvailabilityZone" :String, "BlockDeviceMappings" : [BlockDeviceMapping, ...], "EbsOptimized" :Boolean, "ElasticIps" : [String, ...], "Hostname" :String, "InstallUpdatesOnBoot" :Boolean, "InstanceType" :String, "LayerIds" : [String, ...], "Os" :String, "RootDeviceType" :String, "SshKeyName" :String, "StackId" :String, "SubnetId" :String, "Tenancy" :String, "TimeBasedAutoScaling" :TimeBasedAutoScaling, "VirtualizationType" :String, "Volumes" : [String, ...] } }
YAML
Type: "AWS::OpsWorks::Instance" Properties: AgentVersion:StringAmiId:StringArchitecture:StringAutoScalingType:StringAvailabilityZone:StringBlockDeviceMappings: -BlockDeviceMappingEbsOptimized:BooleanElasticIps: -StringHostname:StringInstallUpdatesOnBoot:BooleanInstanceType:StringLayerIds: -StringOs:StringRootDeviceType:StringSshKeyName:StringStackId:StringSubnetId:StringTenancy:StringTimeBasedAutoScaling:TimeBasedAutoScalingVirtualizationType:StringVolumes: -String
Properties
AgentVersion-
The version of the AWS OpsWorks agent that AWS OpsWorks installs on each instance. AWS OpsWorks sends commands to the agent to performs tasks on your instances, such as starting Chef runs. For valid values, see the
AgentVersionparameter for the CreateInstance action in the AWS OpsWorks Stacks API Reference.Required: No
Type: String
Update requires: No interruption
AmiId-
The ID of the custom Amazon Machine Image (AMI) to be used to create the instance. For more information about custom AMIs, see Using Custom AMIs in the AWS OpsWorks User Guide.
Note
If you specify this property, you must set the
Osproperty toCustom.Required: No
Type: String
Update requires: Updates are not supported.
Architecture-
The instance architecture.
Required: No
Type: String
Update requires: Some interruptions
AutoScalingType-
For scaling instances, the type of scaling. If you specify load-based scaling, do not specify a time-based scaling configuration. For valid values, see CreateInstance in the AWS OpsWorks Stacks API Reference.
Required: No
Type: String
Update requires: Replacement
AvailabilityZone-
The instance Availability Zone.
Required: No
Type: String
Update requires: Replacement
BlockDeviceMappings-
A list of block devices that are mapped to the AWS OpsWorks instance. For more information, see the
BlockDeviceMappingsparameter for the CreateInstance action in the AWS OpsWorks Stacks API Reference.Required: No
Type: List of AWS OpsWorks Instance BlockDeviceMapping
Update requires: Replacement
EbsOptimized-
Whether the instance is optimized for Amazon Elastic Block Store (Amazon EBS) I/O. If you specify an Amazon EBS-optimized instance type, AWS OpsWorks enables EBS optimization by default. For more information, see Amazon EBS–Optimized Instances in the Amazon EC2 User Guide for Linux Instances.
Required: No
Type: Boolean
Update requires: Replacement
ElasticIps-
A list of Elastic IP addresses to associate with the instance.
Required: No
Type: List of String values
Update requires: No interruption
Hostname-
The name of the instance host.
Required: No
Type: String
Update requires: No interruption
InstallUpdatesOnBoot-
Whether to install operating system and package updates when the instance boots.
Required: No
Type: Boolean
Update requires: Some interruptions
InstanceType-
The instance type, which must be supported by AWS OpsWorks. For more information, see CreateInstance in the AWS OpsWorks Stacks API Reference.
If you specify an Amazon EBS-optimized instance type, AWS OpsWorks enables EBS optimization by default. For more information about Amazon EBS-optimized instance types, see Amazon EBS–Optimized Instances in the Amazon EC2 User Guide for Linux Instances.
Required: Yes
Type: String
Update requires: Some interruptions
LayerIds-
The IDs of the AWS OpsWorks layers to associate with this instance.
Required: Yes
Type: List of String values
Update requires: Some interruptions
Os-
The instance operating system. For more information, see CreateInstance in the AWS OpsWorks Stacks API Reference.
Required: No
Type: String
Update requires: Replacement
RootDeviceType-
The root device type of the instance.
Required: No
Type: String
Update requires: Replacement
SshKeyName-
The SSH key name of the instance.
Required: No
Type: String
Update requires: Some interruptions
StackId-
The ID of the AWS OpsWorks stack that this instance will be associated with.
Required: Yes
Type: String
Update requires: Replacement
SubnetId-
The ID of the instance's subnet. If the stack is running in a VPC, you can use this parameter to override the stack's default subnet ID value and direct AWS OpsWorks to launch the instance in a different subnet.
Required: No
Type: String
Update requires: Replacement
Tenancy-
The tenancy of the instance. For more information, see the
Tenancyparameter for the CreateInstance action in the AWS OpsWorks Stacks API Reference.Required: No
Type: String
Update requires: Replacement
TimeBasedAutoScaling-
The time-based scaling configuration for the instance.
Required: No
Type: AWS OpsWorks TimeBasedAutoScaling Type
Update requires: Replacement
VirtualizationType-
The instance's virtualization type,
paravirtualorhvm.Required: No
Type: String
Update requires: Replacement
Volumes-
A list of AWS OpsWorks volume IDs to associate with the instance. For more information, see AWS::OpsWorks::Volume.
Required: No
Type: List of String values
Update requires: No interruption
Return Values
Ref
When the logical ID of this resource is provided to the Ref intrinsic
function, Ref returns the resource name. For example:
{ "Ref": "myInstance1" }
For the AWS OpsWorks instance myInstance1, Ref returns the
AWS OpsWorks instance ID.
For more information about using the Ref function, see Ref.
Fn::GetAtt
Fn::GetAtt returns a value for a specified attribute of this type.
The following are the available attributes and sample return values.
-
AvailabilityZoneThe Availability Zone of the AWS OpsWorks instance, such as
us-east-2a. -
PrivateDnsNameThe private DNS name of the AWS OpsWorks instance.
-
PrivateIpThe private IP address of the AWS OpsWorks instance, such as
192.0.2.0. -
PublicDnsNameThe public DNS name of the AWS OpsWorks instance.
-
PublicIpThe public IP address of the AWS OpsWorks instance, such as
192.0.2.0.Note
Use this attribute only when the AWS OpsWorks instance is in an AWS OpsWorks layer that auto-assigns public IP addresses.
For more information about using Fn::GetAtt, see Fn::GetAtt.
Examples
Create Basic AWS OpsWorks Instances
The following example creates two AWS OpsWorks instances that are associated with
the
myStack AWS OpsWorks stack and the myLayer AWS OpsWorks layer:
JSON
"myInstance1" : { "Type" : "AWS::OpsWorks::Instance", "Properties" : { "StackId" : {"Ref":"myStack"}, "LayerIds" : [{"Ref":"myLayer"}], "InstanceType" : "m1.small" } }, "myInstance2" : { "Type" : "AWS::OpsWorks::Instance", "Properties" : { "StackId" : {"Ref":"myStack"}, "LayerIds" : [{"Ref":"myLayer"}], "InstanceType" : "m1.small" } }
YAML
myInstance1: Type: "AWS::OpsWorks::Instance" Properties: StackId: Ref: "myStack" LayerIds: - Ref: "myLayer" InstanceType: "m1.small" myInstance2: Type: "AWS::OpsWorks::Instance" Properties: StackId: Ref: "myStack" LayerIds: - Ref: "myLayer" InstanceType: "m1.small"
Define a Time-based Auto Scaling Instance
In the following example, the DBInstance instance is online for four
hours from UTC 1200-1600 on Friday, Saturday, and Sunday. The instance is offline
for
all other times and days.
JSON
"DBInstance" : { "Type" : "AWS::OpsWorks::Instance", "Properties" : { "AutoScalingType" : "timer", "StackId" : {"Ref":"Stack"}, "LayerIds" : [{"Ref":"DBLayer"}], "InstanceType" : "m1.small", "TimeBasedAutoScaling" : { "Friday" : { "12" : "on", "13" : "on", "14" : "on", "15" : "on" }, "Saturday" : { "12" : "on", "13" : "on", "14" : "on", "15" : "on" }, "Sunday" : { "12" : "on", "13" : "on", "14" : "on", "15" : "on" } } } }
YAML
DBInstance: Type: "AWS::OpsWorks::Instance" Properties: AutoScalingType: "timer" StackId: Ref: "Stack" LayerIds: - Ref: "DBLayer" InstanceType: "m1.small" TimeBasedAutoScaling: Friday: 12: "on" 13: "on" 14: "on" 15: "on" Saturday: 12: "on" 13: "on" 14: "on" 15: "on" Sunday: 12: "on" 13: "on" 14: "on" 15: "on"
