Skip to content
CertDirectory.io

Limited Time: 40% OFF all Linux Foundation Certifications. Save now

Back to the blog
Study notes13 min read

IAM Users, Groups, Roles සහ Policies

Kavinda Dilshan17 Nov 2026

gpt-image-2_a_surreal_and_vibrant_cinematic_photo_of_IAM_Users_Groups_Roles_සහ_Policies_-0

IAM Users, Groups, Roles සහ Policies – මේ හතර අතර ඇත්තටම වෙනස මොකක්ද?

AWS IAM ඉගෙනගන්න පටන් ගත්තම මුලින්ම හම්බවෙන words හතරක් තියෙනවා.

Users.

Groups.

Roles.

Policies.

Documentation එක බලනකොට definitions තේරෙනවා වගේ.

හැබැයි AWS Console එක open කරලා practical environment එකකට ගියාම suddenly questions ගොඩක් එනවා.

“User එකයි Role එකයි වෙනස මොකක්ද?”

“Group එකකට Policy එකක් attach කරන්නේ ඇයි?”

“EC2 එකකට User එකක් හදන්න ඕනද?”

“Role එකකට login වෙන්න පුළුවන්ද?”

“Policy එක permission එකක්ද?”

මේ confusion එක normal.

හැබැයි මේ හතර එක story එකක් විදිහට තේරුම් ගත්තම IAM ගොඩක් simple වෙනවා.

අපි අද ඒ story එක බලමු.


මුලින්ම Company එකක් imagine කරන්න

හිතන්න Software Company එකක් තියෙනවා.

Company එකේ:

  • Developers

  • DevOps Engineers

  • Database Engineers

  • Security Engineers

  • Finance Team

වැඩ කරනවා.

AWS Account එක ඇතුළේ:

  • EC2 Servers

  • S3 Buckets

  • RDS Databases

  • Lambda Functions

  • CloudWatch Logs

තියෙනවා.

දැන් Company එකට solve කරන්න තියෙන ලොකුම security problem එක:

“කාට මොනවා කරන්න දෙන්නද?”

Developer කෙනෙක්ට logs බලන්න ඕන.

හැබැයි Billing settings modify කරන්න ඕන නැහැ.

Database Engineer කෙනෙක්ට RDS manage කරන්න ඕන.

හැබැයි IAM configuration change කරන්න ඕන නැහැ.

Application එකකට S3 Bucket එකක් read කරන්න ඕන.

හැබැයි complete AWS account access කරන්න ඕන නැහැ.

IAM Users, Groups, Roles සහ Policies තියෙන්නේ මේ access problem එක solve කරන්න.

AWS IAM වල policies users, user groups සහ roles වගේ identities සමඟ associate කර permissions define කරන්න පුළුවන්.


1. IAM User – “මේ identity එක කවුද?”

මුලින්ම IAM User.

IAM User කියන්නේ AWS Account එකක් ඇතුළේ create කරන identity එකක්.

Simple example එකක්:

Company එකේ developer කෙනෙක්:

Nimal

IAM User එකක්:

nimal-dev

දැන් AWS එකට identity එකක් තියෙනවා.

හැබැයි මෙතන වැදගත්ම දෙයක් තියෙනවා.

IAM User එක create කළා කියලා automatically AWS resources access කරන්න permissions ලැබෙන්නේ නැහැ.

AWS documentation අනුව IAM user එකක් මුලින් permissions නැතුව create වෙනවා; access අවශ්‍ය නම් policy එකක් හරහා permissions grant කරන්න වෙනවා.

ඒ කියන්නේ:

User = Identity

User කියන්නේ permission එක නෙවෙයි.

මේ difference එක මතක තියාගන්න.


Office example එකකින් බලමු

Company building එකකට Nimal join වෙනවා.

HR department එක Nimalට Employee ID එකක් දෙනවා.

දැන් company එක දන්නවා:

“මේ Nimal.”

හැබැයි Employee ID එකක් තියෙනවා කියලා Server Room එකට access automatically ලැබෙන්නේ නැහැ.

Finance Room එකටත් යන්න බෑ.

CEO Office එකටත් යන්න බෑ.

