https://login.veeam.com/en/oauth?client_id=nXojRrypJ8&redirect_uri=https%3A%2F%2Fwww.veeam.com%2Fservices%2Fauthentication%2Fredirect_url&response_type=code&scope=profile&state=eyJmaW5hbFJlZGlyZWN0TG9jYXRpb24iOiJodHRwczovL3d3dy52ZWVhbS5jb20va2IzMDM0IiwiaGFzaCI6ImYwYjhlMjc4LTQyMDYtNDNiZC05YWVmLTRkNDA4N2Y0Mjg3ZCJ9
1-800-691-1991 | 9am - 8pm ET
EN

How to Create Custom IAM Role to Perform Restore of EC2 Instance

Challenge

Restore of an EC2 Instance in Veeam Backup for AWS requires certain privileges:
  • Create EBS Volume
  • Attach EBS volume to EC2 Instance
  • Start EC2 Instance 
  • and so on - see permissions below
To perform Instance Restore, the proper security access must be provided to the Veeam Backup for AWS server:
  • Specify an IAM role which Veeam Backup for AWS server can switch to for restore operations.
  • Provide access keys from an IAM User.

Solution

There are two types of deployments where IAM role is required to perform a restore:
  • Backup inside production
  • Isolated from production backup
The isolated from production deployment type provides exceptional level of protection in cases when the whole production environment is lost. This type of deployment is recommended as the most secure one.
Depending on the deployment type, IAM Roles must be created in different accounts.
 

Isolated from production backup deployment


In this type of deployment the Veeam Backup for AWS server is running in dedicated Backup Account. The IAM Restore Role must be created in the Production Account.

1. Use the following JSON to create an IAM Policy using the following instructions from the How to create IAM Policy article. These permissions will allow Veeam Backup for AWS service to perform operations required for restore: 
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "ec2:AttachVolume",
                "ec2:CopySnapshot",
                "ec2:CreateKeyPair",
                "ec2:CreateTags",
                "ec2:CreateVolume",
                "ec2:DeleteKeyPair",
                "ec2:DeleteSnapshot",
                "ec2:DeleteTags",
                "ec2:DeleteVolume",
                "ec2:DeregisterImage",
                "ec2:DescribeAccountAttributes",
                "ec2:DescribeAvailabilityZones",
                "ec2:DescribeImages",
                "ec2:DescribeInstanceAttribute",
                "ec2:DescribeInstances",
                "ec2:DescribeInstanceStatus",
                "ec2:DescribeKeyPairs",
                "ec2:DescribeRegions",
                "ec2:DescribeSecurityGroups",
                "ec2:DescribeSnapshots",
                "ec2:DescribeSubnets",
                "ec2:DescribeRouteTables",
                "ec2:DescribeVolumes",
                "ec2:DescribeVpcEndpoints",
                "ec2:DescribeVpcs",
                "ec2:DescribeTags",
                "ec2:DetachVolume",
                "ec2:ImportImage",
                "ec2:ModifyInstanceAttribute",
                "ec2:ModifySnapshotAttribute",
                "ec2:RunInstances",
                "ec2:StartInstances",
                "ec2:StopInstances",
                "ec2:TerminateInstances",
		"ec2:GetEbsDefaultKmsKeyId",
                "events:DeleteRule",
                "events:DescribeRule",
                "events:ListTargetsByRule",
                "events:PutRule",
                "events:PutTargets",
                "events:RemoveTargets",
                "iam:AddRoleToInstanceProfile",
                "iam:AttachRolePolicy",
                "iam:CreateInstanceProfile",
                "iam:DeleteInstanceProfile",
                "iam:DeleteRolePolicy",
                "iam:DetachRolePolicy",
                "iam:GetInstanceProfile",
                "iam:GetRole",
                "iam:ListAttachedRolePolicies",
                "iam:ListInstanceProfilesForRole",
                "iam:ListRolePolicies",
                "iam:PassRole",
                "iam:PutRolePolicy",
                "iam:RemoveRoleFromInstanceProfile",
                "kms:DescribeKey",
                "kms:ListAliases",
                "kms:ListKeys",
		"kms:CreateGrant",
		"kms:GetKeyPolicy",
		"kms:ReEncryptFrom",
		"kms:ReEncryptTo",
                "s3:GetBucketLocation",
                "servicequotas:ListServiceQuotas"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}
