drslei31
Intern
Intern
  • UID8172
  • Fans0
  • Follows0
  • Posts1
Reads:486Replies:3

AutoScaling (ESS) CompleteLifecycleAction token

Created#
More Posted time:Jan 3, 2020 17:45 PM
I've been trying to get CompleteLifecycleAction to work in aliyun cli with no luck.





aliyun ess CompleteLifecycleAction --LifecycleHookId [LifecycleHookId] --LifecycleActionToken ???


according to documentation LifecycleActionToken is obtained from MNS Topic but when i log from the endpoint the message looks like this:


{"TopicOwner":"58877688xxxxxxxxx","Message":"eyJjb250ZW50Ijp7ImRlZmF1bHRSZXN1bHQiOiJBQkFORE9OIiwiaW5zdGFuY2VJZHMiOlsiaS1rMWFieW0weHI3M2RwNnk4NzRkOCJdLCJsaWZlY3ljbGVBY3Rpb25Ub2tlbiI6IjkxOTYxMDgwLUUwRTItNDUyQi04MjMwLTZDMjFFQTZFQkIzRSIsImxpZmVjeWNsZUhvb2tJZxxxxxxxxxxxxxxxxxxxxx0dyb3VwL2FzZy1rMWE1MXl3ZXRldWFsNms1b3p6OCIsInRpbWUiOiIyMDIwLTAxLTAzVDA4OjUwOjQ1Ljc2OFoiLCJ1c2VySWQiOiI1ODg3NzY4ODg5NTEwNTM0In0=","Subscriber":"5887768889510534","PublishTime":"1578041445777","SubscriptionName":"asdasda2","MessageMD5":"394EFC10B2D9F642081B963E6A917466","TopicName":"xxxxxxxx-xxxxxxxx","MessageId":"0BD60669554642A57xxxxxx"}



as you can see the message seems to be encrypted and i cant find a way to decrypt it. Anyone?

kcloud
Engineer
Engineer
  • UID7778
  • Fans0
  • Follows0
  • Posts52
1st Reply#
Posted time:Jan 4, 2020 0:17 AM
Hi,

I didn't find any documentation regarding this, but the message is encoded in base64.

Try the following python code:

import base64
data = "eyJjb250ZW50Ijp7ImRlZmF1bHRSZXN1bHQiOiJBQkFORE9OIiwiaW5zdGFuY2VJZHMiOlsiaS1rMWFieW0weHI3M2RwNnk4NzRkOCJdLCJsaWZlY3ljbGVBY3Rpb25Ub2tlbiI6IjkxOTYxMDgwLUUwRTItNDUyQi04MjMwLTZDMjFFQTZFQkIzRSIsImxpZmVjeWNsZUhvb2tJZxxxxxxxxxxxxxxxxxxxxx0dyb3VwL2FzZy1rMWE1MXl3ZXRldWFsNms1b3p6OCIsInRpbWUiOiIyMDIwLTAxLTAzVDA4OjUwOjQ1Ljc2OFoiLCJ1c2VySWQiOiI1ODg3NzY4ODg5NTEwNTM0In0="
base64.b64decode(data).decode('utf-8','ignore')


And you will get the following result:

'{"content":{"defaultResult":"ABANDON","instanceIds":["i-k1abym0xr73dp6y874d8"],"lifecycleActionToken":"91961080-E0E2-452B-8230-6C21EA6EBB3E","lifecycleHookIg\x1cq\x1cq\x1cq\x1cq\x1cq\x1d\x1dɽ͜ńݕѕՅ٬սѥĴPԸh͕%Љ'


Cheers,
K

kcloud
Engineer
Engineer
  • UID7778
  • Fans0
  • Follows0
  • Posts52
2nd Reply#
Posted time:Jan 4, 2020 0:21 AM
Hi,

Following is the JavaScript code:

var data = 'eyJjb250ZW50Ijp7ImRlZmF1bHRSZXN1bHQiOiJBQkFORE9OIiwiaW5zdGFuY2VJZHMiOlsiaS1rMWFieW0weHI3M2RwNnk4NzRkOCJdLCJsaWZlY3ljbGVBY3Rpb25Ub2tlbiI6IjkxOTYxMDgwLUUwRTItNDUyQi04MjMwLTZDMjFFQTZFQkIzRSIsImxpZmVjeWNsZUhvb2tJZxxxxxxxxxxxxxxxxxxxxx0dyb3VwL2FzZy1rMWE1MXl3ZXRldWFsNms1b3p6OCIsInRpbWUiOiIyMDIwLTAxLTAzVDA4OjUwOjQ1Ljc2OFoiLCJ1c2VySWQiOiI1ODg3NzY4ODg5NTEwNTM0In0=';

var decoded = new Buffer.from(data, 'base64').toString('ascii');

console.log(decoded);

And the output on the console:

{"content":{"defaultResult":"ABANDON","instanceIds":["i-k1abym0xr73dp6y874d8"],"lifecycleActionToken":"91961080-E0E2-452B-8230-6C21EA6EBB3E","lifecycleHookIgqGqGqGqGqGI=U@=M5,ETEe]QU0Y,U=ih0  Q%H@H@4@D4@MP@`hT@hPT8\Xa0  UMIT``\\X```dTD@TLP t

kcloud
Engineer
Engineer
  • UID7778
  • Fans0
  • Follows0
  • Posts52
3rd Reply#
Posted time:Jan 6, 2020 16:54 PM
Hi,

The following link has the documentation related to this topic:
https://www.alibabacloud.com/help/doc-detail/102410.htm
and also has the sample code in Java
https://www.alibabacloud.com/help/doc-detail/102410.htm#section-pzf-ymj-kgb

In the code, you will see the function "readInput" has the following statement:
return new String(Base64.decodeBase64(act), CHAR_SET);

and it's for decoding the message.

Cheers,
K.
Guest