Identity එක තියෙනවා.

Permissions වෙනම define කරන්න ඕන.

IAM User එකත් ඒ වගේ.


2. IAM Group – “මේ users ලා එකම team එකේ”

දැන් Company එකේ Developers 50 දෙනෙක් ඉන්නවා කියලා හිතන්න.

හැම Developer කෙනාටම individually permissions configure කරනවා.

Developer 1 → EC2 Read

Developer 2 → EC2 Read

Developer 3 → EC2 Read

Developer 4 → EC2 Read

...

Developers 50 දෙනෙක්.

ඒක maintain කරන්න අමාරුයි.

Tomorrow Developer කෙනෙක් join වෙනවා.

Permissions manually add කරන්න ඕන.

Developer කෙනෙක් team change කරනවා.

Permissions modify කරන්න ඕන.

Permissions inconsistent වෙන්නත් පුළුවන්.

එතන තමයි IAM Group useful වෙන්නේ.

AWS අනුව IAM user group එකක් කියන්නේ IAM users collection එකක්; permissions multiple users සඳහා එකම තැනක manage කරන්න groups භාවිතා කරන්න පුළුවන්.


Example එකක්

Group එකක් create කරනවා:

Developers

ඒකට Policy එකක් attach කරනවා:

  • EC2 Read

  • CloudWatch Logs Read

  • S3 Development Bucket Access

දැන්:

Nimal → Developers Group

Kasun → Developers Group

Amali → Developers Group

Developers Group එකට තියෙන permissions මේ users ලාට ලැබෙනවා.

New Developer කෙනෙක් join වෙනවා?

Group එකට add කරන්න.

Simple.


Group එකේ beauty එක

IAM Group එක permissions management organize කරනවා.

Think about this:

User = Individual

Group = Team

Company structure එක AWS permissions structure එකට map කරන්න පුළුවන්.

Examples:

Developers

DatabaseAdmins

SecurityTeam

ReadOnlyUsers

OperationsTeam

මේක permissions manage කරන එක ගොඩක් clean කරනවා.

හැබැයි technical point එකක්:

IAM Group කියන්නේ authentication identity එකක් නෙවෙයි.

Group එකකට login වෙන්නේ නැහැ.

Users තමයි authenticate වෙන්නේ.

Group එක permissions organize කරන්න use කරනවා. AWS documentation අනුව IAM user group එක resource-based policy එකක Principal එකක් ලෙස භාවිතා කරන්න බැහැ, මොකද group එක authenticated principal එකක් නොව permissions-management mechanism එකක්.


3. IAM Role – මේක තමයි beginners ලා confuse වෙන තැන

දැන් Role.

User එකක් තේරුණා.

Group එකක් තේරුණා.

හැබැයි Role එක?

Role එකත් identity එකක්.

හැබැයි User එකකට වඩා powerful difference එකක් තියෙනවා.

Role එක assume කරනවා.

Role එක permanent person කෙනෙක් එක්ක bind වෙලා තියෙන්න ඕන නැහැ.

Human user කෙනෙක් Role එකක් assume කරන්න පුළුවන්.

AWS Service එකක් Role එකක් assume කරන්න පුළුවන්.

Application එකක් Role එකක් use කරන්න පුළුවන්.

Different AWS Account එකක identity එකකට Role එක assume කරන්න පුළුවන්.

AWS IAM roles federation, cross-account access, AWS service access සහ EC2 වගේ workloads සඳහා temporary permissions ලබාදීමට භාවිතා කරන්න පුළුවන්.


Role එක uniform එකක් වගේ හිතන්න

හිතන්න hospital එකක්.

Normal employee කෙනෙක් ඉන්නවා.

Emergency එකක් වෙලාවට specific duty එකක් assign කරනවා.

ඒ duty එකට අවශ්‍ය access temporary විදිහට ලැබෙනවා.

Duty එක ඉවරයි.

Access එකත් ඉවරයි.

IAM Role එකේ idea එකත් ටිකක් එහෙම.

Role එක assume කරනවා.

Role එකේ permissions temporary use කරනවා.

Session එක ඉවර වුණාම temporary credentials expire වෙනවා.

