AWS Amazon EC2 Auto Scaling Attachment
This page shows how to write Terraform and CloudFormation for Amazon EC2 Auto Scaling Attachment and write them securely.
aws_autoscaling_attachment (Terraform)
The Attachment in Amazon EC2 Auto Scaling can be configured in Terraform with the resource name aws_autoscaling_attachment. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
alb_target_group_arnoptional - string -
autoscaling_group_namerequired - string -
elboptional - string -
idoptional computed - string
Explanation in Terraform Registry
Provides an Auto Scaling Attachment resource.
NOTE on Auto Scaling Groups and ASG Attachments: Terraform currently provides both a standalone
aws_autoscaling_attachmentresource (describing an ASG attached to an ELB or ALB), and anaws_autoscaling_groupwithload_balancersandtarget_group_arnsdefined in-line. These two methods are not mutually-exclusive. Ifaws_autoscaling_attachmentresources are used, either alone or with inlineload_balancersortarget_group_arns, theaws_autoscaling_groupresource must be configured to ignore changes to theload_balancersandtarget_group_arnsarguments within alifecycleconfiguration block.
Tips: Best Practices for The Other AWS Amazon EC2 Auto Scaling Resources
In addition to the aws_launch_configuration, AWS Amazon EC2 Auto Scaling has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_launch_configuration
Check public IPs should be given to Auto Scaling instances
It is better to block public access on the Internet to them. It is better to avoid associating public IP addresses if this is unintentional.
AWS::AutoScaling::LaunchConfiguration (CloudFormation)
The LaunchConfiguration in AutoScaling can be configured in CloudFormation with the resource name AWS::AutoScaling::LaunchConfiguration. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
AssociatePublicIpAddressoptional - Boolean -
BlockDeviceMappingsoptional - List of BlockDeviceMapping -
ClassicLinkVPCIdoptional - String -
ClassicLinkVPCSecurityGroupsoptional - List -
EbsOptimizedoptional - Boolean -
IamInstanceProfileoptional - String -
ImageIdrequired - String -
InstanceIdoptional - String -
InstanceMonitoringoptional - Boolean -
InstanceTyperequired - String -
KernelIdoptional - String -
KeyNameoptional - String -
LaunchConfigurationNameoptional - String -
MetadataOptionsoptional - MetadataOptions -
PlacementTenancyoptional - String -
RamDiskIdoptional - String -
SecurityGroupsoptional - List -
SpotPriceoptional - String -
UserDataoptional - String
Explanation in CloudFormation Registry
The
AWS::AutoScaling::LaunchConfigurationresource specifies the launch configuration that can be used by an Auto Scaling group to configure Amazon EC2 instances. When you update the launch configuration for an Auto Scaling group, CloudFormation deletes that resource and creates a new launch configuration with the updated properties and a new name. Existing instances are not affected. To update existing instances when you update theAWS::AutoScaling::LaunchConfigurationresource, you can specify an UpdatePolicy attribute for the group. You can find sample update policies for rolling updates in Auto scaling template snippets. For more information, see CreateLaunchConfiguration in the Amazon EC2 Auto Scaling API Reference and Launch configurations in the Amazon EC2 Auto Scaling User Guide.Note To configure Amazon EC2 instances launched as part of the Auto Scaling group, you can specify a launch template or a launch configuration. We recommend that you use a launch template to make sure that you can use the latest features of Amazon EC2, such as Dedicated Hosts and T2 Unlimited instances. For more information, see Creating a launch template for an Auto Scaling group.