Skip to content

Commit 3475e56

Browse files
committed
feat: switch to ovh provider for buckets
1 parent 16b0f12 commit 3475e56

File tree

6 files changed

+44
-41
lines changed

6 files changed

+44
-41
lines changed

ovh/bucket/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ Create a S3 compatible object storage bucket and policy for a user with write ac
88
| Name | Version |
99
|------|---------|
1010
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 |
11-
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | ~> 1.49.0 |
12-
| <a name="requirement_ovh"></a> [ovh](#requirement\_ovh) | ~> 0.26.0 |
11+
| <a name="requirement_ovh"></a> [ovh](#requirement\_ovh) | ~> 2.1 |
1312
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.9.1 |
1413

1514
## Providers
1615

1716
| Name | Version |
1817
|------|---------|
19-
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | ~> 1.49.0 |
18+
| <a name="provider_ovh"></a> [ovh](#provider\_ovh) | ~> 2.1 |
2019
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.9.1 |
2120

2221
## Modules
@@ -27,19 +26,21 @@ No modules.
2726

2827
| Name | Type |
2928
|------|------|
30-
| [openstack_objectstorage_container_v1.bucket](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/objectstorage_container_v1) | resource |
29+
| [ovh_cloud_project_storage.storage](https://registry.terraform.io/providers/ovh/ovh/latest/docs/resources/cloud_project_storage) | resource |
3130
| [time_static.last_update](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource |
32-
| [openstack_identity_auth_scope_v3.current](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/data-sources/identity_auth_scope_v3) | data source |
3331

3432
## Inputs
3533

3634
| Name | Description | Type | Default | Required |
3735
|------|-------------|------|---------|:--------:|
36+
| <a name="input_cloud_project_id"></a> [cloud\_project\_id](#input\_cloud\_project\_id) | Cloud project ID for this bucket | `string` | n/a | yes |
3837
| <a name="input_customer"></a> [customer](#input\_customer) | Customer applied to this instance | `string` | `""` | no |
38+
| <a name="input_encryption_enabled"></a> [encryption\_enabled](#input\_encryption\_enabled) | A boolean that indicates whether this bucket has encryption enabled. | `string` | `true` | no |
3939
| <a name="input_name"></a> [name](#input\_name) | Name applied to this instance | `string` | `""` | no |
40-
| <a name="input_ovh_write_user"></a> [ovh\_write\_user](#input\_ovh\_write\_user) | OVH user name who will have write access to the bucket | `string` | n/a | yes |
41-
| <a name="input_region"></a> [region](#input\_region) | OVH region | `string` | `"GRA"` | no |
40+
| <a name="input_owner_id"></a> [owner\_id](#input\_owner\_id) | Container owner user ID for this bucket | `string` | `""` | no |
41+
| <a name="input_region_name"></a> [region\_name](#input\_region\_name) | Region (in uppercase) applied to this bucket | `string` | n/a | yes |
4242
| <a name="input_tags"></a> [tags](#input\_tags) | Tags applied to this instance | `map(string)` | <pre>{<br> "ManagedBy": "terraform"<br>}</pre> | no |
43+
| <a name="input_versioning_enabled"></a> [versioning\_enabled](#input\_versioning\_enabled) | A boolean that indicates whether this bucket has versioning enabled. | `bool` | `true` | no |
4344

4445
## Outputs
4546

ovh/bucket/bucket.tf

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
data "openstack_identity_auth_scope_v3" "current" {
2-
name = "current"
3-
}
4-
5-
resource "openstack_objectstorage_container_v1" "bucket" {
6-
name = var.name
7-
region = var.region
8-
metadata = local.interpolated_tags
9-
content_type = "application/json"
10-
container_read = join(":", [
11-
data.openstack_identity_auth_scope_v3.current.project_id,
12-
var.ovh_write_user,
13-
])
14-
container_write = join(":", [
15-
data.openstack_identity_auth_scope_v3.current.project_id,
16-
var.ovh_write_user,
17-
])
1+
resource "ovh_cloud_project_storage" "storage" {
2+
name = var.name
3+
service_name = var.cloud_project_id
4+
region_name = var.region_name
5+
owner_id = var.owner_id
6+
versioning = var.versioning_enabled ? {
7+
status = "enabled"
8+
} : null
9+
encryption = var.encryption_enabled ? {
10+
sse_algorithm = "AES256"
11+
} : null
1812
}

ovh/bucket/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ locals {
88
},
99
var.tags
1010
)
11-
s3_region = lower(element(regex("(.*)[[:digit:]]?$", var.region), 0))
11+
s3_region = lower(element(regex("(.*)[[:digit:]]?$", var.region_name), 0))
1212
}
1313

1414
resource "time_static" "last_update" {

ovh/bucket/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
output "bucket" {
22
value = {
3-
"url" = "s3://${openstack_objectstorage_container_v1.bucket.name}",
3+
"url" = "s3://${ovh_cloud_project_storage.storage.name}",
44
"endpoint_url" = "https://s3.${local.s3_region}.cloud.ovh.net"
55
"region" = local.s3_region,
6-
"name" = openstack_objectstorage_container_v1.bucket.name,
6+
"name" = ovh_cloud_project_storage.storage.name,
77
}
88
}

ovh/bucket/providers.tf

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ terraform {
1010
}
1111
ovh = {
1212
source = "ovh/ovh"
13-
version = "~> 0.26.0"
14-
}
15-
openstack = {
16-
source = "terraform-provider-openstack/openstack"
17-
version = "~> 1.49.0"
13+
version = "~> 2.1"
1814
}
1915
}
2016
}

ovh/bucket/variables.tf

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,30 @@ variable "tags" {
1919
}
2020

2121
# bellow are specific modules variables
22-
variable "region" {
22+
variable "region_name" {
23+
description = "Region (in uppercase) applied to this bucket"
2324
type = string
24-
description = "OVH region"
25-
default = "GRA"
2625
}
2726

28-
# variable "ovh_service_name" {
29-
# description = "OVH service name"
30-
# type = string
31-
# }
27+
variable "cloud_project_id" {
28+
description = "Cloud project ID for this bucket"
29+
type = string
30+
}
31+
32+
variable "owner_id" {
33+
description = "Container owner user ID for this bucket"
34+
type = string
35+
default = ""
36+
}
37+
38+
variable "versioning_enabled" {
39+
description = "A boolean that indicates whether this bucket has versioning enabled."
40+
type = bool
41+
default = true
42+
}
3243

33-
variable "ovh_write_user" {
34-
description = "OVH user name who will have write access to the bucket"
44+
variable "encryption_enabled" {
45+
description = "A boolean that indicates whether this bucket has encryption enabled."
3546
type = string
47+
default = true
3648
}

0 commit comments

Comments
 (0)