2

I am trying to create a backup plan, rule and vault using AWS CDK. After deploying the application I receive the following error in cloudformation console.

Resource handler returned message: "Insufficient privileges to perform this action. (Service: Backup, Status Code: 403, Request ID: xxxxxxx)" (RequestToken: xxxxxxxxx, HandlerErrorCode: GeneralServiceException)

My CDK bootstrap role definitely have access to backup. See policy document below.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "cdk",
      "Effect": "Allow",
      "Action": [
        "lambda:*",
        "logs:*",
        "serverlessrepo:*",
        "servicediscovery:*",
        "ssm:*",
        "cloudformation:*",
        "kms:*",
        "iam:*",
        "sns:*",
        "dynamodb:*",
        "codepipeline:*",
        "cloudwatch:*",
        "events:*",
        "acm:*",
        "sqs:*",
        "backup:*"
      ],
      "Resource": "*"
    }
  ]
}

Following are my CDK code snippets:

backup-rule

ruleName: 'myTestRuleName',
completionWindow: Duration.hours(1),
startWindow: Duration.hours(1),
scheduleExpression: events.Schedule.cron({
    day: '*',
    hour: '2'
}),
deleteAfter: Duration.days(90),
      

backup-vault I tried without encryptionKey and also with a key that I have created through AWS backup web interface. None worked

new backup.BackupVault(this, `${id}-instance`, {
    backupVaultName: props.backupVaultName,
    // encryptionKey: this.key
})

backup-plan

new BackupPlan(scope, `${id}-instance`, {
      backupPlanName: context.backupPlanName,
      backupPlanRules: context.backupPlanRules,
      // backupVault: context.backupVault
 });

backup selection I also tried without creating the role and letting AWS CDK create and use the default role. NOTE: I have also tried created plan, rule and vault without resource selection to make sure, that the problem does not occur on the resource selection side.

const role = new iam.Role(this, 'Backup Access Role', { assumedBy: new iam.ServicePrincipal('backup.amazonaws.com') });
const managedPolicy = iam.ManagedPolicy.fromManagedPolicyArn(this, 'AWSBackupServiceRolePolicyForBackup', 'arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup');
role.addManagedPolicy(managedPolicy);
plan.backupPlan.addSelection('selection',
      {
        resources: [
          BackupResource.fromDynamoDbTable(MyTable)
        ],
        //role: role
      }
)
``

1 Answers1

0

I faced this problem too and adding permissions for backup-storage solved it for me! Referenced the AWSBackupFullAccess permissions

enter image description here

hmin
  • 129
  • 1
  • 3