IAM - Policies

AWS Policies

AWS policies, as the name implies, allow you to set permissions to access your AWS resources. This is essential for controlling who can do what with your AWS services.

There are two types of policies :

  • Resource based policy (This can be applied to specific services (not all supports this) )
  • Identity based policy (This can be applied to users,groups and roles)

Example Policy for Full Access to S3

Let's suppose we want to provide full access to the S3 resource. Here's an example policy:




  • Version: The version number of the policy language.
  • Statement: The key part of the policy. Each statement includes:
    • Effect: Can be either Allow or Deny.
    • Action: Specifies the actions that are allowed. The s3:* wildcard means all actions on Amazon S3 are allowed, including creating, listing, and deleting buckets, uploading and downloading objects, setting permissions, etc.
    • Resource: Specifies the resources that the actions apply to. The * wildcard means all resources. In the context of S3, it means all buckets and all objects within those buckets.

Managed vs Inline Policies

Managed Policies:

  • Managed policies can be either AWS-managed or user-managed.
  • AWS-managed policies are created and maintained by AWS. These are a great starting point if you are not familiar with policy concepts or not comfortable creating your own.
  • User-managed policies are created and maintained by users, giving more flexibility to manage policies themselves.

Inline Policies:

  • Inline policies are directly attached to a user, group, or role.
  • These are good for specific sets of permissions which will not be used again.
  • They are not generally widely used and can be harder to maintain.

Creating an Inline Policy for a Test User

Let's create an inline policy for our test user:

  1. Navigate to IAM Users:

    • In the IAM Users section, click on the user you want to create the policy for.
    • Click the "Add permissions" drop-down button and select the "Create Inline Policy" option.


  2. Select Service:

    • On the service selection page, choose the service you want to limit or extend access to.


  3. Specify Actions:

    • Specify which actions to allow or deny. For example, to allow all reading-related actions, you might check the "Get Object" permission in the list for reading actions on an S3 bucket.


  4. Specify Resources:

    • In the Resources section, specify which resources these permissions apply to.
    • You need to use the Amazon Resource Name (ARN) to specify the resource. For instance, if you created an S3 bucket and want to provide specific access to your test user, instead of selecting "Any in this account," you will add the ARN of that bucket. This way, the test user will have access rights only to that specific bucket.




  5.  Click to "Next" and that is it we successfully defined your inline policy for test user.

Comments

Popular posts from this blog

Identity Access Management - How to create user in IAM ?!

AWS pricing fundamentals

IAM - Roles