---
title: "Create an image and configure access to it in another project via Terraform"
sidebar_label: "Create an image and configure access to it in another project"
sidebar_position: 11
description: "How to create an image and configure access to it in another project"
toc_max_heading_level: 2
---

import Formbricks from '@theme/MDXComponents/Formbricks'
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import CreateResourcesAlert from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/common/create-resources-alert.mdx'
import ConfigureProvidersConfig from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/common/configure-providers-config.mdx'
import ConfigureProviders from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/common/configure-providers.mdx'
import CopyIcon from '@selectel/docux/icons/copy'

# Create an image and configure access to it in another project via Terraform

<CreateResourcesAlert />

<br />

1. [Configure providers for the source project](#configure-providers-for-source-project).

2. [Create an image](#create-image).

3. [Configure access to the image in another project](#configure-access-to-image).

4. [Configure providers for the target project](#configure-providers-for-target-project).

5. [Accept the image in the target project](#accept-image-in-project).

## Configuration files \{#config}

<details>
  <summary>Example file for configuring providers</summary>

  <ConfigureProvidersConfig />
</details>

<details>
  <summary>Example file for creating an image and configuring access to the image for other projects</summary>

  ```hcl
  resource "openstack_images_image_v2" "image_1" {
      name             = "Debian 12.10"
      container_format = "bare"
      disk_format      = "qcow2"
      visibility       = "shared"

      properties = {
          key = "value"
      }
  }

  resource "openstack_images_image_access_v2" "member_1" {
      image_id  = openstack_images_image_v2.image_1.id
      member_id = "bed6b6cbb86a4e2d8dc2735c2f1000e4"
  }

  ```
</details>

<details>
  <summary>Example file for accepting an image in the target project</summary>

  ```hcl
  data "openstack_images_image_v2" "image_1" {
      name          = "Debian 12.10"
      visibility    = "shared"
      member_status = "all"
  }

  resource "openstack_images_image_access_accept_v2" "member_1" {
      image_id = data.openstack_images_image_v2.image_1.id
      status   = "accepted"
  }

  ```
</details>

## 1. Configure providers for the source project \{#configure-providers-for-source-project}

If you have configured Selectel and OpenStack providers, skip this step.

<ConfigureProviders />

## 2. Create an image \{#create-image}

```hcl
resource "openstack_images_image_v2" "image_1" {
    name             = "Debian 12.10"
    container_format = "bare"
    disk_format      = "qcow2"
    visibility       = "shared"

    properties = {
        key = "value"
    }
}
```

Where:

* `container_format` — container format. Available values are `ami`, `ari`, `aki`, `bare`, `ovf`;
* `disk_format` — image disk format. Available values are `ami`, `ari`, `aki`, `vhd`, `vmdk`, `raw`, `qcow2`, `vdi`, `iso`;
* `visibility = "shared"` — the image can be added to other projects.

See the detailed description of the [openstack\_images\_image\_v2](/terraform/openstack-provider-reference/images-glance/resources/openstack_images_image_v2/) resource.

## 3. Configure access to the image in the source project \{#configure-access-to-image}

```hcl
resource "openstack_images_image_access_v2" "member_1" {
    image_id  = openstack_images_image_v2.image_1.id
    member_id = "bed6b6cbb86a4e2d8dc2735c2f1000e4"
}
```

Here `member_id` is the ID of the target project. You can find it in the [control panel](https://my.selectel.ru/vpc/default/servers): from the top menu, click **Products** → **Cloud Servers** → open the projects menu → in the line of the required project, click .<CopyIcon />

See the detailed resource description in [openstack\_images\_image\_access\_v2](/terraform/openstack-provider-reference/images-glance/resources/openstack_images_image_access_v2/).

## 4. Configure providers for the target project \{#configure-providers-for-target-project}

Create a separate configuration file and set up providers for the account and project for which you [configured access to the image](#configure-access-to-image).

<ConfigureProviders />

## 5. Accept the image in the target project \{#accept-image-in-project}

```hcl
data "openstack_images_image_v2" "image_1" {
    name          = "Debian 12.10"
    visibility    = "shared"
    member_status = "all"
}

resource "openstack_images_image_access_accept_v2" "member_1" {
    image_id = data.openstack_images_image_v2.image_1.id
    status   = "accepted"
}
```

Here `status = "accepted"` means the image will be accepted in the target project.

See the detailed resource description in [openstack\_images\_image\_access\_accept\_v2](/terraform/openstack-provider-reference/images-glance/resources/openstack_images_image_access_accept_v2/).

<Formbricks />
