S3 Policies.¶
Permiso de Lectura por usuario IAM.¶
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadOnlyUser",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::xxxxxxxxxxxx:user/Miguelito"
},
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::mi-bucket-unico/*"
}
]
}
Las xxxxxxxx del arn del usuario hacen referencia a su ID en AWS.
Permiso de lectura y escritura por rol/grupo IAM.¶
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadWriteForRole",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:role/DesarrolloWeb"
},
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::mi-bucket-unico/*"
}
]
}
El permiso de PutObject es un permiso de escritura.
Denegar todo el acceso excepto a ciertas direcciones IP.¶
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowOnlyFromOffice",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::mi-bucket-unico", "arn:aws:s3:::mi-bucket-unico/*"],
"Condition": {
"NotIpAddress": {"aws:SourceIp": "203.0.113.0/24"}
}
}
]
}
Las acciones son los tipos de permisos (ejecución, lectura, escritura, etc). Por tant s3:* representa todos los tipos de permisos.
Denegar acceso durante ciertas horas.¶
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowDuringWorkHours",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::mi-bucket-unico/*",
"Condition": {
"DateNotEquals": {
"aws:CurrentTime": [
"2025-11-08T08:00:00Z",
"2025-11-08T18:00:00Z"
]
}
}
}
]
}
Permitir acceso solo a los objetos con la etiqueta "public".¶
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowIfTaggedAsPublic",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::mi-bucket-unico/*",
"Condition": {"StringEquals": {"s3:ExistingObjectTag/Access": "public"}}
}
]
}
Es habitual poner etiquetas en los recursos para luego poder aplicarles políticas a dichos objetos.
Permitir acceso solo a aquellas máquinas que vengan de cierta red (VPC).¶
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AccessFromVPCEndpoint",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::mi-bucket-unico", "arn:aws:s3:::mi-bucket-unico/*"],
"Condition": {
"StringEquals": {"aws:SourceVpce": "vpce-1a2b3c4d"}
}
}
]
}
Una VPC es una red virtual en AWS.