Tuesday 15 October 2013

How to at AWS

Over here I will be putting some of my notes on how to do things at aws, to the best knowledge to me. I know there other good ways to do the same things.

-> How to create your own instance image.


Most of the time you create a image from the one of the listed image from AWS and work on the same image with your settings. Once you do all your base settings, its always good to create an instance image from that image/setting so that you can use the same for the future usages:

Following are few steps using that you can create an image,.

1. Login to your same instance where you have configured the instance.

2. For some standard, it good to create a directory [ mostly you can think of at /mnt ]. e.g: sudo mkdir /mnt/instanceImage/ [ I am using a ubuntu instance./ ]

3. command: 
sudo ec2-bundle-vol -d /mnt/instanceImage -k YourPrivateKeyPath  -c YourCertificatePath -u YourAWSAccountNumber

This above command will bundle your instance image.

4. command:
sudo ec2-upload-bundle -b bucketName -m PathToManifest -a YourAccessKeyUser -s YourSecretKeyPassword



Some Related Commands:

ec2-bundle-vol --help


MANDATORY PARAMETERS
    -c, --cert PATH                  The path to the user's PEM encoded RSA public key certificate file.
    -k, --privatekey PATH            The path to the user's PEM encoded RSA private key file.
    -u, --user USER                  The user's EC2 user ID (Note: AWS account number, NOT Access Key ID).

OPTIONAL PARAMETERS
    -h, --help                       Display this help message and exit.
        --version                    Display the version and copyright notice and then exit.
        --manual                     Display the user manual and exit.
        --batch                      Run in batch mode. No interactive prompts.
        --debug                      Display debug messages.
    -d, --destination PATH           The directory to create the bundle in. Defaults to '/tmp'.
        --ec2cert PATH               The path to the EC2 X509 public key certificate bundled into the AMI.
                                     Defaults to '/home/ubuntu/ec2/etc/ec2/amitools/cert-ec2.pem'.
    -r, --arch ARCHITECTURE          Specify target architecture. One of ["i386", "x86_64"]
        --productcodes PRODUCT_CODES Default product codes attached to the image at registration time.
                                     Comma separated list of product codes.
        --kernel ID                  Id of the default kernel to launch the AMI with.
        --ramdisk ID                 Id of the default ramdisk to launch the AMI with.
    -B, --block-device-mapping MAPS  Default block-device-mapping scheme to launch the AMI with. This scheme
                                     defines how block devices may be exposed to an EC2 instance of this AMI
                                     if the instance-type of the instance is entitled to the specified device.
                                     The scheme is a comma-separated list of key=value pairs, where each key
                                     is a "virtual-name" and each value, the corresponding native device name
                                     desired. Possible virtual-names are:
                                      - "ami": denotes the root file system device, as seen by the instance.
                                      - "root": denotes the root file system device, as seen by the kernel.
                                      - "swap": denotes the swap device, if present.
                                      - "ephemeralN": denotes Nth ephemeral store; N is a non-negative integer.
                                     Note that the contents of the AMI form the root file system. Samples of
                                     block-device-mappings are:
                                      - "ami=sda1,root=/dev/sda1,ephemeral0=sda2,swap=sda3"
                                      - "ami=0,root=/dev/dsk/c0d0s0,ephemeral0=1"
    -a, --all                        Include all directories in the volume being bundled, including those
                                     on remotely mounted filesystems.
    -e, --exclude DIR1,DIR2,...      A comma-separated list of absolute directory paths to exclude. This
                                     option overrides the "--all" option.
    -p, --prefix PREFIX              The filename prefix for bundled AMI files. Defaults to "image".
    -s, --size MB                    The size, in MB (1024 * 1024 bytes), of the image file to create.
                                     The maximum size is 10240 MB.
        --[no-]inherit               Inherit instance metadata. Enabled by default.
                                     Bundling will fail if inherit is enabled but instance data
                                     is not accessible, for example not bundling an EC2 instance.
    -v, --volume PATH                The absolute path to the mounted volume to be bundled. Defaults to "/".
        --fstab PATH                 The absolute path to the fstab to be bundled into the image.
        --generate-fstab             Inject a generated EC2 fstab. (Only use this if you are not rebundling
                                     an existing instance.)

