|
| 1 | +--- |
| 2 | +subcategory: "Object Storage" |
| 3 | +page_title: "Scaleway: scaleway_object" |
| 4 | +--- |
| 5 | + |
| 6 | +# scaleway_object |
| 7 | + |
| 8 | +The `scaleway_object` data source is used to retrieve information about an Object Storage object. |
| 9 | + |
| 10 | +Refer to the Object Storage [documentation](https://www.scaleway.com/en/docs/object-storage/how-to/create-a-bucket/) for more information. |
| 11 | + |
| 12 | +## Retrieve an Object Storage object |
| 13 | + |
| 14 | +The following example demonstrates how to retrieve metadata about an object stored in a bucket: |
| 15 | + |
| 16 | +```hcl |
| 17 | +resource "scaleway_object_bucket" "main" { |
| 18 | + name = "bucket.test.com" |
| 19 | +} |
| 20 | +
|
| 21 | +resource "scaleway_object" "example" { |
| 22 | + bucket = scaleway_object_bucket.main.name |
| 23 | + key = "example.txt" |
| 24 | + content = "Hello world!" |
| 25 | +} |
| 26 | +
|
| 27 | +data "scaleway_object" "selected" { |
| 28 | + bucket = scaleway_object.example.bucket |
| 29 | + key = scaleway_object.example.key |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | +## Argument Reference |
| 34 | + |
| 35 | +This section lists the arguments that you can provide to the `scaleway_object` data source to filter and retrieve the desired Object Storage bucket. Each argument has a specific purpose: |
| 36 | + |
| 37 | +## Argument Reference |
| 38 | + |
| 39 | +This section lists the arguments that you can provide to the `scaleway_object` data source to filter and retrieve the desired Object Storage bucket. Each argument has a specific purpose: |
| 40 | + |
| 41 | +- `bucket` - (Required) The name of the bucket, or its terraform ID (`{region}/{name}`) |
| 42 | +- `key` - (Required) The key (path or filename) of the object within the bucket. |
| 43 | +- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#zones) in which the bucket exists. |
| 44 | +- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project with which the bucket is associated. |
| 45 | + |
| 46 | +## Attributes Reference |
| 47 | + |
| 48 | +The `scaleway_object` data source exports certain attributes once the object information is retrieved. These attributes can be referenced in other parts of your Terraform configuration. |
| 49 | + |
| 50 | +In addition to all above arguments, the following attribute is exported: |
| 51 | + |
| 52 | +* `id` - The unique identifier of the object. |
| 53 | + |
| 54 | +~> **Important**: Object IDs are regional, and follow the format {region}/{bucket}/{key}, e.g. fr-par/bucket-name/example.txt. |
| 55 | + |
0 commit comments