Skip to content

Commit

Permalink
Improve image examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ftersin committed Jul 24, 2023
1 parent d2eee4a commit 3ecd924
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 24 deletions.
8 changes: 0 additions & 8 deletions examples/images/image/datasource/main-properties.tf

This file was deleted.

10 changes: 8 additions & 2 deletions examples/images/image/datasource/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
data "vkcs_images_image" "debian" {
name = "Debian11.4"
most_recent = true
# Both arguments are required to search an actual image provided by VKCS.
visibility = "public"
default = true
# Use properties to distinguish between available images.
properties = {
mcs_os_distro = "debian"
mcs_os_version = "10.1"
}
}
12 changes: 12 additions & 0 deletions examples/images/image/main-datasource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
data "vkcs_images_image" "eurolinux9" {
tag = "tf-example"
# Useful if you keep old versions of your images.
most_recent = true
properties = {
mcs_os_distro = "eurolinux"
mcs_os_version = "9"
}
# This is unnecessary in real life.
# This is required here to let the example work with image resource example.
depends_on = [ vkcs_images_image.eurolinux9 ]
}
25 changes: 25 additions & 0 deletions examples/images/image/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "vkcs_images_image" "eurolinux9" {
name = "eurolinux9-tf-example"
image_source_url = "https://fbi.cdn.euro-linux.com/images/EL-9-cloudgeneric-2023-03-19.raw.xz"
# compression_format should be set for compressed image source.
compression_format = "xz"
container_format = "bare"
disk_format = "raw"
# Minimal requirements from image vendor.
# Should be set to prevent VKCS to build VM on lesser resources.
min_ram_mb = 1536
min_disk_gb = 10

properties = {
# Refer to https://mcs.mail.ru/docs/en/base/iaas/instructions/vm-images/vm-image-metadata
os_type = "linux"
os_admin_user = "root"
mcs_name = "EuroLinux 9"
mcs_os_distro = "eurolinux"
mcs_os_version = "9"
hw_qemu_guest_agent = "yes"
os_require_quiesce = "yes"
}
# Use tags to organize your images.
tags = ["tf-example"]
}
1 change: 1 addition & 0 deletions examples/images/images/datasource/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
data "vkcs_images_images" "images" {
visibility = "public"
default = true
properties = {
mcs_os_distro = "debian"
}
Expand Down
4 changes: 3 additions & 1 deletion templates/image/data-sources/vkcs_images_image.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ description: |-
{{ .Description }}

## Example Usage

### VKCS provided image
{{tffile "examples/images/image/datasource/main.tf"}}
### User image
{{tffile "examples/images/image/main-datasource.tf"}}

{{ .SchemaMarkdown }}
2 changes: 1 addition & 1 deletion templates/image/data-sources/vkcs_images_images.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: "vkcs"
page_title: "vkcs: {{.Name}}"
description: |-
Get information on images available within VKCS.
Get information on available VKCS images
---

# {{.Name}}
Expand Down
6 changes: 6 additions & 0 deletions templates/image/resources/vkcs_images_image.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ description: |-
## Notes
### Properties

See the following [reference](https://mcs.mail.ru/docs/en/base/iaas/instructions/vm-images/vm-image-metadata)
for important supported properties.

This resource supports the ability to add properties to a resource during creation as well as add, update, and delete properties during an update of this resource.

VKCS Image service is adding some read-only properties (such as `direct_url`, `store`) to each image.
This resource automatically reconciles these properties with the user-provided properties.

## Import

Images can be imported using the `id`, e.g.
Expand Down
10 changes: 0 additions & 10 deletions templates/image/resources/vkcs_images_image/main.tf

This file was deleted.

4 changes: 2 additions & 2 deletions vkcs/images/resource_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ func ResourceImagesImage() *schema.Resource {
Optional: true,
ValidateFunc: validation.IntAtLeast(0),
Default: 0,
Description: "Amount of disk space (in GB) required to boot image. Defaults to 0.",
Description: "Amount of disk space (in GB) required to boot VM. Defaults to 0.",
},

"min_ram_mb": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(0),
Default: 0,
Description: "Amount of ram (in MB) required to boot image. Defauts to 0.",
Description: "Amount of ram (in MB) required to boot VM. Defauts to 0.",
},

"name": {
Expand Down

0 comments on commit 3ecd924

Please sign in to comment.