2017-04-19 1 views
0

AWS Lambda에서 내 ECS 작업을 Python으로 예약해야합니다. 이를 위해 람다 핸들러 코드가 필요하다. 어떻게 파이썬에서 aws 작업을 실행합니까?AWS에서 ECS 작업 예약 Python의 Lambda

+0

U는 boto3 python 패키지 http://boto3.readthedocs.io/en/latest/reference/services/ecs.html을 사용할 수 있습니다. – Gigapalmer

답변

0
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