You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Command/Aws/Ec2/CopyImageCommand.php
+23-5
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,8 @@ protected function configure()
50
50
->addOption('Description', 'description', InputOption::VALUE_OPTIONAL, 'A description for the new AMI in the destination region')
51
51
->addOption('ClientToken', 'clienttoken', InputOption::VALUE_OPTIONAL, 'Unique, case-sensitive identifier you provide to ensure the idempotency of the request')
->addOption('AmiName', 'aminame', InputOption::VALUE_NONE, 'Use AMI name instead if ID');
53
+
->addOption('AmiName', 'aminame', InputOption::VALUE_NONE, 'Use AMI name instead of ID')
54
+
;
54
55
}
55
56
56
57
/**
@@ -64,12 +65,29 @@ protected function execute(InputInterface $input, OutputInterface $output)
64
65
65
66
if ($options['AmiName']) {
66
67
$name = $options['SourceImageId'];
67
-
$image = $client->describeImages(["Filters" => [["Name" => "name", "Values" => [$name]]]]); # TODO if more than one instance is returned, warn the user
68
-
$sourceImageId = $image['Images'][0]['ImageId'];
69
-
$options['SourceImageId'] = $sourceImageId;
68
+
$image = $client->describeImages(
69
+
[
70
+
"Filters" => [
71
+
[
72
+
"Name" => "name",
73
+
"Values" => [$name]
74
+
]
75
+
]
76
+
]
77
+
);
78
+
$imageCollection = $image['Images'];
79
+
if (count($imageCollection) > 1) {
80
+
$output->writeln('<error>Know that the AMI name provided matched more than one image. Please be more specific to avoid copying the wrong image.</error>');
Copy file name to clipboardexpand all lines: Command/Aws/Ec2/CreateImageCommand.php
+6-4
Original file line number
Diff line number
Diff line change
@@ -47,9 +47,10 @@ protected function configure()
47
47
->addArgument('Name', InputArgument::REQUIRED, 'A name for the new image.')
48
48
->addArgument('InstanceId', InputArgument::REQUIRED, 'The ID of the instance')
49
49
->addArgument('Description', InputArgument::OPTIONAL, 'A description for the new image.')
50
-
->addOption('BlockDeviceMappings', 'mappings', InputOption::VALUE_OPTIONAL, 'Information about one or more block device mappings. Takes JSON')
50
+
->addOption('BlockDeviceMappings', 'mappings', InputOption::VALUE_OPTIONAL, 'Information about one or more block device mappings. Takes JSON.')
51
51
->addOption('NoReboot', 'noreboot', InputOption::VALUE_NONE, 'Amazon EC2 will not shut down the instance before creating the image. Filesystem integrity is not guaranteed.')
Copy file name to clipboardexpand all lines: Command/Aws/Ec2/DeregisterImageCommand.php
+22-4
Original file line number
Diff line number
Diff line change
@@ -60,11 +60,29 @@ protected function execute(InputInterface $input, OutputInterface $output)
60
60
61
61
if ($options['AmiName']) {
62
62
$name = $options['ImageId'];
63
-
$image = $client->describeImages(["Filters" => [["Name" => "name", "Values" => [$name]]]]); # TODO if more than one instance is returned, warn the user
64
-
$imageId = $image['Images'][0]['ImageId'];
65
-
$options['ImageId'] = $imageId;
63
+
$image = $client->describeImages(
64
+
[
65
+
"Filters" => [
66
+
[
67
+
"Name" => "name", "Values" => [$name]
68
+
]
69
+
]
70
+
]
71
+
);
72
+
$imageCollection = $image['Images'];
73
+
if (count($imageCollection) > 1) {
74
+
$output->writeln('<error>Know that the AMI name provided matched more than one image. Please be more specific to avoid deregistering the wrong image.</error>');
0 commit comments