Compute Engine lets you deprecate a custom image that you own by setting the deprecation status on the image. Each deprecation status causes a different response from the server, helping you transition users away from unsupported images in a manageable way. Use the Google Cloud console, the Google Cloud CLI, or the Compute Engine API method to deprecate an image.
Deprecation states
The following deprecation states are supported:
-
ACTIVE
: the image is active and can be used as normal. Image families point to the most recent and active image in a family. -
DEPRECATED
: the image is marked deprecated but can still be used to create a VM . New links to this image are allowed. Image families no longer point to this image even if it is the most recent image in the family.If you create a VM with a deprecated image using the Google Cloud CLI, the request succeeds with a warning.
-
OBSOLETE
: the image is marked obsolete and is no longer available for use. An error message is returned if you try to use this image in a request. Existing links to this image are still allowed. -
DELETED
: this image is deleted. An error message is returned if you try to use a deleted image.
You can revert a deprecation (make an image active again), by changing the
deprecation state to ACTIVE
.
Before you begin
- Read the Images document.
- If you haven't already, set up authentication
.
Authentication verifies your identity for access to Google Cloud services and APIs. To run
code or samples from a local development environment, you can authenticate to
Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity .
- Set a default region and zone .
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity .
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
Deprecate a custom image
Console
-
In the Google Cloud console, go to the Imagespage.
-
For the image you want to deprecate, click Actions .
-
Select Deprecate.
-
For state, select either Deprecatedor Obsolete. For more information about states, see Deprecation states .
-
Optional: Specify a replacement image.
-
Click Deprecate Image.
gcloud
Use the gcloud compute images deprecate
command
to set the deprecation status of an image.
gcloud compute images deprecate IMAGE_NAME \ --state STATE \ --replacement REPLACEMENT
Replace the following:
-
IMAGE_NAME
: the name of the image to deprecate -
STATE
: the deprecation state -
REPLACEMENT
: the image to replace the one that is deprecated
Go
Java
Python
REST
Make a POST
request to the images().deprecate
method
.
Specify the name of the image you want to deprecate.
POST https://compute.googleapis.com/compute/v1/projects/ PROJECT_ID /global/images/ RESOURCE_ID /deprecate { "state": " STATE ", "replacement": " REPLACEMENT " }
Replace the following:
-
PROJECT_ID
: the project to which the image belongs. -
RESOURCE_ID
: the name of the image that you are deprecating. -
STATE
: the deprecation state of this resource. -
REPLACEMENT
: the image to replace the one that is deprecated.