1Z0-1067-25 Question 13
Select 2You have an ephemeral environment with multiple compute instances named 'stage-app' in your development compartment. You want to use the OCI CLI to first identify all instances matching the 'stage-app' name, then remove them in a single step without further prompts. Which two steps are required?
- A
Use 'oci compute instance list' with a JMESPath filter on the display-name to retrieve only the instance IDs of 'stage-app' instances.
- B
Terminate the identified instance IDs using 'oci compute instance terminate --force' to bypass interactive prompts.
- C
Use 'oci compute instance delete' with only a --compartment-id parameter to remove all instances from the entire compartment.
- D
Shut down each instance using 'oci compute instance stop' and then run 'oci compute vnic-attachment delete' to remove the network-interface attachments before terminating the instance.
Show answer and explanation
Correct answers: A, B
Explanation
To safely and efficiently remove only the 'stage-app' instances, you can filter for the exact instance IDs using the OCI CLI's JMESPath query syntax, then use the terminate command with the --force flag to remove them in a single step. Refer to the OCI CLI Command Reference for more details on the 'oci compute instance list' and 'oci compute instance terminate' subcommands and their parameters.
- A. Correct.
Correct. The 'oci compute instance list' command can be combined with the --query parameter in JMESPath syntax to filter on display-name. For example, '--query "data[?`display-name`=='stage-app'].id"' returns only the IDs of instances named 'stage-app'.
- B. Correct.
Correct. Once you have the instance IDs, you can pass each ID to the 'oci compute instance terminate' command. Using the --force flag ensures no interactive prompts will appear, making it suitable for script automation.
- C. Incorrect.
Incorrect. There is no 'oci compute instance delete' command; the correct syntax is 'terminate'. Also, using only --compartment-id without a name or ID filter could remove all instances in the compartment, which is risky and not specific to 'stage-app'.
- D. Incorrect.
Incorrect. You do not need to perform a manual 'stop' action followed by a 'vnic-attachment delete' before terminating instances. Terminating the instance via 'oci compute instance terminate' automatically handles the cleanup of attached resources.