You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 11, 2023. It is now read-only.
Jun 26 12:39:35 ip-10-23-11-146.ap-south-1.compute.internal systemd[1]: Started Autoscale Lifecycle Daemon.
56
+
Jun 26 12:39:35 ip-10-23-11-146.ap-south-1.compute.internal systemd[1]: Starting Autoscale Lifecycle Daemon...
57
+
Jun 26 12:39:35 ip-10-23-11-146.ap-south-1.compute.internal lifecycled[3412]: {"level":"info","msg":"Looking up instance id from metadata service","time":"2020-06-26T12:39:35Z"}
58
+
Jun 26 12:39:35 ip-10-23-11-146.ap-south-1.compute.internal lifecycled[3412]: {"instanceId":"i-xxx","level":"info","listener":"autoscaling","msg":"Starting listener","time":"2020-06-26T12:39:35Z"}
59
+
Jun 26 12:39:35 ip-10-23-11-146.ap-south-1.compute.internal lifecycled[3412]: {"instanceId":"i-xxx","level":"info","msg":"Waiting for termination notices","time":"2020-06-26T12:39:35Z"}
38
60
```
39
-
systemctl status lifecycled.service
40
-
```
41
-
42
-
Output from a handler could be seen in the service log e.g. by using
43
-
44
-
```
45
-
journalctl -f -u lifecycled.service
46
-
```
47
-
48
-
49
-
## Test the Notification
50
61
51
-
To generate a notification for a termination event, update the Auto Scaling group by decreasing the desired capacity of the Auto Scaling group by 1. You receive a notification within a few minutes after instance termination.
62
+
## Note about lifecycle-handler.sh
52
63
53
-
To change the desired capacity using the console
64
+
For testing that the handler is working properly, you have to observe
65
+
that you are able to observe the side effect from the script.
54
66
55
-
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
67
+
One easy way to validate is by spawning a new EC2 instance with a
68
+
sample website deployed in it (You could use busybox for it) and then
69
+
doing a SSH and watching to see if you are able to observe any logs on
70
+
it whenever it's being hit with an HTTP request. Example:
56
71
57
-
On the navigation pane, under Auto Scaling, choose Auto Scaling Groups.
You can modify your [script](./cloud-config.yml) to have curl hit it:
60
78
61
-
On the Details tab, choose Edit.
79
+
```shellsession
80
+
$ curl http://x.x.x.x
81
+
```
62
82
63
-
For Desired, decrease the current value by 1.
83
+
## Test the Notification
64
84
65
-
Choose Save.
85
+
To generate a notification for a launch event, update the Auto Scaling
86
+
group by decreasing the desired capacity of the Auto Scaling group
87
+
by 1. That will make the lifecycle handler to get triggered. These are
88
+
the steps to decreased the desired capacity using AWS console:
66
89
67
-
After a few minutes, you'll see that the lifecycle-handler.sh script will be executed and it's side effect operation will be performed: in the log of lifecycled.service you'll see a line with something like "hello from the handler, received autoscaling:EC2_INSTANCE_TERMINATING i-01234567890123456"
90
+
* Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
91
+
* On the navigation pane, under Auto Scaling, choose Auto Scaling Groups.
92
+
* Select your Auto Scaling group.
93
+
* On the Details tab, choose Edit.
94
+
* For Desired, decrease the current value by 1.
95
+
* Choose Save.
96
+
* After a few minutes, you'll see that the lifecycle-handler.sh script
97
+
will be executed and it's side effect operation will be performed.
68
98
69
99
## Destruction
70
100
@@ -74,7 +104,3 @@ To destroy the test environment run the following commands:
74
104
make destroy
75
105
make clean
76
106
```
77
-
78
-
## Notes
79
-
- This example was last tested with `Terraform v0.12.4`
80
-
- This example assumes AWS credentials setup with access to the **us-east-2** region.
0 commit comments