EC2: Create AMI

Oveview

The "EC2: Create AMI" action allows you to create an Amazon Machine Image (hereinafter "AMI") from an Amazon EC2 instance (hereinafter "EC2 instance").
The AMI contains a disk image of the EC2 instance and information required to launch it, so that it can be used as a backup of your EC2 instance. As with other actions, you can specify the EC2 instance, from which the AMI is created, with a 、resource ID or a tag attached to the EC2 instance.

Configuration options

No Option Explanation
1 Region

Specify the region where the EC2 instance, which you want to retrieve an AMI, is located

2 Instance
 
Specify the EC2 instance, which you want to retrive the AMI, by resource ID
Instance with specified tag Specify the EC2 instance, which you want to retrive the AMI, by tag
3 AMI name
  • Specify AMI name
    • The resource ID, job ID and generation number of the created EC2 instance are attached to the end of the specified name
4 Explanation
  •  Enter the text to be attached to the "description" of the created AMI
    • You can include following keywords for the explanation
      • %Y
        • 4 digits Year (Example:2017)
      • %m
        • Month(01〜12)
      • %d
        • Day(01〜31)
      • %H
        • Time(00〜23)
      • %M
        • Minutes(00〜59)
      • %S
        • Second(00〜60)
      • %%
        • 「%」When escaping characters
      • When you sepecify "%Y%m%d%H%M", it will be replaced with "201709231100".
      • If you use a keyword in the description, the time zone of the time stored in the retrieved AMI description will be UTC.
5 Number of generations to be created
  •  Select the number of generations for generation management of the created AMI
    • For example, when there are already 5 AMIs created by Cloud Automator and the "generations to be created" option is 5, and the "EC2: Create AMI" action is further executed, the oldest AMI will be deleted to create new AMI.
      • Example: production-backup-i-XXXXXXXXXXX-1234-1
  • When "No generation management" is selected
    •  AMI will not be deleted
    • AMI name will be different from when generation management is enabled
      • Example: prodbackup-i-1234567890abcdef1-12123-20190820T035938Z
6 Instance restart
  •  Choose to restart your EC2 instance to provide a quiesce point when you get an AMI
    • If data inconsistency is not allowed and restart downtime is acceptable, we recommend to restart
  • See also `Re-create an image when AMI status is "Failed"` option
7 Tags to be added to the created image
  •  Specify the tag key and tag value of the tag to be attached to the created AMI
    • Add the same tag to the snapshot
      • Select to attach the same tag key and tag value to the EBS snapshot linked to the AMI
8 Check the completion status of the resource
  •  When not checking the completion status of a resource
    • CreateImage API The success or failure of CreateImage API request is the result of job execution
  •  When checking the completion status of a resource
    • A job is considered successful when the Create Image API request is successful and the status of the created AMI is available.
    • When the Create Image API request is successful and the status of the created AMI is something other than available (such as failed), the job is determined to have failed.
9  Re-create an image when AMI status is "Failed"
  • Select to re-create if the AMI status is failed when checking the completion status of the resource
  • NOTE: If "Instance restart" option is "Yes", the target instance will restart during Re-create an image

Configuration example

Create a job in Cloud Automator using the "EC2: Create AMI" action.

  1. Click the "Add Job" button on the Job screen of Cloud Automator
  2. Select the group to add the job at Select Group
  3. Select an intended trigger in the trigger selection (example: On-demand trigger)
  4. In the action selection, select the "EC2: Create AMI" action
  5. At AWS account selection, select designated AWS account
  6. Setting parameter of the action
    Region Asia pacific (Tokyo)
    Instances tagged with key: environment
    value: production
    Image name production-backup
    Description %Y%m%d%H%M
    Generation for create resource 5
    Reboot instance No
    Additional tag for created image key: environment
    value: production
    Add same tag to image snapshot. Check
    Watch resource exit status Check
    Re-create AMI when AMI creation has been failed. Check
    pict_en.png
  7. Setting post-process when succeeded or failed
  8. Enter Job name and click "Confirm"

Operation check

  1. Click log button for created Job
  2. Click the details of the execution log from the execution log list
  3. Check the result in the log details.
    If it is "success", you can confirm that the Job is executed successfully.
    If it is "Running", the Job is being executed, so check it back after a while.
  4. The operation result of each resource can be confirmed by clicking "Show detail".

Now you can confirm the operation of the Job using the "EC2: Create AMI" action. The "EC2: Create AMI" action is used by a large number of customers to back up EC2 instances. Please use it for your own benefits. 

Status condition of the log

Execution result

Status Explanation
Success It is successful in any of the following cases.
  • When checking the completion status of the resource
    • If the CreateImage API request is successful and the status of the created AMI is available
  • When you don't check the completion status of the resources
    • When CreateImage API request is successful
Failed It is failed in any of the following cases.
  • When checking the completion status of the resource
    • When EC2 instance, which was specified in the Job, is not existed
    • When EC2 instance, which was specified in the Job, exceeds 200
    • When the Create Image API request fails, or when the status of the created AMI is something other than available (such as failed)
  • When you don't check the completion status of the resources
    • When EC2 instance, which was specified in the Job, is not existed
    • When EC2 instance, which was specified in the Job, exceeds 200
    • When the Create Image API request fails

 

Resource operation history status conditions

The operational status is displayed for each AMI that you created.

Status Explanation
completed

It is completed in any of the following cases.

  •  When checking the completion status of the resource
    • If the CreateImage API request is successful and the status of the created AMI is available
  • When you don't check the completion status of the resources
    • When the Create Image API request is successful
failed It is failed in any of the following cases.
    • When checking the completion status of the resource
      • When the Create Image API request fails, or when the status of the created AMI is something other than available (such as failed)
    •  When you don't check the completion status of the resources
      • When the Create Image API request fails

 

About tags attached to AMI

The following tags are attached to the AMI generated by this action.

Key Value
Cloud Automator AMI Generation Generation management number of AMI managed by Cloud Automator (only when generation management is enabled)
Cloud Automator Job ID Job ID which is executed by Cloud Automator
Cloud Automator Source Instance Name Name tag value of the EC2 instance, which created the AMI

AWS API to be used in this action

The following AWS APIs were used for execution of the action.
Please note that the AWS account under which you run the action must have an IAM policy, which enables to run these APIs, attached.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request