From d099c40d15ed3e14db0fc1878b0149c9bf902c20 Mon Sep 17 00:00:00 2001 From: contabo Date: Thu, 21 Mar 2024 09:14:16 +0000 Subject: [PATCH] release v0.1.26 --- contabo/data_source_object_storage.go | 78 ++++--- contabo/data_source_tag.go | 69 ++++++ contabo/data_source_tag_assignment.go | 79 +++++++ contabo/handleErrors.go | 22 ++ contabo/provider.go | 4 + contabo/resource_tag.go | 200 ++++++++++++++++++ contabo/resource_tag_assignment.go | 187 ++++++++++++++++ docs/data-sources/contabo_image.md | 22 +- docs/data-sources/contabo_instance.md | 22 +- .../data-sources/contabo_instance_snapshot.md | 22 +- docs/data-sources/contabo_object_storage.md | 37 +++- .../contabo_object_storage_bucket.md | 23 +- docs/data-sources/contabo_private_network.md | 22 +- docs/data-sources/contabo_secret.md | 22 +- docs/data-sources/contabo_tag.md | 44 ++++ docs/data-sources/contabo_tag_assignment.md | 51 +++++ docs/guides/custom_instance.md | 2 +- docs/guides/use_environment_variables.md | 2 +- docs/index.md | 2 +- .../contabo_object_storage_bucket.md | 1 - docs/resources/contabo_tag.md | 47 ++++ docs/resources/contabo_tag_assignment.md | 45 ++++ examples/custom_instance/custom_instance.tf | 2 +- .../data-sources/contabo_image/data-source.tf | 17 ++ .../contabo_instance/data-source.tf | 17 ++ .../contabo_instance_snapshot/data-source.tf | 17 ++ .../contabo_object_storage/data-source.tf | 27 +++ .../data-source.tf | 18 ++ .../contabo_private_network/data-source.tf | 17 ++ .../contabo_secret/data-source.tf | 17 ++ .../data-sources/contabo_tag/data-source.tf | 16 ++ .../contabo_tag_assignment/data-source.tf | 17 ++ examples/main.tf.example | 2 +- examples/provider/provider.tf | 2 +- .../contabo_object_storage_bucket/resource.tf | 19 ++ examples/resources/contabo_tag/resource.tf | 19 ++ .../contabo_tag_assignment/resource.tf | 14 ++ .../use_environment_variables.tf | 2 +- 38 files changed, 1178 insertions(+), 48 deletions(-) create mode 100644 contabo/data_source_tag.go create mode 100644 contabo/data_source_tag_assignment.go create mode 100644 contabo/resource_tag.go create mode 100644 contabo/resource_tag_assignment.go create mode 100644 docs/data-sources/contabo_tag.md create mode 100644 docs/data-sources/contabo_tag_assignment.md create mode 100644 docs/resources/contabo_tag.md create mode 100644 docs/resources/contabo_tag_assignment.md create mode 100644 examples/data-sources/contabo_image/data-source.tf create mode 100644 examples/data-sources/contabo_instance/data-source.tf create mode 100644 examples/data-sources/contabo_instance_snapshot/data-source.tf create mode 100644 examples/data-sources/contabo_object_storage/data-source.tf create mode 100644 examples/data-sources/contabo_object_storage_bucket/data-source.tf create mode 100644 examples/data-sources/contabo_private_network/data-source.tf create mode 100644 examples/data-sources/contabo_secret/data-source.tf create mode 100644 examples/data-sources/contabo_tag/data-source.tf create mode 100644 examples/data-sources/contabo_tag_assignment/data-source.tf create mode 100644 examples/resources/contabo_object_storage_bucket/resource.tf create mode 100644 examples/resources/contabo_tag/resource.tf create mode 100644 examples/resources/contabo_tag_assignment/resource.tf diff --git a/contabo/data_source_object_storage.go b/contabo/data_source_object_storage.go index 3b3926a..e799faa 100644 --- a/contabo/data_source_object_storage.go +++ b/contabo/data_source_object_storage.go @@ -16,7 +16,7 @@ func dataSourceObjectStorage() *schema.Resource { Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, - Required: true, + Optional: true, Description: "The identifier of the Object Storage. Use it to manage it!", }, "created_date": { @@ -46,26 +46,26 @@ func dataSourceObjectStorage() *schema.Resource { }, "auto_scaling": { Type: schema.TypeList, - Computed: true, + Computed: true, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "state": { Type: schema.TypeString, Computed: true, - Optional: true, + Optional: true, Description: "Status of this object storage. It can be set to `enabled`, `disabled` or `error`.", }, "size_limit_tb": { Type: schema.TypeFloat, Computed: true, - Optional: true, + Optional: true, Description: "Autoscaling size limit for the current object storage.", }, "error_message": { Type: schema.TypeString, Computed: true, - Optional: true, + Optional: true, Description: "If the autoscaling is in an error state (see status property), the error message can be seen in this field.", }, }, @@ -98,8 +98,8 @@ func dataSourceObjectStorage() *schema.Resource { }, "display_name": { Type: schema.TypeString, - Computed: true, - Description: "Display name for object storage.", + Optional: true, + Description: "Display name for object storage. Use it to manage it!", }, }, } @@ -111,33 +111,53 @@ func dataSourceObjectStorageRead( m interface{}, ) diag.Diagnostics { var diags diag.Diagnostics + client := m.(*apiClient.APIClient) - var objectStorageId string - var err error - id := d.Get("id").(string) - if id != "" { - objectStorageId = id - } + objectStorageId := d.Get("id").(string) + objectStorageDisplayName := d.Get("display_name").(string) - if err != nil { - return diag.FromErr(err) - } + if objectStorageId == "" && objectStorageDisplayName == "" { + return HandleMissingDataObjectsFilters(diags, "Missing required field", "You must provide either the `id` or `display_name` field.") + } else if objectStorageId != "" && objectStorageDisplayName != "" { + return HandleMissingDataObjectsFilters(diags, "Multiple filters provided", "You must provide only one of the following fields: `id` or `display_name`.") + } else if (objectStorageId != "") { + res, httpResp, err := client.ObjectStoragesApi.RetrieveObjectStorage(ctx, objectStorageId).XRequestId(uuid.NewV4().String()).Execute() - res, httpResp, err := client.ObjectStoragesApi.RetrieveObjectStorage(ctx, objectStorageId).XRequestId(uuid.NewV4().String()). - Execute() + if err != nil { + return HandleResponseErrors(diags, httpResp) + } - if err != nil { - return HandleResponseErrors(diags, httpResp) - } else if len(res.Data) != 1 { - return MultipleDataObjectsError(diags) - } + if(len(res.Data) == 0) { + return NoDataError(diags) + } + + d.SetId(res.Data[0].ObjectStorageId) + return AddObjectStorageToData( + res.Data[0], + d, + diags, + ) + } else if (objectStorageDisplayName != "") { + res, httpResp, err := client.ObjectStoragesApi.RetrieveObjectStorageList(ctx).XRequestId(uuid.NewV4().String()).DisplayName(objectStorageDisplayName).Execute() + + if err != nil { + return HandleResponseErrors(diags, httpResp) + } - d.SetId(res.Data[0].ObjectStorageId) + if(len(res.Data) == 0) { + return NoDataError(diags) + } else if(len(res.Data) > 1) { + return MultipleDataObjectsError(diags) + } + + d.SetId(res.Data[0].ObjectStorageId) + return AddObjectStorageToData( + res.Data[0], + d, + diags, + ) + } - return AddObjectStorageToData( - res.Data[0], - d, - diags, - ) + return nil } diff --git a/contabo/data_source_tag.go b/contabo/data_source_tag.go new file mode 100644 index 0000000..84947c0 --- /dev/null +++ b/contabo/data_source_tag.go @@ -0,0 +1,69 @@ +package contabo + +import ( + "context" + "strconv" + + apiClient "contabo.com/openapi" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + uuid "github.com/satori/go.uuid" +) + +func dataSourceTag() *schema.Resource { + return &schema.Resource{ + Description: "Tags are Customer-defined labels which can be attached to any resource in your account. Tag API represent simple CRUD functions and allow you to manage your tags. Use tags to group your resources. For example you can define some user group with tag and give them permission to create compute instance.", + ReadContext: dataSourceTagRead, + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Required: true, + Description: "The identifier of the tag. Use it to manage it!", + }, + "color": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "The tag color.", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "The tag name.", + }, + }, + } +} + +func dataSourceTagRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*apiClient.APIClient) + + var tagId int64 + var err error + id := d.Get("id").(string) + if id != "" { + tagId, err = strconv.ParseInt(id, 10, 64) + } + + if err != nil { + return diag.FromErr(err) + } + + res, httpResp, err := client.TagsApi. + RetrieveTag(ctx, tagId). + XRequestId(uuid.NewV4().String()). + Execute() + + if err != nil { + return HandleResponseErrors(diags, httpResp) + } else if len(res.Data) != 1 { + return MultipleDataObjectsError(diags) + } + + d.SetId(strconv.Itoa(int(res.Data[0].TagId))) + + return AddTagToData(res.Data[0], d, diags) +} diff --git a/contabo/data_source_tag_assignment.go b/contabo/data_source_tag_assignment.go new file mode 100644 index 0000000..35e139d --- /dev/null +++ b/contabo/data_source_tag_assignment.go @@ -0,0 +1,79 @@ +package contabo + +import ( + "context" + + apiClient "contabo.com/openapi" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + uuid "github.com/satori/go.uuid" +) + +func dataSourceTagAssignment() *schema.Resource { + return &schema.Resource{ + Description: "Tag assignment marks the specified resource with the specified tag for organizing purposes or to restrict access to that resource.", + ReadContext: dataSourceTagAssignmentRead, + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Required: true, + Description: "The identifier of the tag assignment. Use it to manage it!", + }, + "tag_id": { + Type: schema.TypeInt, + Computed: true, + Optional: true, + Description: "The identifier of the tag.", + }, + "tag_name": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the tag.", + }, + "resource_type": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "The resource type.", + }, + "resource_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "The resource id.", + }, + "resource_name": { + Type: schema.TypeString, + Computed: true, + Description: "The resource name.", + }, + }, + } +} + +func dataSourceTagAssignmentRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*apiClient.APIClient) + + id := d.Get("id").(string) + tagId := getTagIdFromId(id) + resourceType := getResourceTypeFromId(id) + resourceId := getResourceIdFromId(id) + + res, httpResp, err := client.TagAssignmentsApi. + RetrieveAssignment(context.Background(), tagId, resourceType, resourceId). + XRequestId(uuid.NewV4().String()).Execute() + if err != nil { + return HandleResponseErrors(diags, httpResp) + } + + if len(res.Data) == 0 { + return NoDataError(diags) + } else if len(res.Data) > 1 { + return MultipleDataObjectsError(diags) + } + d.SetId(id) + return AddTagAssignmentToData(res.Data[0], d, diags) + +} diff --git a/contabo/handleErrors.go b/contabo/handleErrors.go index 6dfb82b..81aac9e 100644 --- a/contabo/handleErrors.go +++ b/contabo/handleErrors.go @@ -63,6 +63,28 @@ func MultipleDataObjectsError( }) } +func NoDataError( + diags diag.Diagnostics, +) diag.Diagnostics { + return append(diags, diag.Diagnostic{ + Severity: diag.Error, + Summary: "API response returned empty data.", + Detail: "The API response returned empty data.", + }) +} + +func HandleMissingDataObjectsFilters( + diags diag.Diagnostics, + summary string, + details string, +) diag.Diagnostics { + return append(diags, diag.Diagnostic{ + Severity: diag.Error, + Summary: summary, + Detail: details, + }) +} + func HandleDownloadErrors( diags diag.Diagnostics, ) diag.Diagnostics { diff --git a/contabo/provider.go b/contabo/provider.go index 933b815..e584581 100644 --- a/contabo/provider.go +++ b/contabo/provider.go @@ -65,6 +65,8 @@ func Provider() *schema.Provider { "contabo_secret": resourceSecret(), "contabo_private_network": resourcePrivateNetwork(), "contabo_object_storage_bucket": resourceObjectStorageBucket(), + "contabo_tag": resourceTag(), + "contabo_tag_assignment": resourceTagAssignment(), }, DataSourcesMap: map[string]*schema.Resource{ "contabo_instance": dataSourceInstance(), @@ -74,6 +76,8 @@ func Provider() *schema.Provider { "contabo_secret": dataSourceSecret(), "contabo_private_network": dataSourcePrivateNetwork(), "contabo_object_storage_bucket": dataSourceObjectStorageBucket(), + "contabo_tag": dataSourceTag(), + "contabo_tag_assignment": dataSourceTagAssignment(), }, ConfigureContextFunc: providerConfigure, } diff --git a/contabo/resource_tag.go b/contabo/resource_tag.go new file mode 100644 index 0000000..160fc16 --- /dev/null +++ b/contabo/resource_tag.go @@ -0,0 +1,200 @@ +package contabo + +import ( + "context" + "strconv" + + "contabo.com/openapi" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + uuid "github.com/satori/go.uuid" +) + +func resourceTag() *schema.Resource { + return &schema.Resource{ + Description: "Tags are Customer-defined labels which can be attached to any resource in your account. Tag API represent simple CRUD functions and allow you to manage your tags. Use tags to group your resources. For example you can define some user group with tag and give them permission to create compute instances.", + CreateContext: resourceTagCreate, + ReadContext: resourceTagRead, + UpdateContext: resourceTagUpdate, + DeleteContext: resourceTagDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The identifier of the tag. Use it to manage it!", + }, + "color": { + Type: schema.TypeString, + Required: true, + Description: "The tag color.", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "The tag name.", + }, + }, + } +} + +func resourceTagCreate( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*openapi.APIClient) + + tagName := d.Get("name").(string) + tagColor := d.Get("color").(string) + + createTagRequest := openapi.NewCreateTagRequestWithDefaults() + createTagRequest.Name = tagName + createTagRequest.Color = tagColor + + res, httpResp, err := client.TagsApi. + CreateTag(context.Background()). + XRequestId(uuid.NewV4().String()). + CreateTagRequest(*createTagRequest). + Execute() + + if err != nil { + return HandleResponseErrors(diags, httpResp) + } + + if len(res.Data) == 0 { + return NoDataError(diags) + } else if len(res.Data) > 1 { + return MultipleDataObjectsError(diags) + } + + d.SetId(strconv.Itoa(int(res.Data[0].TagId))) + return resourceTagRead(ctx, d, m) +} + +func resourceTagRead( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*openapi.APIClient) + + tagId, err := strconv.ParseInt(d.Id(), 10, 64) + + if err != nil { + return diag.FromErr(err) + } + + res, httpResp, err := client.TagsApi. + RetrieveTag(ctx, tagId). + XRequestId(uuid.NewV4().String()). + Execute() + + if err != nil { + return HandleResponseErrors(diags, httpResp) + } + + if len(res.Data) != 1 { + return append(diags, diag.Diagnostic{ + Severity: diag.Error, + Summary: "Internal Error: should have returned only one object", + }) + } + + return AddTagToData(res.Data[0], d, diags) +} + +func resourceTagUpdate( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*openapi.APIClient) + + tagId, err := strconv.ParseInt(d.Id(), 10, 64) + + if err != nil { + return diag.FromErr(err) + } + + updateTagRequest := openapi.NewUpdateTagRequestWithDefaults() + anyChange := false + + if d.HasChange("name") { + tagName := d.Get("name").(string) + updateTagRequest.Name = &tagName + anyChange = true + } + + if d.HasChange("color") { + tagColor := d.Get("color").(string) + updateTagRequest.Color = &tagColor + anyChange = true + } + + if anyChange { + _, httpResp, err := client.TagsApi. + UpdateTag(context.Background(), tagId). + XRequestId(uuid.NewV4().String()). + UpdateTagRequest(*updateTagRequest). + Execute() + + if err != nil { + return HandleResponseErrors(diags, httpResp) + } + return resourceTagRead(ctx, d, m) + } + + return diags +} + +func resourceTagDelete( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*openapi.APIClient) + + tagId, err := strconv.ParseInt(d.Id(), 10, 64) + + if err != nil { + return diag.FromErr(err) + } + + httpResp, err := client.TagsApi. + DeleteTag(ctx, tagId). + XRequestId(uuid.NewV4().String()). + Execute() + + if err != nil { + return HandleResponseErrors(diags, httpResp) + } + + d.SetId("") + + return diags +} + +func AddTagToData( + tag openapi.TagResponse, + d *schema.ResourceData, + diags diag.Diagnostics, +) diag.Diagnostics { + id := strconv.Itoa(int(tag.TagId)) + if err := d.Set("id", id); err != nil { + return diag.FromErr(err) + } + if err := d.Set("name", tag.Name); err != nil { + return diag.FromErr(err) + } + if err := d.Set("color", tag.Color); err != nil { + return diag.FromErr(err) + } + return diags +} diff --git a/contabo/resource_tag_assignment.go b/contabo/resource_tag_assignment.go new file mode 100644 index 0000000..702dead --- /dev/null +++ b/contabo/resource_tag_assignment.go @@ -0,0 +1,187 @@ +package contabo + +import ( + "context" + + "strconv" + "strings" + + "contabo.com/openapi" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + uuid "github.com/satori/go.uuid" +) + +func resourceTagAssignment() *schema.Resource { + return &schema.Resource{ + Description: "Tag assignment marks the specified resource with the specified tag for organizing purposes or to restrict access to that resource.", + CreateContext: resourceTagAssignmentCreate, + ReadContext: resourceTagAssignmentRead, + DeleteContext: resourceTagAssignmentDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The identifier of the tag assignment. Use it to manage it!", + }, + "tag_id": { + Type: schema.TypeInt, + Computed: true, + Optional: true, + Description: "The identifier of the tag.", + }, + "tag_name": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the tag.", + }, + "resource_type": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "The resource type.", + }, + "resource_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "The resource id.", + }, + "resource_name": { + Type: schema.TypeString, + Computed: true, + Description: "The resource name.", + }, + }, + } +} + +func generateTagAssignmentId(tagIdString string, resourceType string, resourceId string) string { + return tagIdString + "_" + resourceType + "_" + resourceId +} + +func getTagIdFromId(tagAssignmentId string) int64 { + tagIdString := strings.Split(tagAssignmentId, "_")[0] + var tagId int64 + if tagIdString != "" { + tagId, _ = strconv.ParseInt(tagIdString, 10, 64) + } + return tagId +} + +func getResourceTypeFromId(tagAssignmentId string) string { + resourceType := strings.Split(tagAssignmentId, "_")[1] + return resourceType +} + +func getResourceIdFromId(tagAssignmentId string) string { + resourceId := strings.Split(tagAssignmentId, "_")[2] + return resourceId +} + +func resourceTagAssignmentCreate( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*openapi.APIClient) + + tagId := d.Get("tag_id").(int) + resourceType := d.Get("resource_type").(string) + resourceId := d.Get("resource_id").(string) + + _, httpResp, err := client.TagAssignmentsApi. + CreateAssignment(context.Background(), int64(tagId), resourceType, resourceId). + XRequestId(uuid.NewV4().String()).Execute() + if err != nil { + return HandleResponseErrors(diags, httpResp) + } + id := generateTagAssignmentId(strconv.Itoa(int(tagId)), resourceType, resourceId) + d.SetId(id) + return resourceTagAssignmentRead(ctx, d, m) +} + +func resourceTagAssignmentRead( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*openapi.APIClient) + + tagId := getTagIdFromId(d.Id()) + resourceType := getResourceTypeFromId(d.Id()) + resourceId := getResourceIdFromId(d.Id()) + + res, httpResp, err := client.TagAssignmentsApi. + RetrieveAssignment(context.Background(), tagId, resourceType, resourceId). + XRequestId(uuid.NewV4().String()).Execute() + if err != nil { + return HandleResponseErrors(diags, httpResp) + } + + if len(res.Data) == 0 { + return NoDataError(diags) + } else if len(res.Data) > 1 { + return MultipleDataObjectsError(diags) + } + + return AddTagAssignmentToData(res.Data[0], d, diags) +} + +func resourceTagAssignmentDelete( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*openapi.APIClient) + + tagId := getTagIdFromId(d.Id()) + resourceType := getResourceTypeFromId(d.Id()) + resourceId := getResourceIdFromId(d.Id()) + + httpResp, err := client.TagAssignmentsApi. + DeleteAssignment(context.Background(), tagId, resourceType, resourceId). + XRequestId(uuid.NewV4().String()).Execute() + + if err != nil { + return HandleResponseErrors(diags, httpResp) + } + + d.SetId("") + + return diags +} + +func AddTagAssignmentToData( + tagAssignment openapi.AssignmentResponse, + d *schema.ResourceData, + diags diag.Diagnostics, +) diag.Diagnostics { + + id := generateTagAssignmentId(strconv.Itoa(int(tagAssignment.TagId)), tagAssignment.ResourceType, tagAssignment.ResourceId) + if err := d.Set("id", id); err != nil { + return diag.FromErr(err) + } + if err := d.Set("tag_id", tagAssignment.TagId); err != nil { + return diag.FromErr(err) + } + if err := d.Set("tag_name", tagAssignment.TagName); err != nil { + return diag.FromErr(err) + } + if err := d.Set("resource_id", tagAssignment.ResourceId); err != nil { + return diag.FromErr(err) + } + if err := d.Set("resource_type", tagAssignment.ResourceType); err != nil { + return diag.FromErr(err) + } + if err := d.Set("resource_name", tagAssignment.ResourceName); err != nil { + return diag.FromErr(err) + } + return diags +} diff --git a/docs/data-sources/contabo_image.md b/docs/data-sources/contabo_image.md index 5b6cff8..164765b 100644 --- a/docs/data-sources/contabo_image.md +++ b/docs/data-sources/contabo_image.md @@ -10,7 +10,27 @@ description: |- In order to provide a custom image, please specify an URL from which the image can be downloaded directly. A custom image must be in either `.iso` or `.qcow2` format. Other formats will be rejected. Please note that downloading can take a while depending on network speed resp. bandwidth and size of image. You can check the status by retrieving information about the image via a GET request. Download will be rejected if you have exceeded your limits. - +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific image by ID +data "contabo_image" "debian_11" { + id = "66abf39a-ba8b-425e-a385-8eb347ceac10" +} + +output "my_test_image" { + description = "my test image" + value = data.contabo_image.debian_11 +} +``` ## Schema diff --git a/docs/data-sources/contabo_instance.md b/docs/data-sources/contabo_instance.md index aad1d7d..87e1abc 100644 --- a/docs/data-sources/contabo_instance.md +++ b/docs/data-sources/contabo_instance.md @@ -10,7 +10,27 @@ description: |- The Compute Management API allows you to manage compute resources (e.g. creation, deletion, starting, stopping) as well as managing snapshots and custom images. It also supports [cloud-init](https://cloud-init.io/) at least on our default images (for custom images you will need to provide cloud-init support packages). The API offers providing cloud-init scripts via the user_data field. Custom images must be provided in .qcow2 or .iso format. - +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific instance by ID +data "contabo_instance" "test_instance" { + id = "123455" +} + +output "my_test_instance" { + description = "my test instance" + value = data.contabo_instance.test_instance +} +``` ## Schema diff --git a/docs/data-sources/contabo_instance_snapshot.md b/docs/data-sources/contabo_instance_snapshot.md index 95dae09..a08ae5d 100644 --- a/docs/data-sources/contabo_instance_snapshot.md +++ b/docs/data-sources/contabo_instance_snapshot.md @@ -10,7 +10,27 @@ description: |- - +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific instance snapshot by ID +data "contabo_instance_snapshot" "test_snapshot" { + id = "66abf39a-ba8b-425e-a385-8eb347ceac10" +} + +output "my_test_snapshot" { + description = "my test snapshot" + value = data.contabo_instance_snapshot.test_snapshot +} +``` ## Schema diff --git a/docs/data-sources/contabo_object_storage.md b/docs/data-sources/contabo_object_storage.md index 537faf3..ab815ce 100644 --- a/docs/data-sources/contabo_object_storage.md +++ b/docs/data-sources/contabo_object_storage.md @@ -10,18 +10,46 @@ description: |- Manage S3 compatible Object Storage. With the Object Storage API you can create Object Storages in different locations. Please note that you can only have one Object Storage per location. Furthermore, you can increase the amount of storage space and control the autoscaling feature which allows you to automatically perform a monthly upgrade of the disk space to the specified maximum. You might also inspect the usage. This API is not the S3 API itself. For accessing the S3 API directly or with S3 compatible tools like `aws` cli and after having created / upgraded your Object Storage please use the S3 URL from this Storage API and refer to the User Mangement API to retrieve the S3 credentials. +## Example Usage +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} - -## Schema +# Search object storage by ID +data "contabo_object_storage" "example1" { + id = "3a6e5301-fc71-42ce-b60c-49841681c2da" +} -### Required +# Search object storage by display name +data "contabo_object_storage" "example2" { + display_name = "example2" +} -- `id` (String) The identifier of the Object Storage. Use it to manage it! +output "my_object_storage1" { + description = "my object storage 1" + value = data.contabo_object_storage.example1 +} + +output "my_object_storage2" { + description = "my object storage 2" + value = data.contabo_object_storage.example1 +} +``` + + +## Schema ### Optional - `auto_scaling` (Block List) (see [below for nested schema](#nestedblock--auto_scaling)) +- `display_name` (String) Display name for object storage. Use it to manage it! +- `id` (String) The identifier of the Object Storage. Use it to manage it! ### Read-Only @@ -29,7 +57,6 @@ Manage S3 compatible Object Storage. With the Object Storage API you can create - `created_date` (String) The creation date of the Object Storage. - `customer_id` (String) Your customer number. - `data_center` (String) Data center the object storage is located in. -- `display_name` (String) Display name for object storage. - `region` (String) Region where the Object Storage should be located. Default region is the EU. Following regions are available: `EU`,`US-central`, `SIN`. - `s3_tenant_id` (String) Your S3 tenant Id. Only required for public sharing. - `s3_url` (String) S3 URL to connect to your S3 compatible Object Storage. diff --git a/docs/data-sources/contabo_object_storage_bucket.md b/docs/data-sources/contabo_object_storage_bucket.md index 7258d3f..751e76c 100644 --- a/docs/data-sources/contabo_object_storage_bucket.md +++ b/docs/data-sources/contabo_object_storage_bucket.md @@ -10,7 +10,28 @@ description: |- Manage buckets on your contabo Object Storage. With this resource you are able to manage your buckets the same way your are able to manage them in your contabo customer panel. - +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search object storage bucket by Object Storage ID and name +data "contabo_object_storage_bucket" "bucket1" { + object_storage_id = "3a6e5301-fc71-42ce-b60c-49841681c2da" + name = "testbucket" +} + +output "my_test_bucket" { + description = "my test bucket" + value = data.contabo_object_storage_bucket.bucket1 +} +``` ## Schema diff --git a/docs/data-sources/contabo_private_network.md b/docs/data-sources/contabo_private_network.md index 6a409f7..3207af3 100644 --- a/docs/data-sources/contabo_private_network.md +++ b/docs/data-sources/contabo_private_network.md @@ -10,7 +10,27 @@ description: |- Provides a Contabo [Private Network](https://api.contabo.com/#tag/Private-Networks) data source. Private Networks can contain your compute instances whereby they are able to communicate with each other in full usolation, using private IP addresses - +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific private network by ID +data "contabo_private_network" "testnetwork" { + id = "1234" +} + +output "my_test_private_network" { + description = "my test private network" + value = data.contabo_private_network.testnetwork +} +``` ## Schema diff --git a/docs/data-sources/contabo_secret.md b/docs/data-sources/contabo_secret.md index 37e7bf3..61ee7e8 100644 --- a/docs/data-sources/contabo_secret.md +++ b/docs/data-sources/contabo_secret.md @@ -10,7 +10,27 @@ description: |- The Secret Management API allows you to store and manage your passwords and ssh-keys. Usage of the Secret Management API is purely optional. As a convenience feature e.g. it allows you to reuse SSH-keys easily. - +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific secret by ID +data "contabo_secret" "mysecret" { + id = "123" +} + +output "my_secret_output" { + description = "my secret" + value = data.contabo_secret.mysecret +} +``` ## Schema diff --git a/docs/data-sources/contabo_tag.md b/docs/data-sources/contabo_tag.md new file mode 100644 index 0000000..4abb0fd --- /dev/null +++ b/docs/data-sources/contabo_tag.md @@ -0,0 +1,44 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "contabo_tag Data Source - terraform-provider-contabo-sdkv2" +subcategory: "" +description: |- + Tags are Customer-defined labels which can be attached to any resource in your account. Tag API represent simple CRUD functions and allow you to manage your tags. Use tags to group your resources. For example you can define some user group with tag and give them permission to create compute instance. +--- + +# contabo_tag (Data Source) + +Tags are Customer-defined labels which can be attached to any resource in your account. Tag API represent simple CRUD functions and allow you to manage your tags. Use tags to group your resources. For example you can define some user group with tag and give them permission to create compute instance. + +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Get a specific tag by ID +data "contabo_tag" "default_tag" { + id="26878" +} +output "output" { + description = "output" + value = data.contabo_tag.default_tag +} +``` + + +## Schema + +### Required + +- `id` (String) The identifier of the tag. Use it to manage it! + +### Optional + +- `color` (String) The tag color. +- `name` (String) The tag name. diff --git a/docs/data-sources/contabo_tag_assignment.md b/docs/data-sources/contabo_tag_assignment.md new file mode 100644 index 0000000..1a2e82e --- /dev/null +++ b/docs/data-sources/contabo_tag_assignment.md @@ -0,0 +1,51 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "contabo_tag_assignment Data Source - terraform-provider-contabo-sdkv2" +subcategory: "" +description: |- + Tag assignment marks the specified resource with the specified tag for organizing purposes or to restrict access to that resource. +--- + +# contabo_tag_assignment (Data Source) + +Tag assignment marks the specified resource with the specified tag for organizing purposes or to restrict access to that resource. + +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Get a specific tag assignment by tagId_resourceType_resourceId +data "contabo_tag_assignment" "default_tag_assignment" { + id = "178478_image_35ee288f-21ea-420c-a074-ce0a968b59c0" +} + +output "output" { + description = "output" + value = data.contabo_tag_assignment.default_tag_assignment +} +``` + + +## Schema + +### Required + +- `id` (String) The identifier of the tag assignment. Use it to manage it! + +### Optional + +- `resource_id` (String) The resource id. +- `resource_type` (String) The resource type. +- `tag_id` (Number) The identifier of the tag. + +### Read-Only + +- `resource_name` (String) The resource name. +- `tag_name` (String) The name of the tag. diff --git a/docs/guides/custom_instance.md b/docs/guides/custom_instance.md index 3338dd3..fb6c09e 100644 --- a/docs/guides/custom_instance.md +++ b/docs/guides/custom_instance.md @@ -12,7 +12,7 @@ terraform { required_providers { contabo = { source = "contabo/contabo" - version = "__CURRENT_VERSION__" + version = ">= 0.1.26" } } } diff --git a/docs/guides/use_environment_variables.md b/docs/guides/use_environment_variables.md index a72cc36..7ca2178 100644 --- a/docs/guides/use_environment_variables.md +++ b/docs/guides/use_environment_variables.md @@ -12,7 +12,7 @@ terraform { required_providers { contabo = { source = "contabo/contabo" - version = "__CURRENT_VERSION__" + version = ">= 0.1.26" } } } diff --git a/docs/index.md b/docs/index.md index 45c8c2b..52f0f33 100644 --- a/docs/index.md +++ b/docs/index.md @@ -18,7 +18,7 @@ terraform { required_providers { contabo = { source = "contabo/contabo" - version = "__CURRENT_VERSION__" + version = ">= 0.1.26" } } } diff --git a/docs/resources/contabo_object_storage_bucket.md b/docs/resources/contabo_object_storage_bucket.md index dab625e..ef96066 100644 --- a/docs/resources/contabo_object_storage_bucket.md +++ b/docs/resources/contabo_object_storage_bucket.md @@ -10,7 +10,6 @@ description: |- Manage buckets on your contabo Object Storage. With this resource you are able to manage your buckets the same way your are able to manage them in your contabo customer panel. - ## Example Usage ```terraform diff --git a/docs/resources/contabo_tag.md b/docs/resources/contabo_tag.md new file mode 100644 index 0000000..6342c5a --- /dev/null +++ b/docs/resources/contabo_tag.md @@ -0,0 +1,47 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "contabo_tag Resource - terraform-provider-contabo-sdkv2" +subcategory: "" +description: |- + Tags are Customer-defined labels which can be attached to any resource in your account. Tag API represent simple CRUD functions and allow you to manage your tags. Use tags to group your resources. For example you can define some user group with tag and give them permission to create compute instances. +--- + +# contabo_tag (Resource) + +Tags are Customer-defined labels which can be attached to any resource in your account. Tag API represent simple CRUD functions and allow you to manage your tags. Use tags to group your resources. For example you can define some user group with tag and give them permission to create compute instances. + +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Create a new tag +resource "contabo_tag" "default_tag" { + color = "#000002" + name="NewTag" +} + +# Update an existing tag +resource "contabo_tag" "default_tag" { + color = "#ffffff" + name = "UpdatedTag" +} +``` + + +## Schema + +### Required + +- `color` (String) The tag color. +- `name` (String) The tag name. + +### Read-Only + +- `id` (String) The identifier of the tag. Use it to manage it! diff --git a/docs/resources/contabo_tag_assignment.md b/docs/resources/contabo_tag_assignment.md new file mode 100644 index 0000000..b573f93 --- /dev/null +++ b/docs/resources/contabo_tag_assignment.md @@ -0,0 +1,45 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "contabo_tag_assignment Resource - terraform-provider-contabo-sdkv2" +subcategory: "" +description: |- + Tag assignment marks the specified resource with the specified tag for organizing purposes or to restrict access to that resource. +--- + +# contabo_tag_assignment (Resource) + +Tag assignment marks the specified resource with the specified tag for organizing purposes or to restrict access to that resource. + +## Example Usage + +```terraform +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Create a new tag assignment +resource "contabo_tag_assignment" "default_tag_assignment" { + tag_id = "178478" + resource_type = "image" + resource_id = "35ee288f-21ea-420c-a074-ce0a968b59c0" +} +``` + + +## Schema + +### Optional + +- `resource_id` (String) The resource id. +- `resource_type` (String) The resource type. +- `tag_id` (Number) The identifier of the tag. + +### Read-Only + +- `id` (String) The identifier of the tag assignment. Use it to manage it! +- `resource_name` (String) The resource name. +- `tag_name` (String) The name of the tag. diff --git a/examples/custom_instance/custom_instance.tf b/examples/custom_instance/custom_instance.tf index e6ec2bf..76aafb4 100644 --- a/examples/custom_instance/custom_instance.tf +++ b/examples/custom_instance/custom_instance.tf @@ -2,7 +2,7 @@ terraform { required_providers { contabo = { source = "contabo/contabo" - version = ">= 0.1.25" + version = ">= 0.1.26" } } } diff --git a/examples/data-sources/contabo_image/data-source.tf b/examples/data-sources/contabo_image/data-source.tf new file mode 100644 index 0000000..5488f1e --- /dev/null +++ b/examples/data-sources/contabo_image/data-source.tf @@ -0,0 +1,17 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific image by ID +data "contabo_image" "debian_11" { + id = "66abf39a-ba8b-425e-a385-8eb347ceac10" +} + +output "my_test_image" { + description = "my test image" + value = data.contabo_image.debian_11 +} \ No newline at end of file diff --git a/examples/data-sources/contabo_instance/data-source.tf b/examples/data-sources/contabo_instance/data-source.tf new file mode 100644 index 0000000..084dbd8 --- /dev/null +++ b/examples/data-sources/contabo_instance/data-source.tf @@ -0,0 +1,17 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific instance by ID +data "contabo_instance" "test_instance" { + id = "123455" +} + +output "my_test_instance" { + description = "my test instance" + value = data.contabo_instance.test_instance +} \ No newline at end of file diff --git a/examples/data-sources/contabo_instance_snapshot/data-source.tf b/examples/data-sources/contabo_instance_snapshot/data-source.tf new file mode 100644 index 0000000..7fd3cd5 --- /dev/null +++ b/examples/data-sources/contabo_instance_snapshot/data-source.tf @@ -0,0 +1,17 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific instance snapshot by ID +data "contabo_instance_snapshot" "test_snapshot" { + id = "66abf39a-ba8b-425e-a385-8eb347ceac10" +} + +output "my_test_snapshot" { + description = "my test snapshot" + value = data.contabo_instance_snapshot.test_snapshot +} \ No newline at end of file diff --git a/examples/data-sources/contabo_object_storage/data-source.tf b/examples/data-sources/contabo_object_storage/data-source.tf new file mode 100644 index 0000000..4b23e35 --- /dev/null +++ b/examples/data-sources/contabo_object_storage/data-source.tf @@ -0,0 +1,27 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search object storage by ID +data "contabo_object_storage" "example1" { + id = "3a6e5301-fc71-42ce-b60c-49841681c2da" +} + +# Search object storage by display name +data "contabo_object_storage" "example2" { + display_name = "example2" +} + +output "my_object_storage1" { + description = "my object storage 1" + value = data.contabo_object_storage.example1 +} + +output "my_object_storage2" { + description = "my object storage 2" + value = data.contabo_object_storage.example1 +} diff --git a/examples/data-sources/contabo_object_storage_bucket/data-source.tf b/examples/data-sources/contabo_object_storage_bucket/data-source.tf new file mode 100644 index 0000000..c762e92 --- /dev/null +++ b/examples/data-sources/contabo_object_storage_bucket/data-source.tf @@ -0,0 +1,18 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search object storage bucket by Object Storage ID and name +data "contabo_object_storage_bucket" "bucket1" { + object_storage_id = "3a6e5301-fc71-42ce-b60c-49841681c2da" + name = "testbucket" +} + +output "my_test_bucket" { + description = "my test bucket" + value = data.contabo_object_storage_bucket.bucket1 +} \ No newline at end of file diff --git a/examples/data-sources/contabo_private_network/data-source.tf b/examples/data-sources/contabo_private_network/data-source.tf new file mode 100644 index 0000000..8e4a467 --- /dev/null +++ b/examples/data-sources/contabo_private_network/data-source.tf @@ -0,0 +1,17 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific private network by ID +data "contabo_private_network" "testnetwork" { + id = "1234" +} + +output "my_test_private_network" { + description = "my test private network" + value = data.contabo_private_network.testnetwork +} \ No newline at end of file diff --git a/examples/data-sources/contabo_secret/data-source.tf b/examples/data-sources/contabo_secret/data-source.tf new file mode 100644 index 0000000..6e1cc5f --- /dev/null +++ b/examples/data-sources/contabo_secret/data-source.tf @@ -0,0 +1,17 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Search for a specific secret by ID +data "contabo_secret" "mysecret" { + id = "123" +} + +output "my_secret_output" { + description = "my secret" + value = data.contabo_secret.mysecret +} \ No newline at end of file diff --git a/examples/data-sources/contabo_tag/data-source.tf b/examples/data-sources/contabo_tag/data-source.tf new file mode 100644 index 0000000..00926d9 --- /dev/null +++ b/examples/data-sources/contabo_tag/data-source.tf @@ -0,0 +1,16 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Get a specific tag by ID +data "contabo_tag" "default_tag" { + id="26878" +} +output "output" { + description = "output" + value = data.contabo_tag.default_tag +} \ No newline at end of file diff --git a/examples/data-sources/contabo_tag_assignment/data-source.tf b/examples/data-sources/contabo_tag_assignment/data-source.tf new file mode 100644 index 0000000..ed72aa9 --- /dev/null +++ b/examples/data-sources/contabo_tag_assignment/data-source.tf @@ -0,0 +1,17 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Get a specific tag assignment by tagId_resourceType_resourceId +data "contabo_tag_assignment" "default_tag_assignment" { + id = "178478_image_35ee288f-21ea-420c-a074-ce0a968b59c0" +} + +output "output" { + description = "output" + value = data.contabo_tag_assignment.default_tag_assignment +} \ No newline at end of file diff --git a/examples/main.tf.example b/examples/main.tf.example index 5adf43e..85fca0e 100644 --- a/examples/main.tf.example +++ b/examples/main.tf.example @@ -2,7 +2,7 @@ terraform { required_providers { contabo = { source = "contabo/contabo" - version = ">= 0.1.25" + version = ">= 0.1.26" } } } diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index a6b0e0b..c1df3d1 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { contabo = { source = "contabo/contabo" - version = ">= 0.1.25" + version = ">= 0.1.26" } } } diff --git a/examples/resources/contabo_object_storage_bucket/resource.tf b/examples/resources/contabo_object_storage_bucket/resource.tf new file mode 100644 index 0000000..1bb3466 --- /dev/null +++ b/examples/resources/contabo_object_storage_bucket/resource.tf @@ -0,0 +1,19 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Create a new object storage +resource "contabo_object_storage" "example_object_storage" { + region = "EU" + total_purchased_space_tb = 0.500 +} + +# create a bucket in the object_storage +resource "contabo_object_storage_bucket" "example_bucket" { + name = "example_bucket" + object_storage_id = contabo_object_storage.example_object_storage.id +} \ No newline at end of file diff --git a/examples/resources/contabo_tag/resource.tf b/examples/resources/contabo_tag/resource.tf new file mode 100644 index 0000000..35b558e --- /dev/null +++ b/examples/resources/contabo_tag/resource.tf @@ -0,0 +1,19 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Create a new tag +resource "contabo_tag" "default_tag" { + color = "#000002" + name="NewTag" +} + +# Update an existing tag +resource "contabo_tag" "default_tag" { + color = "#ffffff" + name = "UpdatedTag" +} \ No newline at end of file diff --git a/examples/resources/contabo_tag_assignment/resource.tf b/examples/resources/contabo_tag_assignment/resource.tf new file mode 100644 index 0000000..680841a --- /dev/null +++ b/examples/resources/contabo_tag_assignment/resource.tf @@ -0,0 +1,14 @@ +# Configure your Contabo API credentials +provider "contabo" { + oauth2_client_id = "[your client id]" + oauth2_client_secret = "[your client secret]" + oauth2_user = "[your username]" + oauth2_pass = "[your password]" +} + +# Create a new tag assignment +resource "contabo_tag_assignment" "default_tag_assignment" { + tag_id = "178478" + resource_type = "image" + resource_id = "35ee288f-21ea-420c-a074-ce0a968b59c0" +} \ No newline at end of file diff --git a/examples/use_environment_variables/use_environment_variables.tf b/examples/use_environment_variables/use_environment_variables.tf index a4875c0..5b95c7a 100644 --- a/examples/use_environment_variables/use_environment_variables.tf +++ b/examples/use_environment_variables/use_environment_variables.tf @@ -2,7 +2,7 @@ terraform { required_providers { contabo = { source = "contabo/contabo" - version = ">= 0.1.25" + version = ">= 0.1.26" } } }