View a markdown version of this page

Use DescribeLifecycleHooks with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DescribeLifecycleHooks with a CLI

The following code examples show how to use DescribeLifecycleHooks.

CLI
AWS CLI

To describe your lifecycle hooks

The following describe-lifecycle-hooks example describes the lifecycle hooks for the specified Auto Scaling group.

aws autoscaling describe-lifecycle-hooks \ --auto-scaling-group-name my-asg

Output:

{ "LifecycleHooks": [ { "GlobalTimeout": 3000, "HeartbeatTimeout": 30, "AutoScalingGroupName": "my-asg", "LifecycleHookName": "my-launch-hook", "DefaultResult": "ABANDON", "LifecycleTransition": "autoscaling:EC2_INSTANCE_LAUNCHING" }, { "GlobalTimeout": 6000, "HeartbeatTimeout": 60, "AutoScalingGroupName": "my-asg", "LifecycleHookName": "my-termination-hook", "DefaultResult": "CONTINUE", "LifecycleTransition": "autoscaling:EC2_INSTANCE_TERMINATING" } ] }

For more information, see Amazon EC2 Auto Scaling lifecycle hooks in the Amazon EC2 Auto Scaling User Guide.

PowerShell
Tools for PowerShell V4

Example 1: This example describes the specified lifecycle hook.

Get-ASLifecycleHook -AutoScalingGroupName my-asg -LifecycleHookName myLifecycleHook

Output:

AutoScalingGroupName : my-asg DefaultResult : ABANDON GlobalTimeout : 172800 HeartbeatTimeout : 3600 LifecycleHookName : myLifecycleHook LifecycleTransition : auto-scaling:EC2_INSTANCE_LAUNCHING NotificationMetadata : NotificationTargetARN : arn:aws:sns:us-west-2:123456789012:my-topic RoleARN : arn:aws:iam::123456789012:role/my-iam-role

Example 2: This example describes all lifecycle hooks for the specified Auto Scaling group.

Get-ASLifecycleHook -AutoScalingGroupName my-asg

Example 3: This example describes all lifecycle hooks for all your Auto Scaling groups.

Get-ASLifecycleHook
Tools for PowerShell V5

Example 1: This example describes the specified lifecycle hook.

Get-ASLifecycleHook -AutoScalingGroupName my-asg -LifecycleHookName myLifecycleHook

Output:

AutoScalingGroupName : my-asg DefaultResult : ABANDON GlobalTimeout : 172800 HeartbeatTimeout : 3600 LifecycleHookName : myLifecycleHook LifecycleTransition : auto-scaling:EC2_INSTANCE_LAUNCHING NotificationMetadata : NotificationTargetARN : arn:aws:sns:us-west-2:123456789012:my-topic RoleARN : arn:aws:iam::123456789012:role/my-iam-role

Example 2: This example describes all lifecycle hooks for the specified Auto Scaling group.

Get-ASLifecycleHook -AutoScalingGroupName my-asg

Example 3: This example describes all lifecycle hooks for all your Auto Scaling groups.

Get-ASLifecycleHook