{"id":"6b09a4b2ff996234422a2674","slug":"aws-iam-least-privilege","title":"IAM and least privilege on AWS – roles, policies, conditions, SCPs/RCPs, Access Analyzer and OIDC for GitHub Actions","summary":"We clean up permissions in the pierogi shop's AWS account – from \"everyone has AdministratorAccess\" to least privilege. Identities and roles instead of users, policy evaluation logic, ECS task and Lambda roles in CDK, condition keys, permissions boundaries and ABAC, organization guardrails (SCPs and RCPs), IAM Access Analyzer as a CI gate, and deployments from GitHub Actions through OIDC – with no long-lived keys.","servedLang":"en","availableLangs":["pl","en"],"topics":["aws-iam","secrets-management","aws-s3"],"techs":["typescript","node"],"tags":["aws","iam","least-privilege","scp","rcp","permissions-boundary","abac","access-analyzer","oidc","github-actions","ecs","lambda","aws-cdk"],"level":"intermediate","kind":"tutorial","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":17,"stats":{"views":1,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-27T15:41:38.622Z","updatedAt":"2026-11-27T17:32:27.582Z","requestedLang":"en","theme":{"hero":"classic","heroMedia":null,"accent":"amber","background":"grid","weaveResources":true,"toc":"right"},"seoDescription":"AWS IAM least privilege in practice – roles vs IAM users, identity and resource policies, SCPs, RCPs, permissions boundaries, policy evaluation order, condition keys (aws:PrincipalOrgID, aws:SourceArn, kms:ViaService), ECS task roles (task role vs execution role), Lambda, GitHub Actions OIDC, IAM Ac","wordCount":3213,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"In the pierogi shop's AWS account, three developers, the CI pipeline and two services had one thing in common: the "},{"type":"text","text":"AdministratorAccess","marks":[{"type":"code"}]},{"type":"text","text":" policy, granted \"just for now, to get things going\". \"Now\" lasted eighteen months. In this tutorial we replace that state with the principle of least privilege: every identity gets exactly what it needs, for as short a time as possible – so that a mistake or a leak has a limited blast radius."}]},{"type":"callout","attrs":{"variant":"info","title":"In a nutshell"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Roles instead of keys.","marks":[{"type":"bold"}]},{"type":"text","text":" People sign in through IAM Identity Center, services get roles (ECS, Lambda), and CI gets short sessions through OIDC. A long-lived "},{"type":"text","text":"AKIA…","marks":[{"type":"code"}]},{"type":"text","text":" key is the exception, not the norm."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"An explicit deny always wins.","marks":[{"type":"bold"}]},{"type":"text","text":" Permissions are the intersection of several layers: identity policies, resource policies, permissions boundaries, SCPs and RCPs. Guardrails ("},{"type":"text","text":"Deny","marks":[{"type":"code"}]},{"type":"text","text":") at the top protect against mistakes further down."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Least privilege is a process, not a state.","marks":[{"type":"bold"}]},{"type":"text","text":" Access Analyzer generates policies from activity, shows unused permissions and blocks changes in CI that grant new access."}]}]}]}]},{"type":"callout","attrs":{"variant":"tip","title":"What you will build"},"content":[{"type":"paragraph","content":[{"type":"text","text":"An API role policy (S3 on a prefix, KMS only through S3, SQS, Parameter Store) with a trust policy resistant to the "},{"type":"text","text":"confused deputy","marks":[{"type":"italic"}]},{"type":"text","text":" problem, CDK constructs with an ECS task role and execution role, a Lambda role and a permissions boundary, a GitHub Actions deployment role with OIDC and a workflow without AWS secrets, a policy for delegating role creation, an ABAC example, SCPs and RCPs for the organization, and an IAM Access Analyzer script for CI. Download the code (11 files) as a ZIP."}]}]},{"type":"paragraph","content":[{"type":"text","text":"Prerequisites:","marks":[{"type":"bold"}]},{"type":"text","text":" an AWS account (ideally in AWS Organizations), AWS CLI v2, Node.js 22+ and AWS CDK v2, JSON basics. The tutorials on the "},{"type":"text","text":"scalable portal","marks":[{"type":"link","attrs":{"href":"/en/articles/aws-scalable-web-architecture"}}]},{"type":"text","text":" and "},{"type":"text","text":"S3 bucket security","marks":[{"type":"link","attrs":{"href":"/en/articles/aws-s3-bucket-security"}}]},{"type":"text","text":" help."}]},{"type":"stats","attrs":{"items":[{"value":"Deny","label":"always wins","hint":"an explicit deny in any policy"},{"value":"0","label":"long-lived keys","hint":"in the target setup: SSO, roles, OIDC"},{"value":"1 h","label":"GitHub Actions deployment session","hint":"then the credentials expire"},{"value":"90 days","label":"default unused-access window","hint":"Access Analyzer, configurable"}]}},{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart LR\n  subgraph People\n    D([Developer]) -->|SSO + MFA| IC[IAM Identity Center]\n  end\n  IC -->|permission set| RD[Developer role<br/>in the dev account]\n  IC -->|permission set| RR[ReadOnly role<br/>in the prod account]\n  GH([GitHub Actions]) -->|OIDC token| RG[github-deploy role]\n  ECS([ECS task]) -->|task role| RT[pierogi-api-task role]\n  L([Lambda]) -->|execution role| RL[thumbnailer role]\n  RD & RR & RG & RT & RL --> STS[(STS: temporary<br/>credentials)]","caption":"Who gets credentials and how – the target setup"}},{"type":"heading","attrs":{"level":2,"id":"identities-who-is-who"},"content":[{"type":"text","text":"Identities: who is who"}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Identity"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"What for"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Credentials"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Rule"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Root account"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"closing the account, a few billing operations"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"password + MFA"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"no access keys; in an organization – centralized root access management (since 2024)"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Identity Center user"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"people"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"SSO, short sessions, MFA"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the default way people sign in"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"IAM user"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"exceptions: legacy tools without role support"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"long-lived key"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"avoid; if you must – one purpose, rotation, IP/VPC conditions"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"IAM role"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"services, CI, cross-account access, federation"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"temporary (STS)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the basic building block"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Service-linked role"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"AWS services working in your account"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"managed by AWS"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"you don't edit them, but it's worth knowing they exist"}]}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"A role has no password or key – it has a "},{"type":"text","text":"trust policy","marks":[{"type":"bold"}]},{"type":"text","text":" (who may assume it) and "},{"type":"text","text":"permission policies","marks":[{"type":"bold"}]},{"type":"text","text":" (what is allowed once assumed). Credentials from "},{"type":"text","text":"sts:AssumeRole","marks":[{"type":"code"}]},{"type":"text","text":" expire on their own, so a leak from logs or a memory dump has a limited lifetime."}]},{"type":"heading","attrs":{"level":2,"id":"how-aws-makes-a-decision"},"content":[{"type":"text","text":"How AWS makes a decision"}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart TD\n  A([Request]) --> B{Explicit Deny<br/>in any policy?}\n  B -->|yes| X[Deny]\n  B -->|no| C{SCPs and RCPs<br/>allow?}\n  C -->|no| X\n  C -->|yes| D{Resource policy<br/>grants Allow?}\n  D -->|yes*| OK[Allow]\n  D -->|no| E{Permissions boundary<br/>and session policy allow?}\n  E -->|no| X\n  E -->|yes| F{Identity policy<br/>grants Allow?}\n  F -->|yes| OK\n  F -->|no| X","caption":"Simplified evaluation logic for a request within one account"}},{"type":"paragraph","content":[{"type":"text","text":"By default everything is denied ("},{"type":"text","text":"implicit deny","marks":[{"type":"italic"}]},{"type":"text","text":"). Access requires an "},{"type":"text","text":"Allow","marks":[{"type":"code"}]},{"type":"text","text":", and a single explicit deny overrides every "},{"type":"text","text":"Allow","marks":[{"type":"code"}]},{"type":"text","text":". The asterisk on the resource policy: within the same account an "},{"type":"text","text":"Allow","marks":[{"type":"code"}]},{"type":"text","text":" in a resource policy can be enough even without an identity policy (the details depend on the principal type), while cross-account access needs an "},{"type":"text","text":"Allow","marks":[{"type":"code"}]},{"type":"text","text":" on both sides."}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Policy type"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Grants permissions?"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Example"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Identity policy (managed or inline)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"yes"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"what the API role may do"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Resource policy"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"yes"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a bucket, queue, KMS key or secret policy"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Permissions boundary"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"no – only limits"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the ceiling for roles created by teams"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Session policy"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"no – only limits"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"narrowing at "},{"type":"text","text":"AssumeRole","marks":[{"type":"code"}]},{"type":"text","text":" time"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"SCP (AWS Organizations)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"no – limits identities in accounts"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"\"nobody disables CloudTrail\""}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"RCP (AWS Organizations, since 2024)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"no – limits access to resources"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"\"our buckets only from our organization\""}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"step-1-the-application-role-policy"},"content":[{"type":"text","text":"Step 1. The application role policy"}]},{"type":"codeGroup","attrs":{"title":"Permission policy and trust policy of the ECS task role"},"content":[{"type":"codeBlock","attrs":{"language":"json","filename":"policies/api-task-policy.json"},"content":[{"type":"text","text":"{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Sid\": \"InvoicesReadWrite\",\n      \"Effect\": \"Allow\",\n      \"Action\": [\"s3:GetObject\", \"s3:PutObject\"],\n      \"Resource\": \"arn:aws:s3:::pierogi-invoices-123456789012/invoices/*\"\n    },\n    {\n      \"Sid\": \"InvoicesKeyViaS3Only\",\n      \"Effect\": \"Allow\",\n      \"Action\": [\"kms:Decrypt\", \"kms:GenerateDataKey\"],\n      \"Resource\": \"arn:aws:kms:eu-central-1:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab\",\n      \"Condition\": { \"StringEquals\": { \"kms:ViaService\": \"s3.eu-central-1.amazonaws.com\" } }\n    },\n    {\n      \"Sid\": \"EnqueueJobs\",\n      \"Effect\": \"Allow\",\n      \"Action\": \"sqs:SendMessage\",\n      \"Resource\": \"arn:aws:sqs:eu-central-1:123456789012:pierogi-jobs\"\n    },\n    {\n      \"Sid\": \"ReadOwnParameters\",\n      \"Effect\": \"Allow\",\n      \"Action\": \"ssm:GetParameter\",\n      \"Resource\": \"arn:aws:ssm:eu-central-1:123456789012:parameter/pierogi/prod/api/*\"\n    }\n  ]\n}"}]},{"type":"codeBlock","attrs":{"language":"json","filename":"policies/ecs-task-trust-policy.json"},"content":[{"type":"text","text":"{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Principal\": { \"Service\": \"ecs-tasks.amazonaws.com\" },\n      \"Action\": \"sts:AssumeRole\",\n      \"Condition\": {\n        \"ArnLike\": { \"aws:SourceArn\": \"arn:aws:ecs:eu-central-1:123456789012:*\" },\n        \"StringEquals\": { \"aws:SourceAccount\": \"123456789012\" }\n      }\n    }\n  ]\n}"}]}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Specific actions and resources.","marks":[{"type":"bold"}]},{"type":"text","text":" "},{"type":"text","text":"s3:GetObject","marks":[{"type":"code"}]},{"type":"text","text":" and "},{"type":"text","text":"s3:PutObject","marks":[{"type":"code"}]},{"type":"text","text":" only on "},{"type":"text","text":"invoices/*","marks":[{"type":"code"}]},{"type":"text","text":" – no "},{"type":"text","text":"s3:*","marks":[{"type":"code"}]},{"type":"text","text":", no "},{"type":"text","text":"DeleteObject","marks":[{"type":"code"}]},{"type":"text","text":", no listing the whole bucket."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"kms:ViaService","marks":[{"type":"code"}]},{"type":"text","text":" – the role can use the key only through S3. Even with stolen credentials, nobody can decrypt anything with it directly through the KMS API."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Parameter Store by path","marks":[{"type":"bold"}]},{"type":"text","text":" – "},{"type":"text","text":"/pierogi/prod/api/*","marks":[{"type":"code"}]},{"type":"text","text":", not every parameter in the account."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"A trust policy with ","marks":[{"type":"bold"}]},{"type":"text","text":"aws:SourceAccount","marks":[{"type":"code"}]},{"type":"text","text":" and ","marks":[{"type":"bold"}]},{"type":"text","text":"aws:SourceArn","marks":[{"type":"code"}]},{"type":"text","text":" – protects against the "},{"type":"text","text":"confused deputy","marks":[{"type":"italic"}]},{"type":"text","text":": the ECS service assumes this role only on behalf of tasks from our account and region."}]}]}]},{"type":"callout","attrs":{"variant":"warning","title":"The task role is not the execution role"},"content":[{"type":"paragraph","content":[{"type":"text","text":"ECS uses two roles. The "},{"type":"text","text":"execution role","marks":[{"type":"bold"}]},{"type":"text","text":" belongs to the ECS agent: it pulls the image from ECR, writes logs, reads secrets injected as environment variables. The "},{"type":"text","text":"task role","marks":[{"type":"bold"}]},{"type":"text","text":" is the credentials your code gets through the SDK. Mixing them up – or using one role for both – means your application code can read every secret and image repository."}]}]},{"type":"heading","attrs":{"level":2,"id":"step-2-roles-in-cdk-handy-grant-and-its-price"},"content":[{"type":"text","text":"Step 2. Roles in CDK: handy "},{"type":"text","text":"grant*","marks":[{"type":"code"}]},{"type":"text","text":" and its price"}]},{"type":"codeGroup","attrs":{"title":"ECS and Lambda roles with a permissions boundary (AWS CDK)"},"content":[{"type":"codeBlock","attrs":{"language":"typescript","filename":"infra/lib/app-roles.ts"},"content":[{"type":"text","text":"import { Construct } from 'constructs';\nimport * as iam from 'aws-cdk-lib/aws-iam';\nimport * as ecs from 'aws-cdk-lib/aws-ecs';\nimport * as lambda from 'aws-cdk-lib/aws-lambda';\nimport * as s3 from 'aws-cdk-lib/aws-s3';\nimport * as sqs from 'aws-cdk-lib/aws-sqs';\nimport * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';\n\nexport interface AppRolesProps {\n  invoices: s3.IBucket;\n  jobs: sqs.IQueue;\n  dbSecret: secretsmanager.ISecret;\n  boundary: iam.IManagedPolicy;\n}\n\nexport class AppRoles extends Construct {\n  constructor(scope: Construct, id: string, props: AppRolesProps) {\n    super(scope, id);\n    // Every role created inside this construct gets the permissions boundary.\n    iam.PermissionsBoundary.of(this).apply(props.boundary);\n\n    const task = new ecs.FargateTaskDefinition(this, 'ApiTask', { cpu: 512, memoryLimitMiB: 1024 });\n    task.addContainer('api', {\n      image: ecs.ContainerImage.fromRegistry('public.ecr.aws/docker/library/node:24-alpine'),\n      logging: ecs.LogDrivers.awsLogs({ streamPrefix: 'api' }),\n      // Injected at start by the ECS agent → GetSecretValue lands on the EXECUTION role.\n      secrets: { DB_PASSWORD: ecs.Secret.fromSecretsManager(props.dbSecret, 'password') },\n    });\n\n    // The TASK role is what your code gets from the SDK.\n    // grantReadWrite() would also add s3:DeleteObject*, s3:PutObjectRetention, s3:List*…\n    // For sensitive data, write the two actions you actually need.\n    task.taskRole.addToPrincipalPolicy(new iam.PolicyStatement({\n      actions: ['s3:GetObject', 's3:PutObject'],\n      resources: [props.invoices.arnForObjects('invoices/*')],\n    }));\n    props.invoices.encryptionKey?.grant(task.taskRole, 'kms:Decrypt', 'kms:GenerateDataKey');\n    props.jobs.grantSendMessages(task.taskRole); // SendMessage + GetQueueAttributes + GetQueueUrl\n\n    // A Lambda gets its own role – never share one \"app role\" across services.\n    const thumbnailer = new lambda.Function(this, 'Thumbnailer', {\n      runtime: lambda.Runtime.NODEJS_24_X,\n      handler: 'index.handler',\n      code: lambda.Code.fromInline('exports.handler = async () => ({ ok: true });'),\n    });\n    props.invoices.grantRead(thumbnailer, 'uploads/*');\n  }\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"infra/lib/boundary.ts"},"content":[{"type":"text","text":"import { Construct } from 'constructs';\nimport { Stack } from 'aws-cdk-lib';\nimport * as iam from 'aws-cdk-lib/aws-iam';\n\n/** The ceiling for every role a product team creates: workload services only, one region, no IAM. */\nexport function devBoundary(scope: Construct): iam.ManagedPolicy {\n  const region = Stack.of(scope).region;\n  return new iam.ManagedPolicy(scope, 'DevBoundary', {\n    managedPolicyName: 'pierogi-dev-boundary',\n    statements: [\n      new iam.PolicyStatement({\n        sid: 'WorkloadServicesInOurRegion',\n        actions: [\n          's3:*', 'sqs:*', 'dynamodb:*', 'logs:*', 'xray:*', 'cloudwatch:PutMetricData',\n          'secretsmanager:GetSecretValue', 'kms:Decrypt', 'kms:GenerateDataKey',\n          'ecr:GetAuthorizationToken', 'ecr:BatchGetImage', 'ecr:GetDownloadUrlForLayer',\n        ],\n        resources: ['*'],\n        conditions: { StringEquals: { 'aws:RequestedRegion': region } },\n      }),\n    ],\n  });\n}"}]}]}]},"toc":[{"id":"identities-who-is-who","text":"Identities: who is who","level":2,"locked":false},{"id":"how-aws-makes-a-decision","text":"How AWS makes a decision","level":2,"locked":false},{"id":"step-1-the-application-role-policy","text":"Step 1. The application role policy","level":2,"locked":false},{"id":"step-2-roles-in-cdk-handy-grant-and-its-price","text":"Step 2. Roles in CDK: handy grant* and its price","level":2,"locked":false},{"id":"conditions-the-most-important-keys","text":"Conditions: the most important keys","level":2,"locked":true},{"id":"step-3-github-actions-without-keys-oidc","text":"Step 3. GitHub Actions without keys: OIDC","level":2,"locked":true},{"id":"step-4-delegation-with-permissions-boundaries-and-abac","text":"Step 4. Delegation with permissions boundaries and ABAC","level":2,"locked":true},{"id":"step-5-organization-guardrails-scps-and-rcps","text":"Step 5. Organization guardrails: SCPs and RCPs","level":2,"locked":true},{"id":"step-6-access-analyzer-as-a-ci-gate","text":"Step 6. Access Analyzer as a CI gate","level":2,"locked":true},{"id":"credential-hygiene","text":"Credential hygiene","level":2,"locked":true},{"id":"common-mistakes","text":"Common mistakes","level":2,"locked":true},{"id":"test-yourself","text":"Test yourself","level":2,"locked":true},{"id":"what-s-next","text":"What's next","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":59,"visibleBlocks":19,"resources":[{"id":"6b0857bf3c96f2d34d0b42a9","type":"article","provider":"web","url":"https://learn.microsoft.com/en-us/azure/architecture/patterns/federated-identity","embedUrl":null,"title":"Federated Identity Pattern","description":"Use the Federated Identity design pattern to delegate authentication to an external identity provider.","author":"Microsoft Azure Architecture Center","thumbnailUrl":"https://learn.microsoft.com/en-us/media/open-graph-image.png","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["azure","cloud","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":62,"verifiedAt":"2026-11-26T11:07:49.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857ba3c96f2d34d0b3ea7","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/all-about-cedar-an-open-source-solution-for-fine/id915443155?i=1000739301604","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id915443155?i=1000739301604","title":"All About Cedar, an Open Source Solution for Fine-Tuning Kubernetes Authorization","description":"Kubernetes has relied on role-based access control (RBAC) since 2017, but its simplicity limits what developers can express, said Micah Hausler, principal engineer at AWS, on The New Stack Makers. RBAC only allows actions; it can’t enforce conditions, denials, or attribute-based rules. Seeking a…","author":"The New Stack Podcast","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts112/v4/7e/e5/43/7ee54305-38f2-4a29-5014-45d8ac4831e3/mza_10106980059768264551.jpg/600x600bb.jpg","durationSec":973,"lang":"en","topics":["fine-tuning"],"techs":["general"],"tags":["podcast","cloud","kubernetes","ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2025-12-02T15:30:00.000Z","popularity":52,"verifiedAt":"2026-11-26T11:07:16.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:57.868Z","updatedAt":"2026-11-26T16:00:57.868Z"},{"id":"6b0857b53c96f2d34d0b3903","type":"article","provider":"web","url":"https://www.alexanderlolis.com/authorization-in-a-microservices-world","embedUrl":null,"title":"Authorization in a Microservices World","description":"Authorization? How hard can it be? I am pretty sure that others have already solved it. We are not the first ones doing microservices. It should be easy to integrate what's already out there.","author":"alexanderlolis.com","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":["microservices"],"techs":["general"],"tags":["software-architecture","hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2022-04-01T15:11:45.000Z","popularity":69,"verifiedAt":"2026-11-26T11:07:59.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:52.228Z","updatedAt":"2026-11-26T16:00:52.228Z"},{"id":"6b0857bc3c96f2d34d0b4057","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/microservices-security-in-action-with-prabath/id1478997569?i=1000673444208","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id1478997569?i=1000673444208","title":"Microservices Security in Action with Prabath Siriwardena - .NET 201","description":"Microservice architecture is very popular today. The panel talks with microservice security authors about their book and all aspects of securing microservices. Links Microservices Security in Action: Design secure network and API endpoint security for Microservices applications, with examples…","author":"Adventures in .NET","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts211/v4/6a/4e/3b/6a4e3bdb-bbf1-8601-a403-086ce24cb18f/mza_1088513295079016608.jpg/600x600bb.jpg","durationSec":3194,"lang":"en","topics":["microservices"],"techs":["dotnet","java"],"tags":["podcast","kubernetes","security","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2024-10-15T10:00:00.000Z","popularity":44,"verifiedAt":"2026-11-26T11:07:22.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857bf3c96f2d34d0b42b8","type":"article","provider":"web","url":"https://docs.aws.amazon.com/wellarchitected/latest/framework/welcome.html","embedUrl":null,"title":"AWS Well-Architected Framework - AWS Well-Architected Framework","description":"The AWS Well-Architected Framework helps you understand the pros and cons of decisions you make while building systems on AWS. Using the Framework helps you learn architectural best practices for designing and operating secure, reliable, efficient, cost-effective, and sustainable workloads in the…","author":"AWS Well-Architected Framework","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["cloud"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:15.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"}],"challenges":[],"attachments":[],"hasCode":true,"repoUrl":null,"series":[],"prev":null,"next":null,"featured":false,"authorCard":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","headline":"Wzorce projektowe · Architektura · AI i LLM","community":false,"reputation":{"points":3900,"level":{"key":"mentor","label":"Mentor"}},"articles":104,"skills":[{"key":"typescript","title":"TypeScript","level":5,"levelLabel":"Authority","articles":90},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Authority","articles":61},{"key":"python","title":"Python","level":5,"levelLabel":"Authority","articles":59},{"key":"java","title":"Java","level":5,"levelLabel":"Authority","articles":46}]}}