0
我需要在Python中安排AWS Lambda中的ECS任務。我需要這個lambda處理程序代碼。我如何在python中運行aws任務?使用Python從AWS Lambda安排ECS任務
我需要在Python中安排AWS Lambda中的ECS任務。我需要這個lambda處理程序代碼。我如何在python中運行aws任務?使用Python從AWS Lambda安排ECS任務
import boto3
ecs_client = boto3.client('ecs')
logger = logging.getLogger()
def lambda_handler(event, context):
response = ecs_client.run_task(
cluster='your-cluster',
taskDefinition='your-task-name',
count=1,
launchType='EC2', # or fargate
)
logger.info(response)
response = {
"isBase64Encoded": "false",
"statusCode": 200,
"headers": { "COntent-Type": "application/json"},
"body": "hello"
}
return response
U可以使用boto3 python包http://boto3.readthedocs.io/en/latest/reference/services/ecs.html – Gigapalmer