This page describes how to view information about resources that are
provisioned by Infrastructure Manager.

You may want to view resources to understand their state, or to see what
resources exist in a deployment before you update or delete the deployment.

When Infrastructure Manager deploys a Terraform configuration, the service provisions
and configures the Google Cloud resources that are defined in the
configuration. Metadata about these resources are in the Terraform state file,
and Infra Manager stores this file for each deployment and revision.

The state file has information about the resources when they are provisioned
by Infra Manager. The state file and Infra Manager do not
have information about these resources if they are modified, unless they
are modified by a
[Infra Manager revision](https://docs.cloud.google.com/infrastructure-manager/docs/update-deployment.md.txt).

For example, you can use Infra Manager to deploy a load balancer
and then you can modify the load balancer using the Google Cloud console.
In this case, Infra Manager has information about the load balancer
that was initially provisioned, but not about the changes that you did
through the Google Cloud console.

If you need information about the deployment name or state, see
[View deployments](https://docs.cloud.google.com/infrastructure-manager/docs/view-deployments.md.txt).

## Before you begin

1. Ensure [Infra Manager is enabled](https://docs.cloud.google.com/infrastructure-manager/docs/enable-service.md.txt).
2. Ensure you have a service account.
3. Ensure that you have the IAM permissions needed to view deployments.
   - `roles/config.admin` or `roles/config.viewer`.

## List resources provisioned by a deployment

To list the resources provisioned by a deployment:

    gcloud infra-manager resources list --revision=projects/PROJECT_ID/locations/LOCATION/deployments/DEPLOYMENT_ID/revisions/REVISION_ID

Replace:

- <var translate="no">PROJECT_ID</var>: the project ID where Infrastructure Manager runs.
- <var translate="no">LOCATION</var>: the location where Infra Manager runs. See [Infrastructure Manager locations](https://docs.cloud.google.com/infrastructure-manager/docs/locations.md.txt) for the list of valid locations.
- <var translate="no">DEPLOYMENT_ID</var>: the deployment identifier of the resource's deployment.
- <var translate="no">REVISION_ID</var>: the revision identifier of the revision you're viewing.

### Filter the list of resources

To filter the list of resources:

    gcloud infra-manager resources list --revision=projects/PROJECT_ID/locations/LOCATION/deployments/DEPLOYMENT_ID/revisions/REVISION_ID --filter=EXPRESSION

Replace:

- <var translate="no">PROJECT_ID</var>: the project ID where Infrastructure Manager runs.
- <var translate="no">LOCATION</var>: the location where Infra Manager runs. See [Infrastructure Manager locations](https://docs.cloud.google.com/infrastructure-manager/docs/locations.md.txt) for the list of valid locations.
- <var translate="no">DEPLOYMENT_ID</var>: the deployment identifier of the resource's deployment.
- <var translate="no">REVISION_ID</var>: the revision identifier of the revision you're viewing and filtering.
- <var translate="no">EXPRESSION</var>: the expression you are filtering for. Supported expressions are:
  - `terraformInfo.address (string)`
  - `terraformInfo.type (string)`
  - `terraformInfo.id (string)`
  - `state (string)`, one of: `STATE_UNSPECIFIED`, `PLANNED`, `IN_PROGRESS`, `RECONCILED`, `FAILED`
  - `intent(string)`, one of: `INTENT_UNSPECIFIED`, `CREATE`, `UPDATE`, `DELETE`, `RECREATE`, `UNCHANGED`
  - `caiAssets.fullResourceName` (map)
  - `caiAssets.type` (map)

### Sort the list of resources

To sort the list of resources:

    gcloud infra-manager resources list --revision=projects/PROJECT_ID/locations/LOCATION/deployments/DEPLOYMENT_ID/revisions/REVISION_ID --sort-by=[FIELD]

Replace:

- <var translate="no">PROJECT_ID</var>: the project ID where Infrastructure Manager runs.
- <var translate="no">LOCATION</var>: the location where Infra Manager runs. See [Infrastructure Manager locations](https://docs.cloud.google.com/infrastructure-manager/docs/locations.md.txt) for the list of valid locations.
- <var translate="no">DEPLOYMENT_ID</var>: the deployment identifier of the resource's deployment.
- <var translate="no">REVISION_ID</var>: the revision identifier of the revision you're viewing and sorting.
- <var translate="no">FIELD</var>: the field used to sort. Supported fields are:
  - `name`
  - `terraformInfo.address`
  - `terraformInfo.type`
  - `terraformInfo.id`

## View details about a resource

To view details about a specific resource, use the resource ID:

    gcloud infra-manager resources describe projects/PROJECT_ID/locations/LOCATION/deployments/DEPLOYMENT_ID/revisions/REVISION_ID/resources/RESOURCE_ID

Replace:

- <var translate="no">PROJECT_ID</var>: the project ID where Infrastructure Manager runs.
- <var translate="no">LOCATION</var>: the location where Infra Manager runs. See [Infrastructure Manager locations](https://docs.cloud.google.com/infrastructure-manager/docs/locations.md.txt) for the list of valid locations.
- <var translate="no">DEPLOYMENT_ID</var>: the deployment identifier of the resource's deployment.
- <var translate="no">REVISION_ID</var>: the revision identifier of the specific revision that deployed the resource.
- <var translate="no">RESOURCE_ID</var>: the resource ID of the resource you're viewing.

## What's next

- Learn more about [Terraform with Google Cloud](https://docs.cloud.google.com/docs/terraform.md.txt).
- [Automate deployments](https://docs.cloud.google.com/infrastructure-manager/docs/automate-git.md.txt).
- [Update a deployment](https://docs.cloud.google.com/infrastructure-manager/docs/update-deployment.md.txt).
- [View the state of a deployment](https://docs.cloud.google.com/infrastructure-manager/docs/view-deployments.md.txt).
- [Delete a deployment](https://docs.cloud.google.com/infrastructure-manager/docs/delete-deployments.md.txt).