IAM roles and permissions ========================= Two identities need permissions: the **runner** (its Lambda execution role) and the **client** (whatever identity your application runs as). Runner execution role --------------------- .. list-table:: :header-rows: 1 :widths: 22 38 40 * - Service - Actions - Why * - SQS (the queue) - ``sqs:ReceiveMessage``, ``sqs:DeleteMessage``, ``sqs:GetQueueAttributes`` - Read the messages. The managed policy ``AWSLambdaSQSQueueExecutionRole`` includes them, and CloudWatch Logs. * - SQS (the queue) - ``sqs:SendMessage`` - Hold a task until its ``eta``, retries, and the next tasks of a workflow (callbacks, chains, chords). Needed on the queue of the event source mapping and on any queue named in ``options.queue`` * - DynamoDB (the table) - ``dynamodb:PutItem``, ``dynamodb:GetItem``, ``dynamodb:UpdateItem``, ``dynamodb:DeleteItem`` - Register the task and store its state and result. ``DeleteItem``: forget a task rejected with ``requeue`` and clean up finished chords * - Lambda (each remote function) - ``lambda:InvokeFunction`` - Only for ``lambda://`` tasks Create the role ~~~~~~~~~~~~~~~ .. code-block:: bash cat > trust-policy.json <<'JSON' { "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": {"Service": "lambda.amazonaws.com"}, "Action": "sts:AssumeRole" }] } JSON aws iam create-role --role-name $FUNCTION \ --assume-role-policy-document file://trust-policy.json aws iam attach-role-policy --role-name $FUNCTION \ --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole Add the table (and, if you use remote tasks, the functions) as an inline policy: .. code-block:: bash cat > runner-policy.json <