AWS Identity and Access Management
AWS Identity and Access Management
AWS Identity and Access Management
© 2022, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
Gathering Agenda
• 09:00 - 09:30 Gathering
• 09:30 - 10:20 Introduction to IAM
• 10:20 - 10:30 Short Break
• 10:30 - 11:20 AWS Least privileges journey
• 11:20 - 11:45 Break
• 11:45 - 12:35 Strategies for achieving least privileges
• 12:35 - 13:25 Optional: Meet the expert Q&A
Nino Gotsiridze
Technical Account Manager
AWS
© 2022, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
Agenda
• Identity basics
• AWS Organizations
• IAM Policies
• IAM Tools
Governance
Access Mgmt.
Resource Mgmt.
Governance
Access Mgmt.
Resource Mgmt.
© 2023, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
First understand an AWS account
AWS Cloud
Each AWS account is
• a resource container for AWS Cloud services Account A
• an explicit security boundary
Compute
• a container for cost tracking and billing
• a mechanism to enforce limits and thresholds
• e.g. Service Quotas and API thresholds Networking
& content
delivery
+ users, groups, roles, policies
Storage
Over time, customers will add more accounts to
support more applications and services and much more…
© 2023, Amazon Web Services, Inc. or its affiliates.
AWS Organizations
Central governance and management across AWS accounts
for a comprehensive multi-account AWS environment
Manage and define Control access and Audit, monitor, and Share resources Centrally manage
your organisation permission secure your across accounts costs and billing
and accounts environment for
compliance
https://aws.amazon.com/organizations/getting-started/best-practices/
Prod Dev
https://aws.amazon.com/blogs/aws/new-attributes-based-access-control-with-aws-single-sign-on/
1 2 3 4 5
© 2023, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
AWS Access Management
Policy Categories
Guardrails Grants
https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html
https://aws-samples.github.io/aws-iam-permissions-guardrails/guardrails/scp-guardrails.html
Guardrails Grants
Identity-based policies
Resource-based policies
Object ACLs
Guardrails Grants
Session-based policies
© 2023, Amazon Web Services, Inc. or its affiliates. SCP – Service Control Policy
ACL – Access Control List
Keep in mind, least privilege
The right access
To do their job
1 2 3 4 5
Tags can be attached to IAM principals (users or roles) and to AWS resources
© 2023, Amazon Web Services, Inc. or its affiliates.
Resulting in AWS providing fine-grained
access controls
Control access based on For example, allow developers to
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html
Sid
Effect
Principal
Action
Resource
Condition Block
© 2023, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
AWS IAM Tools – Policy generator
3
© 2023, Amazon Web Services, Inc. or its affiliates.
AWS IAM Tools – Policy simulator
1 2 3
https://policysim.aws.amazon.com/
https://docs.aws.amazon.com/IAM/latest/UserGuide/what-is-access-analyzer.html
https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html
© 2023, Amazon Web Services, Inc. or its affiliates.
AWS IAM Tools – Access Analyzer
2 3
• https://aws-samples.github.io/aws-iam-permissions-guardrails/guardrails/scp-guardrails.html
• https://aws.amazon.com/blogs/aws/new-attributes-based-access-control-with-aws-single-sign-on/
• https://aws.amazon.com/organizations/getting-started/best-practices/
• https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html
• https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html
• https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic-cross-account.html
• https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html
• http://awspolicygen.s3.amazonaws.com/policygen.html / https://policysim.aws.amazon.com/
• https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_access-advisor-view-data.html
• https://docs.aws.amazon.com/IAM/latest/UserGuide/what-is-access-analyzer.html
• https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html
Visit aws.training/Security
© 2023, Amazon Web Services, Inc. or its affiliates.
Go build
https://wellarchitectedlabs.com/security/
© 2022, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
AWS EXPERIENCE TEL AVIV - SECURITY TRACK
Yazan Khalaf
Solutions Architect
AWS
© 2023, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
Who can access what
https://docs.aws.amazon.com/organizations/latest/userguide/orgs_integrate_services_list.html
Permissions in AWS
Goals
Resource policies
IAM roles Amazon Simple AWS Lambda AWS Key Amazon Simple
(trust policies) Storage Service functions Management Service Queue Service
(Amazon S3) (AWS KMS) keys (Amazon SQS) queues
buckets © 2023, Amazon Web Services, Inc. or its affiliates.
Specify: Tools to restrict access
• AWS Organizations service control policies (SCPs)
§ Permissions guardrails to restrict access for principals
across accounts in your organization
• IAM permissions boundaries
§ Developers can manage permissions and control
the maximum permissions they grant
• Amazon VPC endpoint policies
§ Require that traffic stays within your VPC
Permissions boundaries
Scoped-down policies
Developers can manage roles safely
Resource-based policies
CalledViaFirst :
cloudformation.amazonaws.com
Denied
Data perimeter
Grant access to these actions, but only if these conditions are met
"Effect": "Allow",
"Action": [
"ec2:StartInstances",
"ec2:StopInstances"],
"Resource": "*",
"Condition": {
"StringEquals": {"ec2:ResourceTag/project": ”CloudMigration"}
}
Specify the type of operator Use predefined keys to look The value you define
used to compare the value up the value in the context that is based on your
from the context to the for policy comparison; you permissions requirements
value in the policy can use global condition keys
or service-specific keys
true
StringEquals PrincipalIsAWSService CloudMigration
StringLike ResourceTag/project ${PrincipalTag/project}
AND
"Condition":{
"StringEquals":{
"aws:PrincipalServiceName":"access-analyzer.amazonaws.com"
OR
}
}
All conditions met together },
{
"Sid":“RoleCreate-CFN",
Same statement "Effect":"Allow",
"Action":"iam:CreateRole",
"Resource":"*",
OR "Condition":{
"StringEquals":{
"iam:PermissionsBoundary":"arn:aws:iam::111122223333:
policy/business-plan-modify",
Any part of conditions met AND }
"aws:CalledViaFirst":"cloudformation.amazonaws.com",
"aws:RequestTag/project":[”CloudMigration", ”IPO"]
}
Separate statements }
]
}
ForAnyValues: Is the context an intersection of the policy? If there is at least one match, the condition applies
aws:TagKeys project
ForAllValues:StringEquals "aws:TagKeys": Not subset
costcenter ["project","name"]
name
"aws:TagKeys":
aws:TagKeys ForAnyValues:StringEquals Not intersection
["project","name"]
© 2023, Amazon Web Services, Inc. or its affiliates.
Conditions: Noteworthy condition keys
Allow actions, but only if these
aws:ResourceTag Attribute-based access control
tags exist
Deny actions for all principals except Use in SCPs to deny with exceptions
PrincipalArn
this ARN
PrincipalIsAWSService Restrict access to corporate IP and Use in SCPs when restricting SourceIP
AWS services © 2023, Amazon Web Services, Inc. or its affiliates.
Using Conditions with Denies
Deny access if the call is made outside of my network (a
Deny access to principals if they are outside of
list of IPs and VPCs) and the API call is not made by an
my organization (PrincipalOrgID) and if they are
AWS service principal (PrincipalIsAWSService) or by an
not an AWS service (PrincipalIsAWSService).
AWS service using the caller’s identity (ViaAWSService).
If the principal is from my organization or the {
principal is an AWS service (such as AWS "Sid":"EnforceNetworkPerimeter",
"Effect":"Deny",
CloudTrail or AWS Billing and Cost Management), "Principal":"*",
"Action":"s3:*",
do not deny. "Resource":[
{ "arn:aws:s3:::your-bucket-name",
"Sid":"EnforceIdentityPerimeter", "arn:aws:s3:::your-bucket-name/*"
"Effect":"Deny", ],
"Principal":"*", "Condition":{
"Action":"s3:*", "StringNotEqualsIfExists":{
"Resource":[ "aws:SourceVpc":[
"arn:aws:s3:::your-bucket-name", "vpc-111bbb22",
"arn:aws:s3:::your-bucket-name/*" "vpc-222ccc33"
], ]
"Condition":{ },
"StringNotEqualsIfExists":{ "NotIpAddressIfExists":{
"aws:PrincipalOrgID":"o-n8ecxxxxx" "aws:SourceIp":[
}, "111.222.333.444/25",
"BoolIfExists":{ "555.666.777.888/29"
"aws:PrincipalIsAWSService":"false" ]
} },
} "BoolIfExists":{
} "aws:PrincipalIsAWSService":"false",
© 2023, Amazon Web Services, Inc. or its affiliates.
"aws:ViaAWSService":"false"
}}}
Set: Policy validation with
IAM Access Analyzer
Makes it easier to author secure and functional policies with more than 100 checks
General warnings
Security
A policy doesn’t conform to best
A policy contains access that
practices, but the issues are not
can be overly permissive
security risks
IAM
Access
Analyzer
Errors Suggestions
A policy contains errors A policy contains statements to
that prevent the policy be improved but doesn’t impact
from functioning the permissions of the policy
We are always adding new checks! Let us know if you have an idea
© 2023, Amazon Web Services, Inc. or its affiliates.
Verifying permissions
AWS account
Role last used and Service and action Service last accessed
access key last used last accessed for SCPs
Task 2
Implement a guardrail so that no one outside your organization can access data in a bucket
Task 4
Allow the creation of infrastructure, but only when using CloudFormation
© 2023, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
Strategies for achieving least
privilege
Yazan Khalaf
Solutions Architect
AWS
© 2022, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
The goal
d o w a nt
in gs y ou
Th ss to i n n ovate
Busine o v e q uickly
t to m
d o n ’ t wan Agility fo r b u i ld ers
in gs y ou Freedom
Th ge r o u s a ctions
Dan b le teams
u n ta
Unacco r e so u rces
v e
Expensi
Mental
model
Set
permissions Journey
=
Least
privilege
Feedback
loops
Refine Verify
permissions access
© 2022,
2023, Amazon Web Services, Inc. or its affiliates.
3P strategies
§ Additional guardrails
§ AWS KMS encryption Principals Resources Principals Resources
§ Conditions, tags
© 2023, Amazon Web Services, Inc. or its affiliates.
#1 (Plan): Begin with coarse-grained controls
Multi-account strategy
Identity PrincipalOrgID
Service control policies
Resource
ResourceOrgID
Resource-based policies
Network SourceIp
SourceVpc
VPC endpoint policies
SourceVpce
Set data perimeters’
definition based on
control objectives
Data perimeters
Project ABC Project PQR Test account Finance team Audit team Biz dev team
Production accounts
© 2023, Amazon Web Services, Inc. or its affiliates.
#2 (Plan): Use accounts as strong boundaries around
resources
Create analyzer
Review active findings
Archive intended access
Remove unintended access
Short-term Long-term
credentials credentials
Benefits
§ Temporary (minutes to hours)
§ You don’t have to rotate them or explicitly revoke them
§ You don’t have to embed within an application
IAM roles
Direct IAM federation IAM Identity IAM roles for IAM roles and
or Center + AWS CLI Amazon EC2, external ID
IAM Identity AWS Lambda, etc.
Center federation
© 2023, Amazon Web Services, Inc. or its affiliates.
#3 (Plan): Prioritize short-term credentials
Protecting secrets
AWS Cloud
AWS Secrets Manager
Amazon Automatic
DocumentDB rotation
AWS Lambda
AWS Organizations
Organizational unit
Service control policies
AWS Organizations
{
“Effect”: ”Deny”,
“Action”: “s3:PutAccountPublicAccessBlock”,
“Resource”: ”*”,
“Condition”: {
“ArnNotLikeIfExists”: {
“aws:PrincipalArn”: "arn:aws:iam::*:role/admin"
}
}
}
Restricting access
VPC endpoint
Block public access
policies
Resource policies
Can
Who What?
access
{ {
“Effect”: ”Allow”, “Effect”: ”Allow”,
“Action”: “ ”, “Principal”: “ ”,
“Resource”: ” ”, “Action”: “ ”,
“Condition”: ”” “Resource”: ” ”,
} “Condition”: ””
}
© 2023, Amazon Web Services, Inc. or its affiliates.
#5 (Policy): Identify the right tool for the job
I need to create a
role and policy for
my Lambda I’ll write it for you!
function
Developer Admin
Knows the Knows a lot about
application’s intent identity and security
© 2023, Amazon Web Services, Inc. or its affiliates.
#6 (Policy): Empower developers to author application
policies
al
Ment l Bottlenecks
mode
Developer
Developer
Developer
Problem
How can developers safely
create new permissions?
App3
Low variety
Account Account
High variety
al
Ment l Feedback loops
mode
Feedback
Eyeballs Automation
Source code step CloudFormation Policy check step Other Deploy step
lint step Check IAM test
Application code CloudFormation policies using steps Deploy the
IaC verification template
AWS including IAM policies
policy
checks
CloudFormation validation
template
Peer
review
AWS Security Blog
Validate IAM policies in CloudFormation
templates using IAM Access Analyzer
© 2023, Amazon Web Services, Inc. or its affiliates.
Strategies for least privilege
1 2 3 4
Description URL
Serverless microframework + automatic
AWS Chalice IAM policy generation
https://github.com/aws/chalice
© 2022,
2023, Amazon Web Services, Inc. or its affiliates. 160
Thank you!
Yazan Khalaf
Solutions Architect
AWS
© 2022, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.