{"id":47232,"date":"2024-10-18T04:27:00","date_gmt":"2024-10-18T04:27:00","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=47232"},"modified":"2024-10-25T07:35:04","modified_gmt":"2024-10-25T07:35:04","slug":"aws-tutorials-iam-difference-of-inline-policies-and-assume-role-policies-also-known-as-trust-policies","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/aws-tutorials-iam-difference-of-inline-policies-and-assume-role-policies-also-known-as-trust-policies\/","title":{"rendered":"AWS Tutorials: IAM Roles Complete Guide"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Common terminologies used in <strong>IAM Roles<\/strong> and <strong>IAM Policies<\/strong> in AWS Identity and Access Management (IAM)<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Term<\/strong><\/th><th><strong>Description<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>IAM Role<\/strong><\/td><td>An IAM entity that defines a set of permissions for making AWS service requests. Roles can be assumed by users, applications, or services.<\/td><\/tr><tr><td><strong>IAM Policy<\/strong><\/td><td>A document that defines permissions for IAM users, groups, and roles. Policies can be attached to roles or users to control access to AWS resources.<\/td><\/tr><tr><td><strong>Trust Policy<\/strong><\/td><td>A policy attached to an IAM role that specifies who can assume the role. It establishes trust between the role and the entity assuming it.<\/td><\/tr><tr><td><strong>Permissions Policy<\/strong><\/td><td>A policy attached to an IAM user, group, or role that defines what actions are allowed or denied on which AWS resources.<\/td><\/tr><tr><td><strong>Principal<\/strong><\/td><td>The entity (user, role, service) that is allowed or denied access to AWS resources. It specifies &#8220;who&#8221; in IAM policies.<\/td><\/tr><tr><td><strong>Action<\/strong><\/td><td>Specifies the specific AWS actions that can be allowed or denied (e.g., <code>s3:PutObject<\/code>, <code>ec2:StartInstances<\/code>).<\/td><\/tr><tr><td><strong>Resource<\/strong><\/td><td>Specifies the AWS resources to which the policy applies (e.g., an S3 bucket, an EC2 instance).<\/td><\/tr><tr><td><strong>Condition<\/strong><\/td><td>Additional conditions that must be met for a policy to apply, such as IP address restrictions, multi-factor authentication (MFA), or time constraints.<\/td><\/tr><tr><td><strong>Assume Role<\/strong><\/td><td>The process by which an IAM principal (user or service) temporarily takes on the permissions of an IAM role.<\/td><\/tr><tr><td><strong>Managed Policy<\/strong><\/td><td>A standalone policy created by AWS or by users that can be attached to multiple users, groups, or roles.<\/td><\/tr><tr><td><strong>Inline Policy<\/strong><\/td><td>A policy embedded directly in a single IAM user, group, or role. It\u2019s specific to that entity and cannot be reused.<\/td><\/tr><tr><td><strong>AWS Managed Policy<\/strong><\/td><td>A policy created and managed by AWS, which includes common permissions sets, such as <code>AmazonS3ReadOnlyAccess<\/code>.<\/td><\/tr><tr><td><strong>Customer Managed Policy<\/strong><\/td><td>A custom policy created by the user to provide specific permissions not covered by AWS Managed Policies.<\/td><\/tr><tr><td><strong>Policy Document<\/strong><\/td><td>The JSON document that defines an IAM policy, specifying permissions, actions, resources, and conditions.<\/td><\/tr><tr><td><strong>Policy Version<\/strong><\/td><td>IAM policies have versions to manage updates. Only one version can be the &#8220;default&#8221; version that is in effect at any time.<\/td><\/tr><tr><td><strong>Session Policy<\/strong><\/td><td>A policy applied during the temporary session of a user who assumes a role, allowing for additional, session-specific permissions.<\/td><\/tr><tr><td><strong>Role Session Name<\/strong><\/td><td>A unique identifier for a session when an IAM role is assumed, often used for logging and tracking purposes.<\/td><\/tr><tr><td><strong>Policy Simulator<\/strong><\/td><td>A tool in IAM that allows testing of policies to see how they will affect access for a specific user or role.<\/td><\/tr><tr><td><strong>STS (Security Token Service)<\/strong><\/td><td>Service that provides temporary credentials to assume roles, allowing short-term access to AWS resources.<\/td><\/tr><tr><td><strong>Permission Boundary<\/strong><\/td><td>An advanced feature that sets a limit on the maximum permissions an IAM role or user can have, regardless of their other attached policies.<\/td><\/tr><tr><td><strong>Temporary Security Credentials<\/strong><\/td><td>Short-term credentials provided by assuming a role, intended for temporary access to AWS resources.<\/td><\/tr><tr><td><strong>Service-linked Role<\/strong><\/td><td>A role created by AWS services that allow those services to manage resources on the user\u2019s behalf (e.g., <code>AWSServiceRoleForSupport<\/code>).<\/td><\/tr><tr><td><strong>PassRole<\/strong><\/td><td>An IAM permission that allows one role to &#8220;pass&#8221; another role to an AWS service, used in scenarios like launching an EC2 instance with an IAM role.<\/td><\/tr><tr><td><strong>Principal ARN<\/strong><\/td><td>The Amazon Resource Name (ARN) that uniquely identifies a principal entity, such as an IAM user or role, within AWS.<\/td><\/tr><tr><td><strong>Effect<\/strong><\/td><td>Specifies whether the policy statement allows or denies access (e.g., <code>\"Effect\": \"Allow\"<\/code> or <code>\"Effect\": \"Deny\"<\/code>).<\/td><\/tr><tr><td><strong>Federated Identity<\/strong><\/td><td>Allows external identities (e.g., from Google, Facebook, or corporate directory) to access AWS resources through IAM roles.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Difference of inline policies and assume role policies (also known as trust policies)<\/h2>\n\n\n\n<p>In AWS IAM (Identity and Access Management), <strong>inline policies<\/strong> and <strong>assume role policies<\/strong> (also known as <strong>trust policies<\/strong>) serve different purposes within the lifecycle of IAM roles. Here&#8217;s a breakdown of the key differences between the two:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>Inline Policy<\/strong>:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Purpose<\/strong>: An inline policy is a <strong>permission policy<\/strong> that is embedded directly into an IAM role, user, or group. It defines what actions the role can perform on AWS resources.<\/li>\n\n\n\n<li><strong>Function<\/strong>: Controls <strong>what actions<\/strong> the role can take and on which resources.<\/li>\n\n\n\n<li><strong>Policy Type<\/strong>: These are <strong>permission policies<\/strong>. They grant permissions to the entity (role, user, or group) they are attached to.<\/li>\n\n\n\n<li><strong>Example Use Case<\/strong>: An inline policy for an IAM role might allow it to perform specific actions, such as listing all S3 buckets or launching EC2 instances.<\/li>\n<\/ul>\n\n\n\n<p><strong>Where It&#8217;s Stored<\/strong>: Inline policies are stored directly in the IAM role, user, or group they are attached to.<\/p>\n\n\n\n<p><strong>Control<\/strong>: Fine-grained control for individual users, roles, or groups.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"510\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-11-1024x510.png\" alt=\"\" class=\"wp-image-47233\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-11-1024x510.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-11-300x149.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-11-768x382.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-11.png 1430w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>Assume Role Policy (Trust Policy)<\/strong>:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Purpose<\/strong>: The assume role policy (or trust policy) defines <strong>who<\/strong> or <strong>what entity<\/strong> (user, service, or another AWS account) can <strong>assume<\/strong> the IAM role. This policy grants permission to another entity to assume the role and temporarily gain its permissions.<\/li>\n\n\n\n<li><strong>Function<\/strong>: Controls <strong>who can assume the role<\/strong> and under what conditions.<\/li>\n\n\n\n<li><strong>Policy Type<\/strong>: These are <strong>trust policies<\/strong>. They define the relationship between the role and the principal (like an IAM user, another role, or AWS service) that can assume it.<\/li>\n\n\n\n<li><strong>Example Use Case<\/strong>: An EC2 instance might assume an IAM role that has permissions to write to an S3 bucket, but only if the trust policy allows the EC2 service to assume the role.<\/li>\n<\/ul>\n\n\n\n<p><strong>Where It&#8217;s Stored<\/strong>: The assume role policy is stored in the <strong>IAM role itself<\/strong> and determines who can assume the role.<\/p>\n\n\n\n<p><strong>Control<\/strong>: Controls <strong>who<\/strong> can assume the role, typically allowing a user or service (like EC2, Lambda, etc.) to use the role&#8217;s permissions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"586\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-12-1024x586.png\" alt=\"\" class=\"wp-image-47234\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-12-1024x586.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-12-300x172.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-12-768x440.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/10\/image-12.png 1404w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Summary of Differences:<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th><strong>Inline Policy<\/strong><\/th><th><strong>Assume Role Policy (Trust Policy)<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Purpose<\/strong><\/td><td>Grants permissions for actions on AWS resources<\/td><td>Defines who (user, service, AWS account) can assume the role<\/td><\/tr><tr><td><strong>Type<\/strong><\/td><td>Permission policy<\/td><td>Trust policy<\/td><\/tr><tr><td><strong>Controls<\/strong><\/td><td>What actions the role can perform<\/td><td>Who can assume the role<\/td><\/tr><tr><td><strong>Attached To<\/strong><\/td><td>Roles, users, or groups<\/td><td>IAM roles<\/td><\/tr><tr><td><strong>Example Usage<\/strong><\/td><td>Allow a role to list S3 buckets or start EC2 instances<\/td><td>Allow EC2 instances to assume a role and access its policies<\/td><\/tr><tr><td><strong>Policy Example<\/strong><\/td><td><code>\"Action\": \"s3:ListBucket\"<\/code><\/td><td><code>\"Principal\": \"ec2.amazonaws.com\"<\/code><\/td><\/tr><tr><td><strong>Stored In<\/strong><\/td><td>Embedded directly in the role, user, or group<\/td><td>Defined within the IAM role itself<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Key Takeaways:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Inline policies<\/strong> grant permissions to the <strong>entity<\/strong> they are attached to.<\/li>\n\n\n\n<li><strong>Assume role policies<\/strong> (trust policies) define who can <strong>assume<\/strong> the role and temporarily gain its permissions.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Common terminologies used in IAM Roles and IAM Policies in AWS Identity and Access Management (IAM) Term Description IAM Role An IAM entity that defines a set of permissions for&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-47232","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=47232"}],"version-history":[{"count":5,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47232\/revisions"}],"predecessor-version":[{"id":47268,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47232\/revisions\/47268"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=47232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=47232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=47232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}