Skip to main content

Granting Access to Your Resources

Some activities run a resource you own in your cloud account, such as a Logic App workflow or an AWS Lambda function. Insight Factory has no access to these resources until you grant it. Grant access to each resource your tasks run, and nothing else.

Azure​

Insight Factory runs these activities with a managed identity in your factory's resource group. Assign the role below to that identity, scoped to the resource the task runs.

ActivityIdentityRoleScope
Run Logic App Workflow (LOGICAPP-WORKFLOW), Standard planOrchestrator function app, func-orchestrator-<factory>-<environment>Logic Apps Standard OperatorThe Logic App
Run Logic App Workflow (LOGICAPP-WORKFLOW), Consumption planOrchestrator function app, func-orchestrator-<factory>-<environment>Logic App ContributorThe workflow
Run Azure Container App Job (CONTAINER-APP)Orchestrator function app, func-orchestrator-<factory>-<environment>Container Apps Jobs OperatorThe Container App job
Execute Azure Batch Task (EXEC-AZURE-BATCH)Data Factory, adf-<factory>-<environment>Azure Batch Job SubmitterThe Batch account

Both identities are system-assigned. Find an identity's object ID on the resource's Identity page in the Azure portal.

To assign a role with the Azure CLI:

az role assignment create \
--assignee-object-id <identity object ID> \
--assignee-principal-type ServicePrincipal \
--role "Logic Apps Standard Operator" \
--scope /subscriptions/<subscription ID>/resourceGroups/<resource group>/providers/Microsoft.Web/sites/<logic app name>

A Standard Logic App's role covers every workflow in the app. A Consumption workflow is its own resource, scoped .../providers/Microsoft.Logic/workflows/<workflow name>.

Role assignments can take a few minutes to apply. A task that runs before then fails with an authorization error.

info

Container App Job tasks all run in one job, set for your factory by Insight Factory. Contact support to set the job your factory uses.

HTTP POST to a Durable Azure Function (POST-AZFUNC-DURABLE) needs no role. It calls the function with a function key that you store in Key Vault and reference from the task's connection.

AWS​

Insight Factory runs these activities with its orchestrator IAM role, <prefix>-orchestrator-role. Create a customer managed IAM policy that grants the actions below on your resources, then attach it to that role. Insight Factory updates don't remove policies you attach.

The role also has a permissions boundary, installed with Insight Factory. The boundary sets the most the role can do but grants nothing, so the role can run only the resources your policy names.

caution

If a task fails with an access denied error saying no permissions boundary allows the action, your policy is correct but the boundary doesn't yet allow that service. Contact support to update it.

Replace <region>, <account ID> and the resource names in each statement with your own.

Invoke AWS Lambda Function (INVOKE-AWS-LAMBDA)​

Grant the ARN that matches the task's LambdaFunctionName. A function name on its own runs the $LATEST version and needs the function's ARN:

{
"Effect": "Allow",
"Action": "lambda:InvokeFunction",
"Resource": "arn:aws:lambda:<region>:<account ID>:function:<function name>"
}

A name with a version or alias, such as <function name>:prod, needs that version's or alias's ARN instead: arn:aws:lambda:<region>:<account ID>:function:<function name>:prod.

Run AWS Step Functions State Machine (STEP-FUNCTIONS-EXECUTION)​

[
{
"Effect": "Allow",
"Action": ["states:StartExecution", "states:DescribeStateMachine"],
"Resource": "arn:aws:states:<region>:<account ID>:stateMachine:<state machine name>"
},
{
"Effect": "Allow",
"Action": ["states:DescribeExecution", "states:StopExecution"],
"Resource": "arn:aws:states:<region>:<account ID>:execution:<state machine name>:*"
}
]

A StateMachineArn with a version or alias, such as <state machine name>:prod, needs that version's or alias's ARN in the first statement instead: arn:aws:states:<region>:<account ID>:stateMachine:<state machine name>:prod. Its executions use the same execution:<state machine name>:* ARNs, so the second statement stays as it is.

Run AWS Batch Job (EXEC-AWS-BATCH)​

[
{
"Effect": "Allow",
"Action": "batch:SubmitJob",
"Resource": [
"arn:aws:batch:<region>:<account ID>:job-queue/<job queue name>",
"arn:aws:batch:<region>:<account ID>:job-definition/<job definition name>",
"arn:aws:batch:<region>:<account ID>:job-definition/<job definition name>:*"
]
},
{
"Effect": "Allow",
"Action": ["batch:CancelJob", "batch:TerminateJob"],
"Resource": "arn:aws:batch:<region>:<account ID>:job/*"
},
{
"Effect": "Allow",
"Action": ["batch:DescribeJobs", "batch:ListJobs"],
"Resource": "*"
}
]

DescribeJobs and ListJobs don't support resource-level permissions, so they need "Resource": "*". Batch job ARNs don't include the queue, so cancelling can't be limited to one queue's jobs.

Run Amazon ECS Task (RUN-ECS-TASK)​

Insight Factory runs the task on Fargate and passes the task definition's roles to ECS, so the policy also needs iam:PassRole on those roles.

[
{
"Effect": "Allow",
"Action": "ecs:RunTask",
"Resource": "arn:aws:ecs:<region>:<account ID>:task-definition/<task definition family>:*",
"Condition": { "ArnEquals": { "ecs:cluster": "arn:aws:ecs:<region>:<account ID>:cluster/<cluster name>" } }
},
{
"Effect": "Allow",
"Action": ["ecs:DescribeTasks", "ecs:StopTask", "ecs:ListTasks"],
"Resource": "*",
"Condition": { "ArnEquals": { "ecs:cluster": "arn:aws:ecs:<region>:<account ID>:cluster/<cluster name>" } }
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": [
"arn:aws:iam::<account ID>:role/<task execution role name>",
"arn:aws:iam::<account ID>:role/<task role name>"
],
"Condition": { "StringEquals": { "iam:PassedToService": "ecs-tasks.amazonaws.com" } }
}
]

Leave out the task role if the task definition has none. Include a role's path in its ARN if it has one, for example role/my-path/<role name>.

info

A task runs on the cluster, subnets and security groups in its Cluster, Subnets and SecurityGroups properties, with the public IP setting in AssignPublicIp. Any it leaves empty use your environment's defaults, which Insight Factory sets. Contact support to change the defaults.

The ecs:cluster conditions must name the cluster each task runs on, which is the default cluster when a task leaves Cluster empty. To allow more than one cluster, list their ARNs in the condition.

Example: one policy for several resources​

Combine the statements for every resource your tasks run into one policy:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "lambda:InvokeFunction",
"Resource": "arn:aws:lambda:ap-southeast-2:111122223333:function:load-orders"
},
{
"Effect": "Allow",
"Action": ["states:StartExecution", "states:DescribeStateMachine"],
"Resource": "arn:aws:states:ap-southeast-2:111122223333:stateMachine:month-end-close"
},
{
"Effect": "Allow",
"Action": ["states:DescribeExecution", "states:StopExecution"],
"Resource": "arn:aws:states:ap-southeast-2:111122223333:execution:month-end-close:*"
}
]
}

To attach it with the AWS CLI:

aws iam create-policy --policy-name insightfactory-task-targets --policy-document file://policy.json
aws iam attach-role-policy --role-name <prefix>-orchestrator-role \
--policy-arn arn:aws:iam::<account ID>:policy/insightfactory-task-targets