【发布时间】:2020-02-09 00:29:24
【问题描述】:
我有一个从 lambda 函数调用的 Fargate 任务。我还有一个负载均衡器,它设置为特定的目标组,比如说 tg-x。我使用 boto3 来运行上述任务。但是,我不使用服务,因为我只需要手动运行此任务。无论如何我可以将目标组添加到此任务中,例如在服务中?
我的代码:
def lambda_handler(event,context):
client = boto3.client('ecs')
response = client.run_task(
cluster='oops-dev', # name of the cluster
launchType = 'FARGATE',
taskDefinition='oops-dev-oops-oops:oops'
count = 1,
platformVersion='LATEST',
networkConfiguration={
'awsvpcConfiguration': {
'subnets': [
'subnet-oops',
'subnet-oops',
'subnet-oops'
],
'securityGroups': [
'sg-oops'
],
'assignPublicIp': 'ENABLED'
}
})
return str(response)
我检查了boto3 docs,以及AWS documentation,但无济于事。我还注意到,即使在 Web 界面中,也无法做到这一点。
提前致谢。
【问题讨论】:
标签: amazon-web-services aws-lambda boto3 aws-fargate