ඒ නිසා long-term credentials share කරනවාට වඩා Roles ගොඩක් situations වල safer pattern එකක්.


EC2 + S3 example එක

මේ example එක IAM Roles තේරුම්ගන්න ගොඩක් වැදගත්.

හිතන්න EC2 Server එකක Application එකක් run වෙනවා.

Application එකට S3 Bucket එකෙන් files read කරන්න ඕන.

Beginner approach එක:

IAM User එකක් create කරනවා.

Access Key එකක් create කරනවා.

Secret Key එකක් create කරනවා.

Code එකේ දානවා.

AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...

Everything works.

හැබැයි security problem එක huge.

Code GitHub එකට accidentally push වුණොත්?

Credentials leak.

Attackerට AWS resources access කරන්න පුළුවන්.

Better approach?

IAM Role

EC2 instance එකට Role එකක් attach කරනවා.

Role එකට S3 read permissions දෙන්න.

Application එක temporary credentials use කරනවා.

Long-term access key එක code එක ඇතුළේ තියාගන්න අවශ්‍ය නැහැ.

මේක IAM Roles වල powerful use case එකක්.


User vs Role – biggest difference එක

Simple විදිහට:

User

“I am this identity.”

IAM Account එක ඇතුළේ identity එකක්.

Role

“For this session, I am assuming these permissions.”

Temporary access use cases වල ගොඩක් powerful.

මේ line දෙක මතක තිබ්බොත් confusion ගොඩක් අඩු වෙනවා.


Role එකේ Policies දෙකක් ගැන හිතන්න

Role එක තවත් interesting.

Role එකට important questions දෙකක් තියෙනවා.

Question 1

“මේ Role එක assume කරන්න කාටද පුළුවන්?”

මේක Trust Policy එකෙන් define කරනවා.

Question 2

“Role එක assume කළාට පස්සේ මොනවද කරන්න පුළුවන්?”

මේක permissions policies වලින් define කරනවා.

AWS documentation අනුව Role එකක trust policy එක role එක assume කරන්න පුළුවන් principal සහ conditions define කරනවා; identity-based policies role එක භාවිතා කරන principalට ලැබෙන permissions define කරනවා.

මේ difference එක IAM Roles deeply understand කරන්න ගොඩක් වැදගත්.


4. IAM Policy – “Rules මොනවද?”

දැන් මේ whole story එකේ rules engine එකට එමු.

IAM Policy

Policy කියන්නේ permissions define කරන document එකක්.

AWS policies බොහෝවිට JSON format එකෙන් තියෙනවා.

