Users should be named with the suffix "-restic", e.g. "host1-restic"
Last active
May 3, 2025 07:09
-
-
Save dlitz/c630c3720a243316e18e5155e691c54d to your computer and use it in GitHub Desktop.
example IAM policy for restic user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "AllowLegacyCrypto0", | |
"Effect": "Allow", | |
"Action": [ | |
"kms:Decrypt" | |
], | |
"Resource": [ | |
"arn:aws:kms:us-west-2:123456789012:key/ff316242-592d-4c73-9c86-e3f7f606c803" | |
], | |
"Condition": { | |
"StringLike": { | |
"kms:ViaService": [ | |
"s3.*.amazonaws.com" | |
] | |
} | |
} | |
}, | |
{ | |
"Sid": "AllowCrypto0", | |
"Effect": "Allow", | |
"Action": [ | |
"kms:Decrypt", | |
"kms:Encrypt", | |
"kms:GenerateDataKey" | |
], | |
"Resource": [ | |
"arn:aws:kms:us-west-2:123456789012:key/mrk-123456789abcdef123456789abcdef12" | |
], | |
"Condition": { | |
"StringLike": { | |
"kms:ViaService": [ | |
"s3.*.amazonaws.com" | |
] | |
} | |
} | |
}, | |
{ | |
"Sid": "AllowWriting", | |
"Effect": "Allow", | |
"Action": [ | |
"s3:PutObject", | |
"s3:GetObject", | |
"s3:DeleteObject" | |
], | |
"Resource": [ | |
"arn:aws:s3:::example-restic/*" | |
] | |
}, | |
{ | |
"Sid": "AllowWrite0", | |
"Effect": "Allow", | |
"Action": [ | |
"s3:ListBucket", | |
"s3:GetBucketLocation" | |
], | |
"Resource": [ | |
"arn:aws:s3:::example-restic" | |
] | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "AllowLegacyCrypto0", | |
"Effect": "Allow", | |
"Action": [ | |
"kms:Decrypt" | |
], | |
"Resource": [ | |
"arn:aws:kms:us-west-2:123456789012:key/ff316242-592d-4c73-9c86-e3f7f606c803" | |
], | |
"Condition": { | |
"StringLike": { | |
"kms:ViaService": [ | |
"s3.*.amazonaws.com" | |
] | |
} | |
} | |
}, | |
{ | |
"Sid": "AllowCrypto0", | |
"Effect": "Allow", | |
"Action": [ | |
"kms:Decrypt", | |
"kms:Encrypt", | |
"kms:GenerateDataKey" | |
], | |
"Resource": [ | |
"arn:aws:kms:us-west-2:123456789012:key/mrk-123456789abcdef123456789abcdef12" | |
], | |
"Condition": { | |
"StringLike": { | |
"kms:ViaService": [ | |
"s3.*.amazonaws.com" | |
] | |
} | |
} | |
}, | |
{ | |
"Sid": "AllowWriting", | |
"Effect": "Allow", | |
"Action": [ | |
"s3:PutObject", | |
"s3:GetObject", | |
"s3:DeleteObject" | |
], | |
"Resource": [ | |
"arn:aws:s3:::example-restic/${aws:username}/*" | |
] | |
}, | |
{ | |
"Sid": "AllowWrite0", | |
"Effect": "Allow", | |
"Action": [ | |
"s3:ListBucket", | |
"s3:GetBucketLocation" | |
], | |
"Resource": [ | |
"arn:aws:s3:::example-restic" | |
] | |
}, | |
{ | |
"Sid": "RestrictToOwnObjects", | |
"Effect": "Deny", | |
"Action": "s3:ListBucket", | |
"Resource": [ | |
"arn:aws:s3:::example-restic", | |
"arn:aws:s3:::example-restic-replica-ca-central-1" | |
], | |
"Condition": { | |
"StringNotLike": { | |
"s3:prefix": [ | |
"", | |
"${aws:username}/*" | |
] | |
}, | |
"Null": { | |
"s3:prefix": "false" | |
} | |
} | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "IndexAndKeyManagement", | |
"Effect": "Allow", | |
"Action": [ | |
"s3:PutObject", | |
"s3:DeleteObject" | |
], | |
"Resource": [ | |
"arn:aws:s3:::example-restic/*-restic/keys/*", | |
"arn:aws:s3:::example-restic/*-restic/index/*" | |
] | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "AllowLockObjects", | |
"Effect": "Allow", | |
"Action": [ | |
"s3:PutObject", | |
"s3:DeleteObject" | |
], | |
"Resource": [ | |
"arn:aws:s3:::example-restic/*-restic/locks/*", | |
"arn:aws:s3:::example-restic-replica-ca-central-1/*-restic/locks/*" | |
] | |
}, | |
{ | |
"Sid": "AllowLockCrypto", | |
"Effect": "Allow", | |
"Action": [ | |
"kms:GenerateDataKey", | |
"kms:Encrypt" | |
], | |
"Resource": [ | |
"arn:aws:kms:*:123456789012:key/mrk-123456789abcdef123456789abcdef12" | |
], | |
"Condition": { | |
"StringLike": { | |
"kms:ViaService": [ | |
"s3.*.amazonaws.com" | |
] | |
} | |
} | |
}, | |
{ | |
"Sid": "AllowReading", | |
"Effect": "Allow", | |
"Action": "s3:GetObject", | |
"Resource": [ | |
"arn:aws:s3:::example-restic/*", | |
"arn:aws:s3:::example-restic-replica-ca-central-1/*" | |
] | |
}, | |
{ | |
"Sid": "AllowListBucket", | |
"Effect": "Allow", | |
"Action": [ | |
"s3:ListBucket", | |
"s3:GetBucketLocation" | |
], | |
"Resource": [ | |
"arn:aws:s3:::example-restic", | |
"arn:aws:s3:::example-restic-replica-ca-central-1" | |
] | |
}, | |
{ | |
"Sid": "AllowDecrypting", | |
"Effect": "Allow", | |
"Action": "kms:Decrypt", | |
"Resource": [ | |
"arn:aws:kms:us-west-2:123456789012:key/ff316242-592d-4c73-9c86-e3f7f606c803", | |
"arn:aws:kms:*:123456789012:key/mrk-123456789abcdef123456789abcdef12" | |
], | |
"Condition": { | |
"StringLike": { | |
"kms:ViaService": [ | |
"s3.*.amazonaws.com" | |
] | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment