-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
58 lines (48 loc) · 2.07 KB
/
iam.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
data "aws_iam_policy_document" "aws_backup_service_assume_role_policy" {
statement {
sid = "AssumeServiceRole"
actions = ["sts:AssumeRole"]
effect = "Allow"
principals {
type = "Service"
identifiers = ["backup.amazonaws.com"]
}
}
}
data "aws_iam_policy" "aws_backup_service_policy" {
arn = "arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup"
}
data "aws_iam_policy" "aws_restore_service_policy" {
arn = "arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForRestores"
}
data "aws_iam_policy" "aws_backup_s3_service_policy" {
arn = "arn:aws:iam::aws:policy/AWSBackupServiceRolePolicyForS3Backup"
}
data "aws_iam_policy" "aws_restore_s3_service_policy" {
arn = "arn:aws:iam::aws:policy/AWSBackupServiceRolePolicyForS3Restore"
}
resource "aws_iam_role" "aws_backup_service_role" {
name = "backup-role"
description = "Allows AWS Backup to access AWS resources on your behalf based on the permissions you define."
assume_role_policy = data.aws_iam_policy_document.aws_backup_service_assume_role_policy.json
}
resource "aws_iam_role_policy" "backup_service_aws_backup_role_policy" {
name = "AWSBackupServiceRolePolicyForBackup"
policy = data.aws_iam_policy.aws_backup_service_policy.policy
role = aws_iam_role.aws_backup_service_role.name
}
resource "aws_iam_role_policy" "restore_service_aws_backup_role_policy" {
name = "AWSBackupServiceRolePolicyForRestores"
policy = data.aws_iam_policy.aws_restore_service_policy.policy
role = aws_iam_role.aws_backup_service_role.name
}
resource "aws_iam_role_policy" "backup_service_aws_backup_s3_role_policy" {
name = "AWSBackupServiceRolePolicyForS3Backup"
policy = data.aws_iam_policy.aws_backup_s3_service_policy.policy
role = aws_iam_role.aws_backup_service_role.name
}
resource "aws_iam_role_policy" "restore_service_aws_restore_s3_role_policy" {
name = "AWSBackupServiceRolePolicyForS3Restore"
policy = data.aws_iam_policy.aws_restore_s3_service_policy.policy
role = aws_iam_role.aws_backup_service_role.name
}