2. Navigate to Roles.
3. Choose Create role.
4. Select the type of the trusted entity Another AWS Account.
5. In the Account ID field, enter the ID of your Backup Account (you can get this number in the AWS console of the Backup Account, in My Account located in the top-right menu).
6. Select the Require external ID checkbox and enter a pass phrase to raise the level of security for the role.
7. Click Next: Permissions.
8. In the filter policies search box, enter the name of the policy created in the Step 1.
9. In the first column, select the policy.
10. Click Next: Tags.
11. Enter tagging info if needed and click Next: Review.
12. Assign a name to the IAM Role. This name will be used in Veeam Backup for AWS (e.g. vb4aws_restore_role).
13. Click Create role.
14. Once the role is created, you will be able to see it in the list of available roles.
 

Backup inside Production deployment


NOTE: This type of deployment (since it is not very secure) is recommended for test, demo and small environments only!

1. Use the following JSON to create an IAM Policy using the following instructions from the How to create IAM Policy article. These permissions will allow Veeam Backup for AWS service to perform operations required for restore: 
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "ec2:AttachVolume",
                "ec2:CopySnapshot",
                "ec2:CreateKeyPair",
                "ec2:CreateTags",
                "ec2:CreateVolume",
                "ec2:DeleteKeyPair",
                "ec2:DeleteSnapshot",
                "ec2:DeleteTags",
                "ec2:DeleteVolume",
                "ec2:DeregisterImage",
                "ec2:DescribeAccountAttributes",
                "ec2:DescribeAvailabilityZones",
                "ec2:DescribeImages",
                "ec2:DescribeInstanceAttribute",
                "ec2:DescribeInstances",
                "ec2:DescribeInstanceStatus",
                "ec2:DescribeKeyPairs",
                "ec2:DescribeRegions",
                "ec2:DescribeSecurityGroups",
                "ec2:DescribeSnapshots",
                "ec2:DescribeSubnets",
                "ec2:DescribeRouteTables",
                "ec2:DescribeVolumes",
                "ec2:DescribeVpcEndpoints",
                "ec2:DescribeVpcs",
                "ec2:DescribeTags",
                "ec2:DetachVolume",
                "ec2:ImportImage",
                "ec2:ModifyInstanceAttribute",
                "ec2:ModifySnapshotAttribute",
                "ec2:RunInstances",
                "ec2:StartInstances",
                "ec2:StopInstances",
                "ec2:TerminateInstances",
		"ec2:GetEbsDefaultKmsKeyId",
                "events:DeleteRule",
                "events:DescribeRule",
                "events:ListTargetsByRule",
                "events:PutRule",
                "events:PutTargets",
                "events:RemoveTargets",
                "iam:AddRoleToInstanceProfile",
                "iam:AttachRolePolicy",
                "iam:CreateInstanceProfile",
                "iam:DeleteInstanceProfile",
                "iam:DeleteRolePolicy",
                "iam:DetachRolePolicy",
                "iam:GetInstanceProfile",
                "iam:GetRole",
                "iam:ListAttachedRolePolicies",
                "iam:ListInstanceProfilesForRole",
                "iam:ListRolePolicies",
                "iam:PassRole",
                "iam:PutRolePolicy",
                "iam:RemoveRoleFromInstanceProfile",
                "kms:DescribeKey",
                "kms:ListAliases",
                "kms:ListKeys",
		"kms:CreateGrant",
		"kms:GetKeyPolicy",
		"kms:ReEncryptFrom",
		"kms:ReEncryptTo",
                "s3:GetBucketLocation",
                "servicequotas:ListServiceQuotas"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}
2. Navigate to Roles.
3. Choose Create role.
4. Select the type of the trusted entity AWS Service.
5. Select EC2 in Choose the service that will use this role.
6. Click Next: Permissions.
7. In filter policies edit box, enter the name of the policy specified in the Step 1 
8. In the first column, select the policy.
9. Click Next: Tags.
10. Enter tagging info if needed and click Next: Review.
11. Assign a name to the IAM Role. This name will be used in Veeam Backup for AWS (e.g. vb4aws_restore_role).
12. Click Create role.
13. Once the role is created, you will be able to see it in the list of available roles.
14. To add this role to the Veeam Backup for AWS service, you must update Trust relationships for the created role as described in this article.
 

How to obtain access keys for IAM User to use for Instance Restore operation


If you already have an IAM User account which you would like to use to perform restore operations, go to the section "Acquiring access keys for an IAM User".


Creating an IAM User for performing restore