----

ec2-bundle-image --help


MANDATORY PARAMETERS
    -c, --cert PATH                  The path to the user's PEM encoded RSA public key certificate file.
    -k, --privatekey PATH            The path to the user's PEM encoded RSA private key file.
    -u, --user USER                  The user's EC2 user ID (Note: AWS account number, NOT Access Key ID).
    -i, --image PATH                 The path to the file system image to bundle.

OPTIONAL PARAMETERS
    -h, --help                       Display this help message and exit.
        --version                    Display the version and copyright notice and then exit.
        --manual                     Display the user manual and exit.
        --batch                      Run in batch mode. No interactive prompts.
        --debug                      Display debug messages.
    -d, --destination PATH           The directory to create the bundle in. Defaults to '/tmp'.
        --ec2cert PATH               The path to the EC2 X509 public key certificate bundled into the AMI.
                                     Defaults to '/etc/ec2/amitools/cert-ec2.pem'.
    -r, --arch ARCHITECTURE          Specify target architecture. One of ["i386", "x86_64"]
        --productcodes PRODUCT_CODES Default product codes attached to the image at registration time.
                                     Comma separated list of product codes.
        --kernel ID                  Id of the default kernel to launch the AMI with.
        --ramdisk ID                 Id of the default ramdisk to launch the AMI with.
    -B, --block-device-mapping MAPS  Default block-device-mapping scheme to launch the AMI with. This scheme
                                     defines how block devices may be exposed to an EC2 instance of this AMI
                                     if the instance-type of the instance is entitled to the specified device.
                                     The scheme is a comma-separated list of key=value pairs, where each key
                                     is a "virtual-name" and each value, the corresponding native device name
                                     desired. Possible virtual-names are:
                                      - "ami": denotes the root file system device, as seen by the instance.
                                      - "root": denotes the root file system device, as seen by the kernel.
                                      - "swap": denotes the swap device, if present.
                                      - "ephemeralN": denotes Nth ephemeral store; N is a non-negative integer.
                                     Note that the contents of the AMI form the root file system. Samples of
                                     block-device-mappings are:
                                      - "ami=sda1,root=/dev/sda1,ephemeral0=sda2,swap=sda3"
                                      - "ami=0,root=/dev/dsk/c0d0s0,ephemeral0=1"
    -p, --prefix PREFIX              The filename prefix for bundled AMI files. Defaults to image name.


---

 ec2-upload-bundle --help


MANDATORY PARAMETERS
    -b, --bucket BUCKET              The bucket to use. This is an S3 bucket,
                                     followed by an optional S3 key prefix using '/' as a delimiter.
    -a, --access-key USER            The user's AWS access key ID.
    -s, --secret-key PASSWORD        The user's AWS secret access key.
    -m, --manifest PATH              The path to the manifest file.

OPTIONAL PARAMETERS
    -h, --help                       Display this help message and exit.
        --version                    Display the version and copyright notice and then exit.
        --manual                     Display the user manual and exit.
        --batch                      Run in batch mode. No interactive prompts.
        --debug                      Display debug messages.
        --url URL                    The S3 service URL. Defaults to https://s3.amazonaws.com.
        --acl ACL                    The access control list policy ["public-read" | "aws-exec-read"].
                                     Defaults to "aws-exec-read".
    -d, --directory DIRECTORY        The directory containing the bundled AMI parts to upload.
                                     Defaults to the directory containing the manifest.
        --part PART                  Upload the specified part and upload all subsequent parts.
        --retry                      Automatically retry failed uploads.
        --skipmanifest               Do not upload the manifest.
        --location LOCATION          The location of the bucket to upload to [EU,US,us-west-1,ap-southeast-1].







No comments:

Post a Comment