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

notification.tf#L4
resource "aws_autoscaling_notification" "notification" {
  count = var.notifications ? 1 : 0

  group_names = [
    aws_autoscaling_group.bastion.name,
  ]
main.tf#L1
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

Explanation in Terraform Registry

Provides an AutoScaling Group with Notification support, via SNS Topics. Each of the notifications map to a [Notification Configuration][2] inside Amazon Web Services, and are applied to each AutoScaling Group you supply.

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_LAUNCH
  • autoscaling:EC2_INSTANCE_LAUNCH_ERROR
  • autoscaling:EC2_INSTANCE_TERMINATE
  • autoscaling:EC2_INSTANCE_TERMINATE_ERROR
  • autoscaling: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

NotificationConfiguration specifies a notification configuration for the NotificationConfigurations property of AWS::AutoScaling::AutoScalingGroup. NotificationConfiguration specifies 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.