A simple code in Python 3.6 for running on AWS Lambda that trigger ECS (Fargate).
-
Access Lambda Management Console;
-
Click on Create function;
-
Select Author from scratch;
-
Put Name for the function;
-
Select Python 3.6 on Runtime Select-box;
-
On Role, select/create a role with the inline policy recommended below;
-
Then, click on Create function;
-
Now, we are on Lambda Function;
-
Copy the code on handle.py, on this repo, and Paste on lambda_function.py, inside the Function code.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1512361420000",
"Effect": "Allow",
"Action": [
"ecs:RunTask"
],
"Resource": [
"*"
]
},
{
"Sid": "Stmt1512361593000",
"Effect": "Allow",
"Action": [
"iam:PassRole"
],
"Resource": [
"arn:aws:iam::************:role/ecsTaskExecutionRole" // replace (******) with your Account ID
]
}
]
}