Copy AMI to a separate region from a separate account

I am trying to transfer AMI from my AWS account A (ap-southeast-2) to account B (us-east-1).

In my account, I have granted launch permissions for my account A.

However, when I run the code below,

$result = $this->destination_ec2_client->copyImage(
          array(
               'SourceRegion' => $this->source_region,
               'SourceImageId' => $image_id,
               'Name' => $amis[0]['Name']
          ));

When I run the documentation over the code, the call should copy the AMI from the source area and copy it to the destination area.

However, the end result is an error. An error is displayed on the console when the AMI description is unsuccessful.

State Reason: AMI ownership mismatch

Any thoughts? Did I understand the mechanism correctly?

+2
source share
2 answers

CLI AWS - . :

$ aws ec2 run-instances --image-id $SHAREDAMI --instance-type c3.large  --user-data '#!/bin/bash
> poweroff'

:

$ aws ec2 create-image --instance-id $IDFROMRUN --name "Image from other accounts AMI"

AMI . :.

$ aws --region us-west-1 ec2 copy-image --source-region us-east-1 --source-image-id $AMIFROMCREATE --name "Copy of Image from other accounts AMI"
+5

AFAIK, AMI .

, AMI B (ap---2) AMI A (ap-south-2).

, AMI A public. B, AMI (ap-southeast-2)

, B, script, AMI ap-south-2 us-east-1

, .

0

All Articles