Jordan Fisher
08/28/2025, 1:54 PMOidcAwsCredentials
in the base_job_template
generated for an AWS ECS push pool. Is there any further reference or documentation on this?Marvin
08/28/2025, 1:54 PMMarvin
08/28/2025, 2:01 PMOidcAwsCredentials
in the ECS push work pool base job template is a Prefect Cloud–managed credential type used for Workload Identity (OIDC) to assume an AWS IAM role at run time.
- It’s not a user-facing block or class in prefect-aws
, which is why you won’t find it in the SDK docs or code. Prefect Cloud injects these short‑lived AWS credentials into the job when your work pool is configured to use an AWS Workload Identity.
What this means in practice:
- You configure an AWS IAM role with a trust policy that allows Prefect Cloud’s OIDC provider to assume the role (via STS).
- In Prefect Cloud, you add an AWS Workload Identity and attach it to your ECS push work pool.
- At run time, Prefect Cloud exchanges its OIDC token for temporary AWS credentials and populates the job template’s credentials
with OidcAwsCredentials
.
Docs and references:
- General Prefect AWS integration overview: Prefect AWS integration
- ECS concepts and worker/pool context: ECS guide (for background on how ECS is used with Prefect)
Today, there isn’t a public SDK reference page specifically for OidcAwsCredentials
because it’s a Cloud-internal type, not something you import or configure directly in code.
If it’s helpful, I can share:
- A high-level checklist for setting up the IAM role trust policy and permissions (ECS/ECR, etc.)
- A sample trust policy you can adapt (you’ll need the issuer/audience and subject conditions provided in your Prefect Cloud “Workload Identity” UI)
Are you setting this up on Prefect Cloud now? If so, let me know and I’ll tailor the exact steps and example policy to your workspace.Gonzalo Arce
08/28/2025, 2:16 PMGonzalo Arce
08/28/2025, 2:17 PMMarvin
08/28/2025, 2:17 PMMarvin
08/28/2025, 2:18 PMsts:AssumeRoleWithWebIdentity
, the OIDC provider as Principal (Federated), and Conditions that match the audience and subject values from Prefect Cloud.
- Example trust policy structure (PLACEHOLDERS: replace with the values shown in Prefect Cloud; keys and patterns will differ by provider and workspace):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::<ACCOUNT_ID>:oidc-provider/<OIDC_ISSUER_HOST>"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"<OIDC_ISSUER_HOST>:aud": "<http://sts.amazonaws.com|sts.amazonaws.com>"
},
"StringLike": {
"<OIDC_ISSUER_HOST>:sub": "<VALUE_PROVIDED_BY_PREFECT_CLOUD>"
}
}
}
]
}
- STS API reference: AssumeRoleWithWebIdentity
3) Attach a permissions policy to that role (control-plane permissions)
- This is what Prefect Cloud will use to start your ECS tasks.
- A minimal example (tighten as needed to your environment):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecs:RunTask",
"ecs:DescribeTasks",
"ecs:DescribeTaskDefinition"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": [
"arn:aws:iam::<ACCOUNT_ID>:role/<YOUR_TASK_EXECUTION_ROLE>",
"arn:aws:iam::<ACCOUNT_ID>:role/<YOUR_TASK_ROLE>"
],
"Condition": {
"StringEquals": {
"iam:PassedToService": "<http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com>"
}
}
}
]
}
- Note: ECR pulls are handled by your ECS task execution role, not the Prefect control-plane role above. Ensure your task execution role has AmazonECSTaskExecutionRolePolicy
(or equivalent custom permissions for ECR, logs, etc.).
4) Back in Prefect Cloud
- Add a new AWS Workload Identity (you’ll supply the IAM role ARN you just created).
- Attach it to your ECS push work pool.
A couple of helpful references:
- Prefect AWS integration overview: Prefect AWS integration
- AWS OIDC provider setup: AWS: Create OIDC provider
Because the exact issuer/audience/subject values are provided in the Prefect UI, I don’t want to guess them here. Once we enable Workload Identity for your workspace, you’ll see those values and can copy/paste them directly into the AWS trust policy.Marvin
08/28/2025, 2:18 PMGonzalo Arce
08/28/2025, 2:20 PMMarvin
08/28/2025, 2:20 PMMarvin
08/28/2025, 2:21 PMsts:AssumeRoleWithWebIdentity
- Put the OIDC provider ARN in the Principal.Federated
- Match the audience and subject shown in Prefect Cloud
Example trust policy structure (replace placeholders with the values from the Prefect UI and your AWS account):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::<ACCOUNT_ID>:oidc-provider/<OIDC_ISSUER_HOST>"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"<OIDC_ISSUER_HOST>:aud": "<http://sts.amazonaws.com|sts.amazonaws.com>"
},
"StringLike": {
"<OIDC_ISSUER_HOST>:sub": "<SUBJECT_VALUE_FROM_PREFECT_UI>"
}
}
}
]
}
- STS details: AssumeRoleWithWebIdentity
3) Attach a permissions policy to that role (control plane)
- This role is used by Prefect Cloud to start and monitor your ECS tasks. Tighten as needed to your resources.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecs:RunTask",
"ecs:DescribeTasks",
"ecs:DescribeTaskDefinition",
"ecs:DescribeClusters",
"ecs:ListTasks",
"ecs:StopTask"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": [
"arn:aws:iam::<ACCOUNT_ID>:role/<YOUR_TASK_EXECUTION_ROLE>",
"arn:aws:iam::<ACCOUNT_ID>:role/<YOUR_TASK_ROLE>"
],
"Condition": {
"StringEquals": {
"iam:PassedToService": "<http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com>"
}
}
}
]
}
Notes:
- ECR image pulls, CloudWatch logs, etc., are handled by your ECS task execution role (e.g., with AmazonECSTaskExecutionRolePolicy
). Prefect’s OIDC role does not need direct ECR permissions if your execution role is set up correctly.
- The base job template will show type: OidcAwsCredentials
automatically when a Workload Identity is attached — no code changes needed on your end.
4) Connect the role in Prefect Cloud
- After the feature is enabled, go to Work Pools > your ECS Push pool > Credentials > Add Workload Identity (AWS) and enter the IAM Role ARN you created.
Helpful references:
- Prefect AWS integration overview: Prefect AWS integration
- AWS OIDC provider setup: AWS: Create OIDC provider
If you share your AWS account ID(s), ECS cluster name, and the ARNs of your task role/execution role, I can tailor a least‑privilege policy for you. I’ll also update you here as soon as Workload Identity is enabled for those workspaces.Gonzalo Arce
08/28/2025, 2:23 PMMarvin
08/28/2025, 2:24 PMMarvin
08/28/2025, 2:24 PMSubject: Enable AWS Workload Identity (OIDC)
Org name/slug:
Workspace #1 name + ID:
Workspace #2 name + ID:
Cloud region (US/EU):
I am an org admin: yes/no
Preferred contact email:
AWS account ID(s) where ECS will run:
Any compliance constraints (optional):
Please enable Workload Identity (AWS OIDC) for the workspaces above.
Once it’s enabled, the UI will display the exact OIDC issuer/audience/subject you’ll need for the AWS IAM role trust policy. If you want, I can also help draft a least‑privilege IAM policy once you share your ECS cluster and task/execution role ARNs.
Reference:
- Pricing overview: Prefect pricingGonzalo Arce
08/28/2025, 2:31 PMMarvin
08/28/2025, 2:31 PMMarvin
08/28/2025, 2:31 PMPlease enable AWS Workload Identity (OIDC).
Org name/slug:
Workspace #1 name + ID: 430a47aa-cff0-4228-8612-37adb6c66cdf
Workspace #2 name + ID: 61d226e7-d7cf-4b2e-8f5e-5350236792be
Cloud region (US/EU):
I am an org admin: yes/no
Preferred contact email:
I consent to Prefect sharing these details with Support to process this request: yes
Gonzalo Arce
08/28/2025, 2:41 PMMarvin
08/28/2025, 2:41 PMMarvin
08/28/2025, 2:42 PMSubject: Request to enable AWS Workload Identity (OIDC) for ECS Push Work Pools
Hello Prefect Support,
Please enable AWS Workload Identity (OIDC) for the following Prefect Cloud workspaces:
Organization name/slug:
Cloud region (US or EU):
Workspaces:
- <Workspace #1 name> (ID: 430a47aa-cff0-4228-8612-37adb6c66cdf)
- <Workspace #2 name> (ID: 61d226e7-d7cf-4b2e-8f5e-5350236792be)
I am an org admin: yes/no
Preferred contact email:
Preferred Slack handle (optional):
AWS environment details:
- AWS account ID(s) where ECS will run:
- Intended services: ECS (Fargate or EC2?), ECR, CloudWatch Logs
- Any compliance constraints (e.g., region restrictions, SCPs, private subnets only):
Request:
- Enable AWS Workload Identity (OIDC) for the above workspaces.
- Please provide the OIDC issuer, audience, and subject values needed for our AWS IAM role trust policy.
- We intend to attach the OIDC role to our ECS push work pools.
(Optional) Least-privilege review:
We can share ARNs for our ECS cluster, task role, and execution role if you can advise on a least-privilege control-plane policy.
Desired timeline/priority:
Thank you!
<Your Name>
<Title/Team>
<Company>
If you have an account team/CSM, feel free to CC them for faster handling.Gonzalo Arce
08/28/2025, 3:02 PMMarvin
08/28/2025, 3:02 PMMarvin
08/28/2025, 3:03 PM{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ECSControlPlane",
"Effect": "Allow",
"Action": [
"ecs:RunTask",
"ecs:DescribeTasks",
"ecs:DescribeTaskDefinition",
"ecs:DescribeClusters",
"ecs:ListTasks",
"ecs:StopTask"
],
"Resource": "*"
},
{
"Sid": "PassTaskRolesToECS",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": [
"arn:aws:iam::<ACCOUNT_ID>:role/<YOUR_TASK_EXECUTION_ROLE>",
"arn:aws:iam::<ACCOUNT_ID>:role/<YOUR_TASK_ROLE>"
],
"Condition": {
"StringEquals": {
"iam:PassedToService": "<http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com>"
}
}
}
]
}
If you let Prefect register task definitions (optional):
- Add:
{
"Sid": "TaskDefinitionLifecycle",
"Effect": "Allow",
"Action": [
"ecs:RegisterTaskDefinition",
"ecs:DeregisterTaskDefinition"
],
"Resource": "*"
}
- You’ll still need the iam:PassRole statement for the roles referenced in the task definition.
Tightening scope (optional best practice)
- You can restrict ecs:RunTask, ecs:StopTask, etc., to specific clusters and task definitions using ARNs and/or ECS condition keys. Start broad while testing; then narrow to:
- Cluster: arnawsecs<region><account>:cluster/<your-cluster>
- Task definition: arnawsecs<region><account>task definition/<family>*
- Keep iam:PassRole limited to only the exact task role and execution role ARNs your tasks use.
B. Task execution role (inside your ECS task)
Attach AWS-managed policy AmazonECSTaskExecutionRolePolicy (or equivalent custom)
- Grants ECR image pulls and CloudWatch Logs:
- ecr:GetAuthorizationToken, ecr:BatchGetImage, ecr:GetDownloadUrlForLayer
- logs:CreateLogStream, logs:PutLogEvents
Reference: Task execution IAM role and AmazonECSTaskExecutionRolePolicy
C. Task role (inside your ECS task)
- App-specific permissions (e.g., S3, RDS, etc.) required by your flow code.
Notes
- For OIDC: the control-plane policy above is what the OIDC role needs. The trust policy will come from the Prefect UI once Workload Identity is enabled (issuer/audience/subject).
- For IAM user credentials (alternative to OIDC): use the same control-plane policy as above, but store the keys securely (rotate regularly).
Helpful references
- Prefect AWS integration overview: Prefect AWS integration
- ECS task execution role details: AWS: Task execution IAM role
- AssumeRoleWithWebIdentity: AWS STS API referenceMarvin
08/28/2025, 3:03 PM