|
| 1 | +import * as iam from "../iam"; |
| 2 | + |
| 3 | +export default { |
| 4 | + description: "Allows Elastio to scan AWS Backup recovery points.", |
| 5 | + |
| 6 | + statements: [ |
| 7 | + { |
| 8 | + Sid: "ReadBackupInventory", |
| 9 | + Action: [ |
| 10 | + // Vaults |
| 11 | + "backup:ListBackupVaults", |
| 12 | + "backup:DescribeBackupVault", |
| 13 | + |
| 14 | + // Recovery points |
| 15 | + "backup:ListRecoveryPointsByResource", |
| 16 | + "backup:DescribeRecoveryPoint", |
| 17 | + "backup:ListRecoveryPointsByBackupVault", |
| 18 | + "backup:GetRecoveryPointRestoreMetadata", |
| 19 | + |
| 20 | + // Common for all resources |
| 21 | + "backup:ListTags", |
| 22 | + |
| 23 | + // Misc. |
| 24 | + "backup:ListProtectedResources", |
| 25 | + "backup:ListProtectedResourcesByBackupVault", |
| 26 | + ], |
| 27 | + Resource: "*", |
| 28 | + }, |
| 29 | + |
| 30 | + { |
| 31 | + Sid: "ReadEbsInventory", |
| 32 | + Action: [ |
| 33 | + // Volumes |
| 34 | + "ec2:DescribeVolumeStatus", |
| 35 | + "ec2:DescribeVolumes", |
| 36 | + |
| 37 | + // Snapshots |
| 38 | + "ec2:DescribeSnapshots", |
| 39 | + "ec2:DescribeSnapshotAttribute", |
| 40 | + |
| 41 | + // Common for all resources |
| 42 | + "ec2:DescribeTags", |
| 43 | + |
| 44 | + // Used for cost estimation |
| 45 | + "ebs:ListSnapshotBlocks", |
| 46 | + "ebs:ListChangedBlocks", |
| 47 | + ], |
| 48 | + Resource: "*", |
| 49 | + }, |
| 50 | + |
| 51 | + { |
| 52 | + Sid: "ReadEbsSnapshotsData", |
| 53 | + Action: ["ebs:GetSnapshotBlock"], |
| 54 | + Resource: "*", |
| 55 | + }, |
| 56 | + |
| 57 | + { |
| 58 | + Sid: "ReadEc2Inventory", |
| 59 | + Action: [ |
| 60 | + "ec2:DescribeInstances", |
| 61 | + "ec2:DescribeImages", |
| 62 | + "ec2:DescribeHosts", |
| 63 | + "ssm:DescribeInstanceInformation", |
| 64 | + ], |
| 65 | + Resource: "*", |
| 66 | + }, |
| 67 | + |
| 68 | + { |
| 69 | + Sid: "ShareEbsSnapshot", |
| 70 | + Action: ["ec2:ModifySnapshotAttribute"], |
| 71 | + Resource: "*", |
| 72 | + Condition: { |
| 73 | + // Needed to add createVolumePermission for the sharing the snapshot |
| 74 | + // with the connector account. |
| 75 | + StringLike: { |
| 76 | + "ec2:Add/userId": "*", |
| 77 | + }, |
| 78 | + }, |
| 79 | + }, |
| 80 | + |
| 81 | + { |
| 82 | + Sid: "KmsAccess", |
| 83 | + |
| 84 | + // Users need to put a special tag on their KMS keys to allow Elastio |
| 85 | + // use them for decrypting their data. It must be documented in public |
| 86 | + // Elastio documentation. |
| 87 | + Condition: iam.hasResourceTag("elastio:authorize"), |
| 88 | + |
| 89 | + Action: [ |
| 90 | + // These actions are needed to reencrypt the volumes that were encrypted |
| 91 | + // by the KMS key. |
| 92 | + "kms:ReEncryptFrom", |
| 93 | + "kms:ReEncryptTo", |
| 94 | + "kms:CreateGrant", |
| 95 | + "kms:Encrypt", |
| 96 | + |
| 97 | + // Needed only for some cases. For example, when we want to snapshot an EBS |
| 98 | + // volume that was created from a snapshot of the root volume of an EC2 instance. |
| 99 | + // These calls are made by the ebs.amazonaws.com and not by our code. |
| 100 | + "kms:DescribeKey", |
| 101 | + |
| 102 | + // GenerateDataKeyWithoutPlaintext in particular is required in case when |
| 103 | + // we create a volume from an unencrypted snapshot but there is a default |
| 104 | + // KMS encryption key set in EBS for the volume. |
| 105 | + "kms:GenerateDataKey", |
| 106 | + "kms:GenerateDataKeyWithoutPlaintext", |
| 107 | + |
| 108 | + // This is required when reading S3 buckets encrypted with a KMS key |
| 109 | + "kms:Decrypt", |
| 110 | + ], |
| 111 | + Resource: "*", |
| 112 | + }, |
| 113 | + ], |
| 114 | +} satisfies iam.Policy; |
0 commit comments