Cloud Migration

Cloud migration is the process of moving data, applications or other business elements from an organization’s onsite computers to the cloud, or moving them from one cloud environment to another.

Fig.1 Key Points in Cloud Migration

Steps for Migrating VM from On-premises to AWS cloud

Data Flow for this process would be,

Fig.2 Data Flow

1. Basic AWS environment

One basic thing to remember while migrating from on-premises to the cloud is an “Existing infrastructure” of that particular virtual machine. User has to create an exact same environment in AWS cloud which they had on their On-premises.

Here in blog, we have taken an example of “Migration of Artifactory VM to the AWS cloud”. To ease out manual process of creating an AWS infrastructure, we used one CloudFormation template which will create a full AWS stack required by an Artifactory VM.

Here’s a sample of CloudFormation template,

AWSTemplateFormatVersion: “2010-09-09″Description: “Environment for Cloud Migration”

Resources:

CloudMigrationVPC:

Type: “AWS::EC2::VPC”

Properties:

CidrBlock: “10.0.0.0/16”

EnableDnsHostnames: “true”

EnableDnsSupport: “true”

Tags:

– Key: “Name”

Value: “Cloudvpc”

InternetGateway:

Type: “AWS::EC2::InternetGateway”

Properties: {}

VPCGatewayAttachment:

Type: “AWS::EC2::VPCGatewayAttachment”

Properties:

VpcId: {“Ref”: “CloudMigrationVPC”}

InternetGatewayId: {“Ref”: “InternetGateway”}

SubnetA:

Type: “AWS::EC2::Subnet”

Properties:

CidrBlock: “10.0.1.0/24”

VpcId: {“Ref”: “CloudMigrationVPC”}

RouteTable:

Type: “AWS::EC2::RouteTable”

Properties:

VpcId: {“Ref”: “CloudMigrationVPC”}

RouteTableAssociationA:

Type: “AWS::EC2::SubnetRouteTableAssociation”

Properties:

SubnetId: {“Ref”: “SubnetA”}

RouteTableId: {“Ref”: “RouteTable”}

RoutePublic:

Type: “AWS::EC2::Route”

Properties:

RouteTableId: {“Ref”: “RouteTable”}

DestinationCidrBlock: “0.0.0.0/0”

GatewayId: {“Ref”: “InternetGateway”}

DependsOn: “VPCGatewayAttachment”

CloudMigrationSG:

Type: “AWS::EC2::SecurityGroup”

Properties:

GroupDescription: “cloud_security”

VpcId: {“Ref”: “CloudMigrationVPC”}

SecurityGroupIngress:

– CidrIp: “0.0.0.0/0”

FromPort: 80

IpProtocol: “tcp”

ToPort: 80

– CidrIp: “0.0.0.0/0”

FromPort: 8081

IpProtocol: “tcp”

ToPort: 8081

– CidrIp: “0.0.0.0/0”

FromPort: 8080

IpProtocol: “tcp”

ToPort: 8080

– CidrIp: “0.0.0.0/0”

FromPort: 22

IpProtocol: “tcp”

ToPort: 22

2. AWS Cli
  • Prerequisite for AWS cli

Pip: – To install refer this link, https://packaging.python.org/installing/

For installing AWS cli use this command,

pip install –upgrade awscli

aws –version

  • To use AWS cli, User needs to configure it with AWS Access key and secret key which generated when a user created an IAM user.

For AWS cli configuration use,

aws configure
3. AWS Role and policy
  • Create a role named vmimport with a trust relationship policy document that allows VM import to assume the role, and user must attach an IAM policy to the role.

Create a file named trust-policy.json with the following policy:

{“Version”: “2012-10-17”,

“Statement”: [

{

“Effect”: “Allow”,

“Principal”: { “Service”: “vmie.amazonaws.com” },

“Action”: “sts:AssumeRole”,

“Condition”: {

“StringEquals”:{

“sts:Externalid”: “vmimport”

} } } ] }

  • Use the create-role command to create a role named vmimport and give VM Import/Export access to it. Ensure that you specify the full path to the location of the trust-policy.json file.
aws iam create-role –role-name vmimport –assume-role-policy-document file://trust-policy.json

Create role-policy

  • Create a file named role-policy.json with the following policy, where <bucket name> is the bucket where the disk images are stored:

{“Version”: “2012-10-17”,

“Statement”: [

{

“Effect”: “Allow”,

“Action”: [

“s3:ListBucket”,

“s3:GetBucketLocation”

],

“Resource”: [

“arn:aws:s3:::<bucket-name>”

]

},

{

“Effect”: “Allow”,

“Action”: [

“s3:GetObject”

],

“Resource”: [

“arn:aws:s3:::<bucket-name>/*”

]

},

{

“Effect”: “Allow”,

“Action”:[

“ec2:ModifySnapshotAttribute”,

“ec2:CopySnapshot”,

“ec2:RegisterImage”,

“ec2:Describe*”

],

“Resource”: “*”

} ] }

  • Use the following put-role-policy command to attach the policy to the role created above. Ensure that user specify the full path to the location of the role-policy.json file.
aws iam put-role-policy –role-name vmimport –policy-name vmimport –policy-document file://role-policy.json
4. Creating .VHD file of On-premises virtual machine (XEN environment)
  • Open the Export wizard: select the pool or server containing the VM(s) that user want to export, then click on VM menu, Export.
  • On the first page of the wizard, enter the name of the export file, specify the folder

Where user want file(s) to be saved, and select OVF/OVA Package (*.ovf, *.ova) from the Format list, and click Next.

  • Select the VMs that user want to export and then click Next.
  • On the EULAs page, user can add previously prepared End User Licensing Agreement (EULA) documents in the package.
  • On the Transfer VM Settings page, configure networking options for the temporary VM used to perform the export process (“Transfer VM”). Click Next to continue.
  • On the final page of the wizard, review the settings that user have configured on the previous pages.
  • Click Finish to begin exporting selected VMs and close the wizard.
5. Upload an Image to Amazon S3
  • To upload file from local to s3
aws s3api put-object –bucket <bucketname> –key <filename> –body <filepath>

 

6. Import Image
  • After user uploaded their VM image file to Amazon S3, user can use the AWS CLI to import the image.

Use the import-image command,

aws ec2 import-image –description “Description” –disk-containers file://containers.json

The following is an example containers.json file.

[{

“Description”: “description”,

“Format”: “ova”,

“UserBucket”: {

“S3Bucket”: “democloudmigration”,

“S3Key”: “artifactory.ova”

} } ]

  • Use the describe-import-image-tasks command to return the status of an import task.
aws ec2 describe-import-image-tasks –import-task-ids import-ami-<id>

Wait until status says “Completed”.

7. Create an instance using ami
  • To create an instance from ami, run a following command:
aws ec2 run-instances –image-id <AMI-ID> –count 1 –instance-type t2.micro –key-name <keyName> –security-group-ids <SG-ID> –subnet-id <SUBNET-ID> —associate-public-ip-address

 

Conclusion:

Cloud migration has some risks associated with it. So while implementing it be well prepared. To avoid potential disaster, map out your strategy and plan for the unexpected. A solid migration strategy acts as a guide or checklist to ensure a successful journey to the cloud. Enterprises need to plan for expenses, especially the unexpected ones as well as the migration’s effect on an organization, its systems and users.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


CAPTCHA Image
Reload Image