admin管理员组文章数量:1335361
How do I pass $$.Task.Token
to an EC2 run-instances
call from AWS Step Functions?
Should I pass it using "user-data" key in the json request?
It becomes more difficult since user-data key accepts ONLY base64 encoded string. The string $$.Task.Token
is passed as it is and not its value.
Or is there any other way to pass the task token to an aws EC2 instance?
How do I pass $$.Task.Token
to an EC2 run-instances
call from AWS Step Functions?
Should I pass it using "user-data" key in the json request?
It becomes more difficult since user-data key accepts ONLY base64 encoded string. The string $$.Task.Token
is passed as it is and not its value.
Or is there any other way to pass the task token to an aws EC2 instance?
Share Improve this question edited Dec 9, 2024 at 19:09 Rodrigue 3,6872 gold badges41 silver badges50 bronze badges asked Nov 20, 2024 at 4:39 ShanthiShanthi 6772 gold badges8 silver badges20 bronze badges1 Answer
Reset to default 1There are always plenty of intrinsic functions for tasks like that. States.Base64Encode
is your case.
Here is the full code of the step function passing down TaskToken and waitingForCallback. The task token is passed along with the base64 string and will be initialized as an env variable TASK_TOKEN.
Don't fet to clean up the instance though.
{
"Comment": "State Machine that launches EC2 with TASK_TOKEN as an environment variable",
"StartAt": "PrepareAndLaunchEC2",
"States": {
"PrepareAndLaunchEC2": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:ec2:runInstances.waitForTaskToken",
"Parameters": {
"ImageId": "ami-0cdd6d7420844683b",
"InstanceType": "t2.micro",
"MinCount": 1,
"MaxCount": 1,
"UserData.$": "States.Base64Encode(States.Format('#!/bin/bash\n export TASK_TOKEN=\"{}\"\n# More commands here', $$.Task.Token))"
},
"End": true
}
}
}
本文标签: How do I pass the Task Token to an EC2 runinstances call from AWS Step FunctionsStack Overflow
版权声明:本文标题:How do I pass the Task Token to an EC2 run-instances call from AWS Step Functions - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742381276a2464142.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论