๐จPolicy Deep Dive
IAM Policy Structure
In a JSON (Javascript Object Notation), it has de following structure:
The Effect: Can be "ALLOW" or "DENY"
The Action: Los API calls que queremos permitir o denegar segun coloquemos en el "Effect".
The Resource: Se coloca el ARN del recurso.
The Condition: Es un elemento opcional, que puede definir cuando o no entra la politica en efecto.
{
"Version": "2012-10-17",
"Statement":
[
{
"Effect":"Allow",
"Action":[
"s3:PutObject",
"s3:PutObjectAcl",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:DeleteObject"
],
"Resource":"arn:aws:s3:::holidaygifts/*"
},
{
"Effect": "Deny",
"Action": [
"s3:GetObject",
"s3:GetObjectAcl"
],
"Resource":"arn:aws:s3:::holidaygifts/*",
"Condition": {
"DateGreaterThan": {"aws:CurrentTime": "2022-12-01T00:00:00Z"},
"DateLessThan": {"aws:CurrentTime": "2022-12-25T06:00:00Z"}
}
}
]
}En aa politica del ejemplo podemos notar lo siguiente:
Se permite las operaciones read and write hasta antes del 1 de diciembre y hasta despues del 25 de diciembre.
Se solapan dos operaciones de read, en donde en el periodo arriba mencionado, toma prioridad el deny, siempre que haya solapamiento el deny tomara prioridad sobre los allow.
Siempre considerar o interpretar las politicas como DENY -> ALLOW -> DENY.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyNonApprovedRegions",
"Effect": "Deny",
"NotAction": [
"cloudfront:*",
"iam:*",
"route53:*",
"support:*"
],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:RequestedRegion": [
"ap-southeast-2",
"eu-west-1"
]
}
}
}
]
}En la politica arriba vemos lo siguiente:
The statement Not Action indica que en este caso se va a denegar todo lo que no incluya en esta caso cloudfront, iam, route53 y support.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::cl-animals4life",
"Condition": {
"StringLike": {
"s3:prefix": [
"",
"home/",
"home/${aws:username}/*"
]
}
}
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::cl-animals4life/home/${aws:username}",
"arn:aws:s3:::cl-animals4life/home/${aws:username}/*"
]
}
]
}
AWS Policy Evaluation Logic.

Last updated