Creating instances for AWS Marketplace
The AWS Marketplace helps customers find software from a set of third-party vendors. There is no need to set up a new billing account for another company; those bills can be paid via the AWS monthly bills. We can read reviews from other customers to help us make the most appropriate selection. We can also share or sell our AMIs with the public so that the wider community can use them.
In this recipe, we list the commands for creating AMIs for offering them to other users on AWS Marketplace.
How to do it…
Here we list the commands for creating AMIs for offering them to other users on AWS Marketplace.
Creating an AMI from EC2 instance
By running the following command, you can create the image from EC2 instance. You have to provide the instance ID, image name, and image description.
$ aws ec2 create-image --instance-id [InstanceId] --name [Name] --description [Description]
The parameters used in this command are described as follows:
[InstanceId]
: This option provides the EC2 instance ID[Name]
: This option gives the name of the image[Description]
: This one provides the image description
The following command creates an image of the EC2 instance with ID i-2e7dace3
:
$ aws ec2 create-image --instance-id i-2e7dace3 --name "WebServerImage" --description "Image of web server"
Making the AMI public
By running the following command, you can make your image public. You have to provide the image ID and launch permissions.
$ aws ec2 modify-image-attribute --image-id [ImageId] --launch-permission [LaunchPermission]
The parameters used in this command are described as follows:
[ImageId]
: This option provides the image ID[LaunchPermission]
: This option is used to launch permissionsSyntax:
"{\"Add\": [{\"Group\":\"all\"}]}"
By running following command, you can make your image public.
$ aws ec2 modify-image-attribute --image-id ami-97e6cbc5 --launch-permission "{\"Add\": [{\"Group\":\"all\"}]}"