AWS Amazon EC2 Auto Scaling Notification
This page shows how to write Terraform and CloudFormation for Amazon EC2 Auto Scaling Notification and write them securely.
aws_autoscaling_notification (Terraform)
The Notification in Amazon EC2 Auto Scaling can be configured in Terraform with the resource name aws_autoscaling_notification. The following sections describe 2 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_autoscaling_notification" "notification" {
count = var.notifications ? 1 : 0
group_names = [
aws_autoscaling_group.bastion.name,
]
resource "aws_autoscaling_notification" "this" {
group_names = [var.asg_name]
notifications = [
"autoscaling:EC2_INSTANCE_LAUNCH",
"autoscaling:EC2_INSTANCE_TERMINATE",
"autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
Parameters
-
group_namesrequired - set of string -
idoptional computed - string -
notificationsrequired - set of string -
topic_arnrequired - string
Explanation in Terraform Registry
Provides an AutoScaling Group with Notification support, via SNS Topics. Each of the
notificationsmap to a [Notification Configuration][2] inside Amazon Web Services, and are applied to each AutoScaling Group you supply.
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::AutoScalingGroup NotificationConfiguration (CloudFormation)
The AutoScalingGroup NotificationConfiguration in AutoScaling can be configured in CloudFormation with the resource name AWS::AutoScaling::AutoScalingGroup NotificationConfiguration. 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
NotificationTypes
A list of event types that trigger a notification. Event types can include any of the following types.
Allowed Values:
autoscaling:EC2_INSTANCE_LAUNCHautoscaling:EC2_INSTANCE_LAUNCH_ERRORautoscaling:EC2_INSTANCE_TERMINATEautoscaling:EC2_INSTANCE_TERMINATE_ERRORautoscaling:TEST_NOTIFICATIONRequired: No
Type: List of String
Update requires: No interruption
TopicARN
The Amazon Resource Name (ARN) of the Amazon Simple Notification Service (Amazon SNS) topic.
Required: Yes
Type: String
Update requires: No interruption
Explanation in CloudFormation Registry
NotificationConfigurationspecifies a notification configuration for theNotificationConfigurationsproperty of AWS::AutoScaling::AutoScalingGroup.NotificationConfigurationspecifies the events that the Amazon EC2 Auto Scaling group sends notifications for.For example snippets, see Declaring an Auto Scaling group with a launch template and notifications.
For more information, see Getting Amazon SNS notifications when your Auto Scaling group scales in the Amazon EC2 Auto Scaling User Guide.
Frequently asked questions
What is AWS Amazon EC2 Auto Scaling Notification?
AWS Amazon EC2 Auto Scaling Notification is a resource for Amazon EC2 Auto Scaling of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon EC2 Auto Scaling Notification?
For Terraform, the Cloud-42/terraform-aws-bastion and msaqibhashmi/weblate-iac source code examples are useful. See the Terraform Example section for further details.