1. Use the following JSON to create an IAM Policy using the following instructions from the How to create IAM Policy article. These permissions will allow Veeam Backup for AWS service to perform operations required for restore:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "ec2:AttachVolume",
                "ec2:CopySnapshot",
                "ec2:CreateKeyPair",
                "ec2:CreateTags",
                "ec2:CreateVolume",
                "ec2:DeleteKeyPair",
                "ec2:DeleteSnapshot",
                "ec2:DeleteTags",
                "ec2:DeleteVolume",
                "ec2:DeregisterImage",
                "ec2:DescribeAccountAttributes",
                "ec2:DescribeAvailabilityZones",
                "ec2:DescribeImages",
                "ec2:DescribeInstanceAttribute",
                "ec2:DescribeInstances",
                "ec2:DescribeInstanceStatus",
                "ec2:DescribeKeyPairs",
                "ec2:DescribeRegions",
                "ec2:DescribeSecurityGroups",
                "ec2:DescribeSnapshots",
                "ec2:DescribeSubnets",
                "ec2:DescribeRouteTables",
                "ec2:DescribeVolumes",
                "ec2:DescribeVpcEndpoints",
                "ec2:DescribeVpcs",
                "ec2:DescribeTags",
                "ec2:DetachVolume",
                "ec2:ImportImage",
                "ec2:ModifyInstanceAttribute",
                "ec2:ModifySnapshotAttribute",
                "ec2:RunInstances",
                "ec2:StartInstances",
                "ec2:StopInstances",
                "ec2:TerminateInstances",
		"ec2:GetEbsDefaultKmsKeyId",
                "events:DeleteRule",
                "events:DescribeRule",
                "events:ListTargetsByRule",
                "events:PutRule",
                "events:PutTargets",
                "events:RemoveTargets",
                "iam:AddRoleToInstanceProfile",
                "iam:AttachRolePolicy",
                "iam:CreateInstanceProfile",
                "iam:DeleteInstanceProfile",
                "iam:DeleteRolePolicy",
                "iam:DetachRolePolicy",
                "iam:GetInstanceProfile",
                "iam:GetRole",
                "iam:ListAttachedRolePolicies",
                "iam:ListInstanceProfilesForRole",
                "iam:ListRolePolicies",
                "iam:PassRole",
                "iam:PutRolePolicy",
                "iam:RemoveRoleFromInstanceProfile",
                "kms:DescribeKey",
                "kms:ListAliases",
                "kms:ListKeys",
		"kms:CreateGrant",
		"kms:GetKeyPolicy",
		"kms:ReEncryptFrom",
		"kms:ReEncryptTo",
                "s3:GetBucketLocation",
                "servicequotas:ListServiceQuotas",
                "sns:CreateTopic",
                "sns:DeleteTopic",
                "sns:ListSubscriptionsByTopic",
                "sns:ListTopics",
                "sns:SetTopicAttributes",
                "sns:Subscribe",
                "sns:Unsubscribe",
                "ssm:GetCommandInvocation",
                "ssm:SendCommand",
                "sts:AssumeRole",
                "sts:GetCallerIdentity",
                "sts:GetSessionToken",
                "sqs:DeleteMessage",
                "sqs:ListQueues",
                "sqs:ReceiveMessage",
                "sqs:DeleteQueue",
                "sqs:SendMessage",
                "sqs:CreateQueue",
                "sqs:SetQueueAttributes"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}
2. Navigate to Users section of IAM Management.
3. Click Add User.
4. Enter the user name and select Access Type as AWS Management Console access.
5. Select the password for this user and proceed to the next step by clicking Next: Permissions.
6. Select attach existing policies directly.
7. Filter by entering the name of the policy selected on step 1 and select the found item and proceed to next page.
8. Enter tagging info if needed and click Next: Review.
9. Click Create User.
 

Acquiring access keys for an IAM User


1. Navigate to Users section of IAM Management.
2. Click the User name of the IAM User that you want to use for restore operations.
3. Switch to the Security Credentials tab.
4. Click Create Access Key.
5. In the popup window, you will see a pair of access key and security key (hidden under the Show link).
6. Copy and paste access and security keys to the Veeam Backup for AWS server UI, into the Account section of the restore wizard.

It is highly recommended to deactivate access keys right after the restore operation is complete. To do that, click the Make inactive link for the security key created.
KB ID:
3034
Product:
Veeam Backup for AWS
Version:
Any
Published:
2019-12-02
Last Modified:
2020-08-13
Please rate how helpful this article was to you:
5 out of 5 based on 1 ratings
Thank you for helping us improve!
An error occurred during voting. Please try again later.

Couldn't find what you were looking for?

Below you can submit an idea for a new knowledge base article.
Report a typo on this page:

Please select a spelling error or a typo on this page with your mouse and press CTRL + Enter to report this mistake to us. Thank you!

Spelling error in text

Knowledge base content request
By submitting, you agree that your personal data will be managed by Veeam in accordance with the Privacy Policy.

ty icon

Thank you!

We have received your request and our team will reach out to you shortly.

OK

error icon

Oops! Something went wrong.

Please go back try again later.