Simple example:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::company-images/*"
    }
  ]
}

මේක human language එකෙන් කියනවා නම්:

“මේ identity එකට **company-images** S3 Bucket එකේ objects read කරන්න දෙන්න.”

Simple.


Policy එකක basic questions

Policy එක basically questions තුනකට answer කරනවා.

Effect

Allow ද? Deny ද?

Action

මොන action එක කරන්නද?

Example:

s3:GetObject

ec2:StartInstances

ec2:StopInstances

Resource

මොන resource එකටද?

Specific Bucket එකක්?

Specific Server එකක්?

Specific Database එකක්?

මේ combination එකෙන් permissions precise විදිහට control කරන්න පුළුවන්.


User + Policy

දැන් combinations බලමු.

Nimal කියන IAM User එක තියෙනවා.

Policy එක:

ReadOnlyS3

Nimalට policy එක attach කරනවා.

දැන් Nimalට policy එකේ define කරලා තියෙන permissions ලැබෙනවා.

Simple.


Group + Policy

Developers Group එක තියෙනවා.

Policy එක attach කරනවා:

DevelopmentEnvironmentAccess

Developers Group එකේ:

Nimal

Kasun

Amali

තුන්දෙනාම ඒ permissions inherit කරනවා.

AWS documentation අනුව group එකකට policy එකක් attach කළාම group එකේ users ලාට එම policy permissions ලැබෙනවා.


Role + Policy

Role:

EC2-S3-ReadRole

Policy:

S3ReadOnlyForImages

EC2 Instance එක Role එක assume/use කරනවා.

දැන් EC2 Application එකට required S3 resources access කරන්න පුළුවන්.

No hard-coded long-term credentials.

Clean.


මේ හතර එකට connect කරමු

දැන් full picture එක බලමු.

IAM User

Individual identity

IAM Group

Users organize කරන collection එක

IAM Role

Temporary / assumable identity

IAM Policy

Permissions define කරන rules

ඒ කියන්නේ:

Users, Groups සහ Roles → කාට/මොන identity එකට access ලැබෙනවද?

Policies → ඔවුන්ට මොනවා කරන්න පුළුවන්ද?


Office Building example එක නැවත බලමු

මේකෙන් whole IAM model එක මතක තියාගන්න පුළුවන්.

User

Employee ID Card එක.

“මම කවුද?”

Group

Department එක.

“මම Developers Team එකේ.”

Role

Temporary Duty Badge එක.

“මේ වෙලාවේ මම Production Support Role එකේ.”

Policy

Door Access Rules.

“මේ badge එකෙන් මේ doors open කරන්න පුළුවන්.”

IAM suddenly simple.


Practical Company Example එකක්

Company එකේ Developers 10 දෙනෙක්.

Developers Group එකක් හදනවා.

Policy:

  • Development EC2 manage කරන්න

  • Development S3 access කරන්න

  • CloudWatch logs බලන්න

  • Production resources deny කරන්න

දැන් developers group එකට developers add කරනවා.


Production emergency එකක් එනවා.

Senior Engineer කෙනෙක්ට temporarily Production access ඕන.

Permanent Administrator permission දෙන්නේ නැහැ.

ProductionSupportRole කියලා Role එකක් තියෙනවා.

Senior Engineer ඒ Role එක assume කරනවා.

Limited time එකකට required permissions ලැබෙනවා.

Work එක කරනවා.

Session එක expire වෙනවා.

මේක security perspective එකෙන් beautiful design pattern එකක්.

Permanent power වෙනුවට temporary, controlled access.


Policy Types

IAM deeper ගියාම policies types කිහිපයක් හම්බවෙනවා.

Mainly beginners ලාට මුලින්ම තේරුම්ගන්න useful දෙක:

Identity-Based Policy

User, Group හෝ Role එකකට attach කරන policy.

Question එක:

“මේ identity එකට මොනවා කරන්න පුළුවන්ද?”

Resource-Based Policy

Resource එකට directly attach කරන policy.

Example:

S3 Bucket Policy.

Question එක:

“මේ resource එකට කවුද access කරන්න පුළුවන්?”

AWS IAM identity-based සහ resource-based policies දෙකම support කරනවා.


Managed Policy සහ Inline Policy

තවත් terms දෙකක්:

Managed Policy

සහ

Inline Policy

Managed Policy එක reusable.

Multiple users, groups හෝ roles වලට attach කරන්න පුළුවන්.

Inline Policy එක specific identity එකකට directly embed වෙනවා.

AWS IAM managed සහ inline policy types දෙකම support කරනවා.

Beginner කෙනෙක්ට මේ stage එකේ important lesson එක:

Policy කියන්නේ permission definition එක.

Policy attach කරන identity එක අනුව ඒ permissions apply වෙනවා.


Least Privilege මෙතනත් අමතක කරන්න එපා

හිතන්න Developer කෙනෙක්ට එක S3 Bucket එකක් read කරන්න ඕන.

Easy solution:

AdministratorAccess

Everything works!

No permission errors.

Developer happy.

Engineer happy.

Until…

Account compromise වෙනකම්.

Good Security කියන්නේ error message remove කරන එක නෙවෙයි.

Good Security කියන්නේ:

Task එක කරන්න අවශ්‍ය minimum permission එක විතරක් ලබාදෙන එක.

මේකට කියන්නේ:

Principle of Least Privilege


“Permission Denied” කියන්නේ enemy එකක් නෙවෙයි

Beginners ලා AWS use කරනකොට මේ message එක දැක්කම frustrated වෙනවා.

AccessDenied

“අනේ permission එකක් දෙන්න.”

ඊට පස්සේ AdministratorAccess attach කරනවා.

Problem solved.

Technically.

Security problem created.

AccessDenied error එක sometimes IAM ඔයාගේ system එක protect කරනවා කියන signal එකක්.

Correct approach:

Exactly මොන action එකට permission ඕනද?

බලන්න.

Required action එක identify කරන්න.

Required resource එක identify කරන්න.

Minimum permissions ලබාදෙන්න.

එතන තමයි IAM ඉගෙනගන්න එක පටන් ගන්නේ.


Human users ගැන modern AWS approach එක

Another important point.

IAM User කියන concept එක දැනගන්නම ඕන.

හැබැයි modern AWS environments වල workforce access සඳහා හැම employee කෙනාටම long-term IAM user credentials create කරන එක always preferred approach එක නෙවෙයි.

AWS federation සහ IAM Identity Center වගේ mechanisms භාවිතා කර temporary credentials සහ centralized workforce access භාවිතා කරන approaches recommend කරනවා.

ඒ නිසා:

IAM User concept එක වැදගත්.

හැබැයි:

“AWS access ඕන හැම human කෙනාටම IAM User එකක් create කරන්න”

කියන rule එකක් නෑ.


Group එක Roles වලට use කරනවද?

IAM Group එක mainly IAM Users organize කරන්නයි.

Group එක ඇතුළේ Roles දාන්නේ නැහැ.

Nested groups දාන්නේත් නැහැ.

Simple mental model:

Group = Users collection

එච්චරයි.

මේක interview question එකක් විදිහටත් එන්න පුළුවන්.


Role එකට password එකක් තියෙනවද?

IAM User එකකට credentials තියෙන්න පුළුවන්.

Role එකත් User වගේ permanent username/password identity එකක් කියලා හිතන්න එපා.

Role එක assume කරන identity එක temporary credentials ලබාගෙන role permissions use කරනවා.

මේ temporary access concept එකම IAM Roles powerful කරනවා.


Cross-Account Example එකක්

Company එකට AWS Accounts දෙකක් තියෙනවා.

Development Account

Developers daily වැඩ කරනවා.

Production Account

Critical production systems තියෙනවා.

Production account එකට separate IAM users create කරලා passwords distribute කරනවා වෙනුවට…

Production Account එකේ Role එකක් create කරන්න පුළුවන්.

ProductionReadOnlyRole

Development/central identity environment එකේ authorized engineers ලා ඒ Role එක assume කරනවා.

Temporary permissions ලැබෙනවා.

Session එක ඉවරයි.

Access expire.

IAM Roles cross-account access සඳහා AWS-supported pattern එකක්.


Machinesට Users create කරන්න එපා කියන lesson එක

මේක මතක තියාගන්න.

EC2 එකකට AWS access ඕන?

Role ගැන හිතන්න.

Lambda එකකට S3 access ඕන?

Execution Role ගැන හිතන්න.

Application workload එකකට AWS services access ඕන?

Temporary credentials / workload identity pattern ගැන හිතන්න.

Static access keys avoid කරන්න පුළුවන් නම් avoid කරන්න.

Secrets distribute කරනවාට වඩා identities assign කරන එක cleaner.


IAM වල beautiful thing එක

IAM මුලින් බලද්දී boring security service එකක් වගේ පේන්න පුළුවන්.

JSON files.

Permissions.

Users.

Policies.

Roles.

හැබැයි production system එකක් manage කරන්න පටන් ගත්තම IAM එකේ value එක දැනෙනවා.

මොකද question එක technical විතරක් නෙවෙයි.

Question එක trust ගැන.

“මම මේ identity එකට කොච්චර power එකක් දෙන්නද?”

Too little access?

Work කරන්න බෑ.

Too much access?

Risk.

IAM කියන්නේ මේ දෙක අතර balance එක design කරන එක.


Simple diagram එකක්

මේක mind එකේ තියාගන්න:

                Policy
                  │
        ┌─────────┼─────────┐
        │         │         │
      User      Group      Role
        │         │         │
      Person    Users    Person / App /
                         AWS Service

Policy කියන්නේ rules.

User, Group, Role කියන්නේ ඒ rules apply කරන targets / identities.


තව ලේසිම විදිහ

Interview එකක:

IAM User කියන්නේ මොකක්ද?

→ AWS account එකක් ඇතුළේ individual identity එකක්.

IAM Group කියන්නේ?

→ IAM Users collection එකක්, permissions easily manage කරන්න.

IAM Role කියන්නේ?

→ Trusted principal එකකට assume කරන්න පුළුවන් identity එකක්, සාමාන්‍යයෙන් temporary credentials එක්ක.

IAM Policy කියන්නේ?

→ AWS resources මත allowed/denied actions define කරන permissions document එකක්.

Done.


හැබැයි Engineer කෙනෙක් definition එකෙන් නවතින්නේ නැහැ

Engineer කෙනෙක් අහනවා:

“මේ User එක අවශ්‍යද?”

“Group එකෙන් permissions manage කරන්න පුළුවන්ද?”

“Permanent credentials වෙනුවට Role use කරන්න පුළුවන්ද?”

“Policy එක too broad ද?”

“Resource * use කරන්න ඇත්තටම ඕනද?”

“Temporary access දෙන්න පුළුවන්ද?”

“මේ permission එක තවමත් අවශ්‍යද?”

මේ questions තමයි IAM security improve කරන්නේ.


Imagine කරන්න…

Friday evening.

Production system එකේ issue එකක්.

Engineer කෙනෙක්ට emergency access ඕන.

Easy solution:

AdministratorAccess.

Fast.

Problem solve.

හැබැයි six months laterත් ඒ AdministratorAccess තවම තියෙනවා.

Nobody remembers why.

Engineerගේ credentials leak වෙනවා.

Suddenly emergency permission එක permanent security risk එකක් වෙලා.

IAM design කරනකොට permissions create කරන එක විතරක් නෙවෙයි.

Permissions lifecycle එකත් හිතන්න ඕන.

Who needs it?

Why?

For how long?

Can it be temporary?

Can we remove it afterwards?

මේ තමයි mature security thinking.


මතක තියාගන්න Golden Rule එක

IAM වල complicated documents, conditions සහ policy evaluation rules ගොඩක් තියෙනවා.

හැබැයි beginner stage එකේ එක sentence එකක් මතක තියාගන්න.

Identity tells AWS WHO.

Policy tells AWS WHAT THEY CAN DO.

Users සහ Roles identities.

Groups users organize කරනවා.

Policies permissions define කරනවා.

එච්චරයි.

එතනින් IAM world එක build වෙන්න පටන් ගන්නවා.


අවසානයේ...

Cloud Security කියන්නේ hackers ලා stop කරන එක විතරක් නෙවෙයි.

Sometimes biggest risk එක attacker කෙනෙක් නෙවෙයි.

වැරදි permission එකක්.

Developer කෙනෙක් accidentally production resource එකක් delete කරනවා.

Application එකකට unnecessary permissions තියෙනවා.

Access Key එකක් leak වෙනවා.

Old employee account එක තවම active.

Temporary requirement එකකට දීපු AdministratorAccess permanent වෙලා.

මේ හැම problem එකක්ම අපිට එක lesson එකක් දෙනවා:

Access matters.

IAM User අපිට කියනවා:

“Who?”

Group එක කියනවා:

“Which team?”

Role එක කියනවා:

“What temporary identity can be assumed?”

Policy එක කියනවා:

“What are they allowed to do?”

මේ හතර හරියට connect කළාම IAM complicated menu එකක් නෙවෙයි.

එක logical security system එකක්.

Good Cloud Engineer කෙනෙක් resource එකක් create කරන්න කලින්:

“How do I build this?”

කියලා අහනවා.

Great Cloud Engineer කෙනෙක් ඒකට තවත් question එකක් add කරනවා:

“Who should be allowed to touch it?”

ඒ question එකෙන් තමයි real Cloud Security පටන් ගන්නේ.

ඊළඟට අපි IAM එකේ තවත් powerful topic එකක් බලමු:

“IAM Policies ඇත්තටම වැඩ කරන්නේ කොහොමද? Allow, Deny, Action, Resource සහ Principal සරලව”

JSON policy එකක් line-by-line බලලා, AWS permission decision එක ගන්නේ කොහොමද කියලා එතනින් තේරුම් ගමු.