From fb8566e9643fbabbba9f954bdd186d932307d1e1 Mon Sep 17 00:00:00 2001 From: Vitaliy Natarov Date: Thu, 16 Jan 2025 18:27:20 +0100 Subject: [PATCH] Add module + example --- oracle_cloud/examples/core_volume/README.md | 274 +++++++- oracle_cloud/examples/core_volume/main.tf | 4 + .../modules/core_volume/boot_volume.tf | 91 +++ .../modules/core_volume/boot_volume_backup.tf | 40 ++ oracle_cloud/modules/core_volume/outputs.tf | 616 ++++++++++++++++++ oracle_cloud/modules/core_volume/variables.tf | 514 +++++++++++++++ oracle_cloud/modules/core_volume/volume.tf | 92 +++ .../modules/core_volume/volume_attachment.tf | 39 ++ .../modules/core_volume/volume_backup.tf | 40 ++ .../core_volume/volume_backup_policy.tf | 60 ++ .../volume_backup_policy_assignment.tf | 31 + .../modules/core_volume/volume_group.tf | 68 ++ .../core_volume/volume_group_backup.tf | 40 ++ .../modules/core_volumes/boot_volume.tf | 5 - .../core_volumes/boot_volume_backup.tf | 5 - oracle_cloud/modules/core_volumes/outputs.tf | 3 - .../modules/core_volumes/variables.tf | 17 - oracle_cloud/modules/core_volumes/volume.tf | 5 - .../modules/core_volumes/volume_attachment.tf | 5 - .../modules/core_volumes/volume_backup.tf | 5 - .../core_volumes/volume_backup_policy.tf | 5 - .../volume_backup_policy_assignment.tf | 5 - .../modules/core_volumes/volume_group.tf | 5 - .../core_volumes/volume_group_backup.tf | 5 - 24 files changed, 1907 insertions(+), 67 deletions(-) create mode 100644 oracle_cloud/modules/core_volume/boot_volume.tf create mode 100644 oracle_cloud/modules/core_volume/boot_volume_backup.tf create mode 100644 oracle_cloud/modules/core_volume/outputs.tf create mode 100644 oracle_cloud/modules/core_volume/variables.tf create mode 100644 oracle_cloud/modules/core_volume/volume.tf create mode 100644 oracle_cloud/modules/core_volume/volume_attachment.tf create mode 100644 oracle_cloud/modules/core_volume/volume_backup.tf create mode 100644 oracle_cloud/modules/core_volume/volume_backup_policy.tf create mode 100644 oracle_cloud/modules/core_volume/volume_backup_policy_assignment.tf create mode 100644 oracle_cloud/modules/core_volume/volume_group.tf create mode 100644 oracle_cloud/modules/core_volume/volume_group_backup.tf delete mode 100644 oracle_cloud/modules/core_volumes/boot_volume.tf delete mode 100644 oracle_cloud/modules/core_volumes/boot_volume_backup.tf delete mode 100644 oracle_cloud/modules/core_volumes/outputs.tf delete mode 100644 oracle_cloud/modules/core_volumes/variables.tf delete mode 100644 oracle_cloud/modules/core_volumes/volume.tf delete mode 100644 oracle_cloud/modules/core_volumes/volume_attachment.tf delete mode 100644 oracle_cloud/modules/core_volumes/volume_backup.tf delete mode 100644 oracle_cloud/modules/core_volumes/volume_backup_policy.tf delete mode 100644 oracle_cloud/modules/core_volumes/volume_backup_policy_assignment.tf delete mode 100644 oracle_cloud/modules/core_volumes/volume_group.tf delete mode 100644 oracle_cloud/modules/core_volumes/volume_group_backup.tf diff --git a/oracle_cloud/examples/core_volume/README.md b/oracle_cloud/examples/core_volume/README.md index 0d2d9aea..6cb35477 100644 --- a/oracle_cloud/examples/core_volume/README.md +++ b/oracle_cloud/examples/core_volume/README.md @@ -1,4 +1,274 @@ -# Work with core_volumes via terraform +# Work with CORE_VOLUME via terraform -A terraform module for making core_volumes. +A terraform module for making CORE_VOLUME. + +## Usage +---------------------- +Import the module and retrieve with ```terraform get``` or ```terraform get --update```. Adding a module resource to your template, e.g. `main.tf`: + +``` +# +# MAINTAINER Vitaliy Natarov "vitaliy.natarov@yahoo.com" +# + +terraform { + required_version = "~> 1.0" + + required_providers { + oci = { + source = "oracle/oci" + version = "6.21.0" + } + } +} + +provider "oci" { + fingerprint = var.provider_oci_fingerprint + private_key_path = var.provider_oci_private_key_path + region = var.provider_oci_region + tenancy_ocid = var.provider_oci_tenancy_ocid + user_ocid = var.provider_oci_user_ocid + alias = var.provider_oci_alias +} + +module "core_volume" { + source = "../../modules/core_volume" + + enable_core_volume = true + core_volume_compartment_id = "" + + tags = {} +} + +``` + +## Module Input Variables +---------------------- +- `name` - The name for resources (`default = test`) +- `environment` - The environment for resources (`default = dev`) +- `tags` - Add additional tags (`default = {}`) +- `enable_core_boot_volume` - Enable core boot volume usages (`default = False`) +- `core_boot_volume_compartment_id` - (Required) (Updatable) The OCID of the compartment that contains the boot volume. (`default = null`) +- `core_boot_volume_source_details` - (Required) - Set list of boot volume source details (`default = []`) +- `volume_source_details_type` - (Optional) Specifies the volume source details for a new Block volume. The volume source is either another Block volume in the same Availability Domain or a Block volume backup. This is an optional field. If not specified or set to null, the new Block volume will be empty. When specified, the new Block volume will contain data from the source volume or backup. (`default = []`) +- `core_boot_volume_availability_domain` - (Optional) The availability domain of the volume. Omissible for cloning a volume. The new volume will be created in the availability domain of the source volume. Example: Uocm:PHX-AD-1 (`default = null`) +- `core_boot_volume_backup_policy_id` - (Optional) If provided, specifies the ID of the boot volume backup policy to assign to the newly created boot volume. If omitted, no policy will be assigned. This field is deprecated. Use the oci_core_volume_backup_policy_assignments instead to assign a backup policy to a boot volume. (`default = null`) +- `core_boot_volume_cluster_placement_group_id` - (Optional) The clusterPlacementGroup Id of the volume for volume placement. (`default = null`) +- `core_boot_volume_display_name` - (Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. (`default = null`) +- `core_boot_volume_is_auto_tune_enabled` - (Optional) (Updatable) Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the DetachedVolumeAutotunePolicy instead to enable the volume for detached autotune. (`default = null`) +- `core_boot_volume_kms_key_id` - (Optional) (Updatable) The OCID of the Vault service key to assign as the master encryption key for the boot volume. (`default = null`) +- `core_boot_volume_size_in_gbs` - (Optional) (Updatable) The size of the volume in GBs. (`default = null`) +- `core_boot_volume_vpus_per_gb` - (Optional) (Updatable) The number of volume performance units (VPUs) that will be applied to this volume per GB, representing the Block Volume service's elastic performance options. See Block Volume Performance Levels for more information. (`default = null`) +- `core_boot_volume_xrc_kms_key_id` - (Optional) The OCID of the Vault service key which is the master encryption key for the boot volume cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys. (`default = null`) +- `core_boot_volume_boot_volume_replicas_deletion` - Set boot volume replicas deletion usages (`default = null`) +- `core_boot_volume_autotune_policies` - (Optional) (Updatable) The list of autotune policies to be enabled for this volume. (`default = []`) +- `core_boot_volume_boot_volume_replicas` - (Optional) (Updatable) The list of boot volume replicas to be enabled for this boot volume in the specified destination availability domains. (`default = []`) +- `core_boot_volume_freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags (`default = {}`) +- `core_boot_volume_timeouts` - The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Boot Volume * update - (Defaults to 20 minutes), when updating the Boot Volume * delete - (Defaults to 20 minutes), when destroying the Boot Volume (`default = {}`) +- `enable_core_boot_volume_backup` - Enable core boot volume backup usages (`default = False`) +- `core_boot_volume_backup_boot_volume_id` - The OCID of the source volume backup. (`default = ""`) +- `core_boot_volume_backup_display_name` - (Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. (`default = null`) +- `core_boot_volume_backup_kms_key_id` - (Optional) (Updatable) The OCID of the Vault service key which is the master encryption key for the volume backup. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys. (`default = null`) +- `core_boot_volume_backup_type` - (Optional) The type of backup to create. If omitted, defaults to incremental. Supported values are 'FULL' or 'INCREMENTAL'. (`default = null`) +- `core_boot_volume_backup_freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. (`default = {}`) +- `core_boot_volume_backup_timeouts` - The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Boot Volume Backup * update - (Defaults to 20 minutes), when updating the Boot Volume Backup * delete - (Defaults to 20 minutes), when destroying the Boot Volume Backup (`default = {}`) +- `enable_core_volume` - Enable core volume usages (`default = False`) +- `core_volume_compartment_id` - (Required) (Updatable) The OCID of the compartment that contains the volume. (`default = null`) +- `core_volume_availability_domain` - (Optional) The availability domain of the volume. Omissible for cloning a volume. The new volume will be created in the availability domain of the source volume. Example: Uocm:PHX-AD-1 (`default = null`) +- `core_volume_backup_policy_id` - (Optional) If provided, specifies the ID of the volume backup policy to assign to the newly created volume. If omitted, no policy will be assigned. This field is deprecated. Use the oci_core_volume_backup_policy_assignments instead to assign a backup policy to a volume. (`default = null`) +- `core_volume_cluster_placement_group_id` - (Optional) The clusterPlacementGroup Id of the volume for volume placement. (`default = null`) +- `core_volume_display_name` - (Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. (`default = null`) +- `core_volume_is_auto_tune_enabled` - (Optional) (Updatable) Specifies whether the auto-tune performance is enabled for this volume. This field is deprecated. Use the DetachedVolumeAutotunePolicy instead to enable the volume for detached autotune. (`default = null`) +- `core_volume_kms_key_id` - (Optional) (Updatable) The OCID of the Vault service key to assign as the master encryption key for the volume. (`default = null`) +- `core_volume_size_in_gbs` - (Optional) (Updatable) The size of the volume in GBs. (`default = null`) +- `core_volume_size_in_mbs` - (Optional) The size of the volume in MBs. The value must be a multiple of 1024. This field is deprecated. Use sizeInGBs instead. (`default = null`) +- `core_volume_vpus_per_gb` - (Optional) (Updatable) The number of volume performance units (VPUs) that will be applied to this volume per GB, representing the Block Volume service's elastic performance options. See Block Volume Performance Levels for more information. (`default = null`) +- `core_volume_xrc_kms_key_id` - (Optional) The OCID of the Vault service key which is the master encryption key for the block volume cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys. (`default = null`) +- `core_volume_block_volume_replicas_deletion` - Set the replicas deletion for volume (`default = null`) +- `core_volume_autotune_policies` - (Optional) (Updatable) The list of autotune policies to be enabled for this volume. (`default = []`) +- `core_volume_block_volume_replicas` - (Optional) (Updatable) The list of block volume replicas to be enabled for this volume in the specified destination availability domains. (`default = []`) +- `core_volume_source_details` - (Optional) Specifies the volume source details for a new Block volume. The volume source is either another Block volume in the same Availability Domain or a Block volume backup. This is an optional field. If not specified or set to null, the new Block volume will be empty. When specified, the new Block volume will contain data from the source volume or backup. (`default = []`) +- `core_volume_freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. (`default = {}`) +- `core_volume_timeouts` - The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume * update - (Defaults to 20 minutes), when updating the Volume * delete - (Defaults to 20 minutes), when destroying the Volume (`default = {}`) +- `enable_core_volume_group` - Enable core volume group usages (`default = False`) +- `core_volume_group_availability_domain` - (Required) The availability domain of the volume group. (`default = null`) +- `core_volume_group_compartment_id` - (Required) (Updatable) The OCID of the compartment that contains the volume group. (`default = null`) +- `core_volume_group_source_details` - (Required) Specifies the source for a volume group. (`default = []`) +- `core_volume_group_backup_policy_id` - (Optional) If provided, specifies the ID of the volume backup policy to assign to the newly created volume group. If omitted, no policy will be assigned. This field is deprecated. Use the oci_core_volume_backup_policy_assignments instead to assign a backup policy to a volume group. (`default = null`) +- `core_volume_group_cluster_placement_group_id` - (Optional) The clusterPlacementGroup Id of the volume group for volume group placement. (`default = null`) +- `core_volume_group_display_name` - (Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. (`default = null`) +- `core_volume_group_volume_ids` - (Optional) (Updatable) Use this for update operation only. This field is not supported during creation. For create use volume_ids under source_details (`default = null`) +- `core_volume_group_xrc_kms_key_id` - (Optional) The OCID of the Vault service key which is the master encryption key for the volume's cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys. (`default = null`) +- `core_volume_group_volume_group_replicas` - (Optional) (Updatable) The list of volume group replicas that this volume group will be enabled to have in the specified destination availability domains. (`default = []`) +- `core_volume_group_freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. (`default = {}`) +- `core_volume_group_timeouts` - The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Group * update - (Defaults to 20 minutes), when updating the Volume Group * delete - (Defaults to 20 minutes), when destroying the Volume Group (`default = {}`) +- `enable_core_volume_group_backup` - Enable core volume group backup usages (`default = False`) +- `core_volume_group_backup_volume_group_id` - (Required) The OCID of the volume group that needs to be backed up. (`default = null`) +- `core_volume_group_backup_compartment_id` - (Optional) (Updatable) The OCID of the compartment that will contain the volume group backup. This parameter is optional, by default backup will be created in the same compartment and source volume group. (`default = null`) +- `core_volume_group_backup_display_name` - (Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. (`default = null`) +- `core_volume_group_backup_type` - (Optional) The type of backup to create. If omitted, defaults to incremental. (`default = null`) +- `core_volume_group_backup_freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. (`default = {}`) +- `core_volume_group_backup_timeouts` - The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Group Backup * update - (Defaults to 20 minutes), when updating the Volume Group Backup * delete - (Defaults to 20 minutes), when destroying the Volume Group Backup (`default = {}`) +- `enable_core_volume_backup` - Enable core volume backup usages (`default = False`) +- `core_volume_backup_volume_id` - (Optional) The OCID of the volume that needs to be backed up.**Note: To create the resource either volume_id or source_details is required to be set. (`default = null`) +- `core_volume_backup_display_name` - (Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. (`default = null`) +- `core_volume_backup_kms_key_id` - (Optional) (Updatable) The OCID of the Vault service key which is the master encryption key for the volume backup. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys. (`default = null`) +- `core_volume_backup_type` - (Optional) The type of backup to create. If omitted, defaults to INCREMENTAL. Supported values are 'FULL' or 'INCREMENTAL'. (`default = null`) +- `core_volume_backup_freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. (`default = {}`) +- `core_volume_backup_timeouts` - The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Backup * update - (Defaults to 20 minutes), when updating the Volume Backup * delete - (Defaults to 20 minutes), when destroying the Volume Backup (`default = {}`) +- `enable_core_volume_backup_policy` - Enable core volume backup policy usages (`default = False`) +- `core_volume_backup_policy_compartment_id` - (Required) The OCID of the compartment. (`default = null`) +- `core_volume_backup_policy_destination_region` - (Optional) (Updatable) The paired destination region for copying scheduled backups to. Example: us-ashburn-1. See Region Pairs for details about paired regions. (`default = null`) +- `core_volume_backup_policy_display_name` - (Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. (`default = null`) +- `core_volume_backup_policy_schedules` - (Optional) (Updatable) The collection of schedules for the volume backup policy. See see Schedules in Policy-Based Backups for more information. (`default = []`) +- `core_volume_backup_policy_freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. (`default = {}`) +- `core_volume_backup_policy_timeouts` - The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Backup Policy * update - (Defaults to 20 minutes), when updating the Volume Backup Policy * delete - (Defaults to 20 minutes), when destroying the Volume Backup Policy (`default = {}`) +- `enable_core_volume_backup_policy_assignment` - Enable core volume backup policy assignment usages (`default = False`) +- `core_volume_backup_policy_assignment_asset_id` - The OCID of the volume or volume group to assign the policy to. (`default = ""`) +- `core_volume_backup_policy_assignment_policy_id` - The OCID of the volume backup policy to assign to the volume. (`default = ""`) +- `core_volume_backup_policy_assignment_xrc_kms_key_id` - (Optional) The OCID of the Vault service key which is the master encryption key for the block / boot volume cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys. (`default = null`) +- `core_volume_backup_policy_assignment_timeouts` - The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Backup Policy Assignment * update - (Defaults to 20 minutes), when updating the Volume Backup Policy Assignment * delete - (Defaults to 20 minutes), when destroying the Volume Backup Policy Assignment (`default = {}`) +- `enable_core_volume_attachment` - Enable core volume attachment usages (`default = False`) +- `core_volume_attachment_attachment_type` - (Required) The type of volume. The only supported values are 'iscsi' and 'paravirtualized'. (`default = null`) +- `core_volume_attachment_instance_id` - (Required) The OCID of the instance. (`default = null`) +- `core_volume_attachment_volume_id` - The OCID of the volume. (`default = ""`) +- `core_volume_attachment_device` - (Optional) The device name. To retrieve a list of devices for a given instance, see ListInstanceDevices. (`default = null`) +- `core_volume_attachment_display_name` - (Optional) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. (`default = null`) +- `core_volume_attachment_encryption_in_transit_type` - (Applicable when attachment_type=iscsi) Refer the top-level definition of encryptionInTransitType. The default value is NONE. (`default = null`) +- `core_volume_attachment_is_agent_auto_iscsi_login_enabled` - (Applicable when attachment_type=iscsi) Whether to enable Oracle Cloud Agent to perform the iSCSI login and logout commands after the volume attach or detach operations for non multipath-enabled iSCSI attachments. (`default = null`) +- `core_volume_attachment_is_pv_encryption_in_transit_enabled` - (Applicable when attachment_type=paravirtualized) Whether to enable in-transit encryption for the data volume's paravirtualized attachment. The default value is false. (`default = null`) +- `core_volume_attachment_is_read_only` - (Optional) Whether the attachment was created in read-only mode. (`default = null`) +- `core_volume_attachment_is_shareable` - (Optional) Whether the attachment should be created in shareable mode. If an attachment is created in shareable mode, then other instances can attach the same volume, provided that they also create their attachments in shareable mode. Only certain volume types can be attached in shareable mode. Defaults to false if not specified. (`default = null`) +- `core_volume_attachment_use_chap` - (Applicable when attachment_type=iscsi) Whether to use CHAP authentication for the volume attachment. Defaults to false. (`default = null`) +- `core_volume_attachment_timeouts` - The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Attachment * update - (Defaults to 20 minutes), when updating the Volume Attachment * delete - (Defaults to 20 minutes), when destroying the Volume Attachment (`default = {}`) + +## Module Output Variables +---------------------- +- `core_boot_volume_compartment_id` - The OCID of the compartment that contains the boot volume. +- `core_boot_volume_display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. +- `core_boot_volume_id` - The boot volume's Oracle ID (OCID). +- `core_boot_volume_cluster_placement_group_id` - The clusterPlacementGroup Id of the volume for volume placement. +- `core_boot_volume_availability_domain` - The availability domain of the boot volume. Example: Uocm:PHX-AD-1 +- `core_boot_volume_boot_volume_replicas` - The list of boot volume replicas of this boot volume +- `core_boot_volume_auto_tuned_vpus_per_gb` - The number of Volume Performance Units per GB that this boot volume is effectively tuned to. +- `core_boot_volume_autotune_policies` - The list of autotune policies enabled for this volume. +- `core_boot_volume_volume_group_id` - The OCID of the source volume group. +- `core_boot_volume_vpus_per_gb` - The number of volume performance units (VPUs) that will be applied to this boot volume per GB, representing the Block Volume service's elastic performance options. See Block Volume Performance Levels for more information. +- `core_boot_volume_state` - The current state of a boot volume. +- `core_boot_volume_image_id` - The image OCID used to create the boot volume. +- `core_boot_volume_is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the DetachedVolumeAutotunePolicy instead to enable the volume for detached autotune. +- `core_boot_volume_is_hydrated` - Specifies whether the boot volume's data has finished copying from the source boot volume or boot volume backup. +- `core_boot_volume_kms_key_id` - The OCID of the Vault service master encryption key assigned to the boot volume. +- `core_boot_volume_size_in_gbs` - The size of the boot volume in GBs. +- `core_boot_volume_size_in_mbs` - The size of the volume in MBs. The value must be a multiple of 1024. This field is deprecated. Please use size_in_gbs. +- `core_boot_volume_source_details` - Output block of source details for Boot Volume +- `core_boot_volume_backup_id` - The OCID of the boot volume backup. +- `core_boot_volume_backup_image_id` - The image OCID used to create the boot volume the backup is taken from. +- `core_boot_volume_backup_kms_key_id` - The OCID of the Vault service master encryption assigned to the boot volume backup. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys. +- `core_boot_volume_backup_size_in_gbs` - The size of the boot volume, in GBs. +- `core_boot_volume_backup_source_boot_volume_backup_id` - The OCID of the source boot volume backup. +- `core_boot_volume_backup_source_type` - Specifies whether the backup was created manually, or via scheduled backup policy. +- `core_boot_volume_backup_state` - The current state of a boot volume backup. +- `core_boot_volume_backup_type` - The type of a volume backup. Supported values are 'FULL' or 'INCREMENTAL'. +- `core_boot_volume_backup_unique_size_in_gbs` - The size used by the backup, in GBs. It is typically smaller than sizeInGBs, depending on the space consumed on the boot volume and whether the backup is full or incremental. +- `core_boot_volume_backup_boot_volume_id` - The OCID of the boot volume. +- `core_boot_volume_backup_compartment_id` - The OCID of the compartment that contains the boot volume backup. +- `core_boot_volume_backup_display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. +- `core_boot_volume_backup_expiration_time` - The date and time the volume backup will expire and be automatically deleted. Format defined by RFC3339. This parameter will always be present for backups that were created automatically by a scheduled-backup policy. For manually created backups, it will be absent, signifying that there is no expiration time and the backup will last forever until manually deleted. +- `core_volume_id` - The OCID of the volume. +- `core_volume_is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this volume. This field is deprecated. Use the DetachedVolumeAutotunePolicy instead to enable the volume for detached autotune. +- `core_volume_is_hydrated` - Specifies whether the cloned volume's data has finished copying from the source volume or backup. +- `core_volume_kms_key_id` - The OCID of the Vault service key which is the master encryption key for the volume. +- `core_volume_size_in_gbs` - The size of the volume in GBs. +- `core_volume_size_in_mbs` - The size of the volume in MBs. This field is deprecated. Use sizeInGBs instead. +- `core_volume_source_details` - Output of source details +- `core_volume_cluster_placement_group_id` - The clusterPlacementGroup Id of the volume for volume placement. +- `core_volume_compartment_id` - The OCID of the compartment that contains the volume. +- `core_volume_availability_domain` - The availability domain of the volume. Example: Uocm:PHX-AD-1 +- `core_volume_block_volume_replicas` - The list of block volume replicas of this volume. +- `core_volume_auto_tuned_vpus_per_gb` - The number of Volume Performance Units per GB that this volume is effectively tuned to. +- `core_volume_autotune_policies` - The list of autotune policies enabled for this volume. +- `core_volume_state` - The current state of a volume. +- `core_volume_volume_group_id` - The OCID of the source volume group. +- `core_volume_vpus_per_gb` - The number of volume performance units (VPUs) that will be applied to this volume per GB, representing the Block Volume service's elastic performance options. See Block Volume Performance Levels for more information. +- `core_volume_group_id` - The OCID for the volume group. +- `core_volume_group_volume_ids` - OCIDs for the current volumes in this volume group. +- `core_volume_group_state` - The current state of a volume group. +- `core_volume_group_source_details` - Specifies the source for a volume group. +- `core_volume_group_is_hydrated` - Specifies whether the newly created cloned volume group's data has finished copying from the source volume group or backup. +- `core_volume_group_size_in_gbs` - The aggregate size of the volume group in GBs. +- `core_volume_group_size_in_mbs` - The aggregate size of the volume group in MBs. +- `core_volume_group_availability_domain` - The availability domain of the volume group. +- `core_volume_group_compartment_id` - The OCID of the compartment that contains the volume group. +- `core_volume_group_display_name` - user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. +- `core_volume_group_compartment_id` - The OCID of the compartment that contains the volume group backup. +- `core_volume_group_display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. +- `core_volume_group_expiration_time` - The date and time the volume group backup will expire and be automatically deleted. Format defined by RFC3339. This parameter will always be present for volume group backups that were created automatically by a scheduled-backup policy. For manually created volume group backups, it will be absent, signifying that there is no expiration time and the backup will last forever until manually deleted. +- `core_volume_group_id` - The OCID of the volume group backup. +- `core_volume_group_size_in_gbs` - The aggregate size of the volume group backup, in GBs. +- `core_volume_group_size_in_mbs` - The aggregate size of the volume group backup, in MBs. +- `core_volume_group_source_type` - Specifies whether the volume group backup was created manually, or via scheduled backup policy. +- `core_volume_group_source_volume_group_backup_id` - The OCID of the source volume group backup. +- `core_volume_group_state` - The current state of a volume group backup. +- `core_volume_group_time_request_received` - The date and time the request to create the volume group backup was received. Format defined by RFC3339. +- `core_volume_group_type` - The type of backup. +- `core_volume_group_unique_size_in_gbs` - The aggregate size used by the volume group backup, in GBs. It is typically smaller than size_in_gbs, depending on the space consumed on the volume group and whether the volume backup is full or incremental. +- `core_volume_group_unique_size_in_mbs` - The aggregate size used by the volume group backup, in MBs. It is typically smaller than size_in_mbs, depending on the space consumed on the volume group and whether the volume backup is full or incremental. +- `core_volume_group_volume_backup_ids` - OCIDs for the volume backups in this volume group backup. +- `core_volume_group_volume_group_id` - The OCID of the source volume group. +- `core_volume_backup_compartment_id` - The OCID of the compartment that contains the volume backup. +- `core_volume_backup_display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. +- `core_volume_backup_expiration_time` - The date and time the volume backup will expire and be automatically deleted. Format defined by RFC3339. This parameter will always be present for backups that were created automatically by a scheduled-backup policy. For manually created backups, it will be absent, signifying that there is no expiration time and the backup will last forever until manually deleted. +- `core_volume_backup_id` - The OCID of the volume backup. +- `core_volume_backup_kms_key_id` - The OCID of the Vault service key which is the master encryption key for the volume backup. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys. +- `core_volume_backup_size_in_gbs` - The size of the volume, in GBs. +- `core_volume_backup_size_in_mbs` - The size of the volume in MBs. The value must be a multiple of 1024. This field is deprecated. Please use size_in_gbs. +- `core_volume_backup_source_type` - Specifies whether the backup was created manually, or via scheduled backup policy. +- `core_volume_backup_source_volume_backup_id` - The OCID of the source volume backup. +- `core_volume_backup_state` - The current state of a volume backup. +- `core_volume_backup_time_request_received` - The date and time the request to create the volume backup was received. Format defined by [RFC3339]https://tools.ietf.org/html/rfc3339. +- `core_volume_backup_type` - The type of a volume backup. Supported values are 'FULL' or 'INCREMENTAL'. +- `core_volume_backup_unique_size_in_gbs` - The size used by the backup, in GBs. It is typically smaller than sizeInGBs, depending on the space consumed on the volume and whether the backup is full or incremental. +- `core_volume_backup_unique_size_in_mbs` - The size used by the backup, in MBs. It is typically smaller than sizeInMBs, depending on the space consumed on the volume and whether the backup is full or incremental. This field is deprecated. Please use uniqueSizeInGBs. +- `core_volume_backup_volume_id` - The OCID of the volume. +- `core_volume_backup_policy_compartment_id` - The OCID of the compartment that contains the volume backup. +- `core_volume_backup_policy_destination_region` - The paired destination region for copying scheduled backups to. Example us-ashburn-1. See Region Pairs for details about paired regions. +- `core_volume_backup_policy_display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. +- `core_volume_backup_policy_id` - The OCID of the volume backup policy. +- `core_volume_backup_policy_schedules` - The collection of schedules that this policy will apply. +- `core_volume_backup_policy_assignment_asset_id` - The OCID of the volume or volume group the policy has been assigned to. +- `core_volume_backup_policy_assignment_id` - The OCID of the volume backup policy assignment. +- `core_volume_backup_policy_assignment_policy_id` - The OCID of the volume backup policy that has been assigned to the volume or volume group. For a volume group, only the user defined policy is allowed to use. For more information, see Policy-Based Backups. +- `core_volume_backup_policy_assignment_xrc_kms_key_id` - The OCID of the Vault service key which is the master encryption key for the block / boot volume cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys. +- `core_volume_attachment_port` - The volume's iSCSI port, usually port 860 or 3260. Example: 3260 +- `core_volume_attachment_state` - The current state of the volume attachment. +- `core_volume_attachment_volume_id` - The OCID of the volume. +- `core_volume_attachment_is_multipath` - Whether the Iscsi or Paravirtualized attachment is multipath or not, it is not applicable to NVMe attachment. +- `core_volume_attachment_is_pv_encryption_in_transit_enabled` - Whether in-transit encryption for the data volume's paravirtualized attachment is enabled or not. +- `core_volume_attachment_is_read_only` - Whether the attachment was created in read-only mode. +- `core_volume_attachment_iscsi_login_state` - The iscsi login state of the volume attachment. For a Iscsi volume attachment, all iscsi sessions need to be all logged-in or logged-out to be in logged-in or logged-out state. +- `core_volume_attachment_is_volume_created_during_launch` - Flag indicating if this volume was created for the customer as part of a simplified launch. Used to determine whether the volume requires deletion on instance termination. +- `core_volume_attachment_iscsi_login_state` - The iscsi login state of the volume attachment. For a Iscsi volume attachment, all iscsi sessions need to be all logged-in or logged-out to be in logged-in or logged-out state. +- `core_volume_attachment_chap_secret` - The Challenge-Handshake-Authentication-Protocol (CHAP) secret valid for the associated CHAP user name. +- `core_volume_attachment_chap_username` - The volume's system-generated Challenge-Handshake-Authentication-Protocol (CHAP) user name. See RFC 1994 for more on CHAP. Example: ocid1.volume.oc1.phx. +- `core_volume_attachment_compartment_id` - The OCID of the compartment. +- `core_volume_attachment_device` - The device name. +- `core_volume_attachment_display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information. +- `core_volume_attachment_encryption_in_transit_type` - Refer the top-level definition of encryptionInTransitType. The default value is NONE. +- `core_volume_attachment_id` - The OCID of the volume attachment. +- `core_volume_attachment_instance_id` - The OCID of the instance the volume is attached to. +- `core_volume_attachment_ipv4` - The volume's iSCSI IP address. Example: 169.254.0.2 +- `core_volume_attachment_iqn` - The target volume's iSCSI Qualified Name in the format defined by RFC 3720. Example: iqn.2015-12.us.oracle.com: +- `core_volume_attachment_is_agent_auto_iscsi_login_enabled` - Whether Oracle Cloud Agent is enabled perform the iSCSI login and logout commands after the volume attach or detach operations for non multipath-enabled iSCSI attachments. +- `core_volume_attachment_attachment_type` - The type of volume attachment. +- `core_volume_attachment_availability_domain` - The availability domain of an instance. Example: Uocm:PHX-AD-1 + + +## Authors + +Created and maintained by [Vitaliy Natarov](https://github.com/SebastianUA). An email: [vitaliy.natarov@yahoo.com](vitaliy.natarov@yahoo.com). + +## License + +Apache 2 Licensed. See [LICENSE](https://github.com/SebastianUA/terraform/blob/master/LICENSE) for full details. diff --git a/oracle_cloud/examples/core_volume/main.tf b/oracle_cloud/examples/core_volume/main.tf index 98d590a0..0094b47d 100644 --- a/oracle_cloud/examples/core_volume/main.tf +++ b/oracle_cloud/examples/core_volume/main.tf @@ -25,4 +25,8 @@ provider "oci" { module "core_volume" { source = "../../modules/core_volume" + enable_core_volume = true + core_volume_compartment_id = "" + + tags = {} } diff --git a/oracle_cloud/modules/core_volume/boot_volume.tf b/oracle_cloud/modules/core_volume/boot_volume.tf new file mode 100644 index 00000000..c113e593 --- /dev/null +++ b/oracle_cloud/modules/core_volume/boot_volume.tf @@ -0,0 +1,91 @@ +#----------------------------------------------------------- +# core boot volume +#----------------------------------------------------------- +resource "oci_core_boot_volume" "core_boot_volume" { + count = var.enable_core_boot_volume ? 1 : 0 + + # Required + compartment_id = var.core_boot_volume_compartment_id + + dynamic "source_details" { + iterator = source_details + for_each = var.core_boot_volume_source_details + + content { + # Required + type = var.boot_volume_source_details_type + + # Optional + change_block_size_in_bytes = lookup(source_details.value, "change_block_size_in_bytes", null) + first_backup_id = lookup(source_details.value, "first_backup_id", null) + id = lookup(source_details.value, "id", null) + second_backup_id = lookup(source_details.value, "second_backup_id", null) + } + } + + # Optional + availability_domain = var.core_boot_volume_availability_domain + backup_policy_id = var.core_boot_volume_backup_policy_id + cluster_placement_group_id = var.core_boot_volume_cluster_placement_group_id + display_name = var.core_boot_volume_display_name != "" ? var.core_boot_volume_display_name : "${lower(var.name)}-boot-volume-${lower(var.environment)}" + is_auto_tune_enabled = var.core_boot_volume_is_auto_tune_enabled + kms_key_id = var.core_boot_volume_kms_key_id + size_in_gbs = var.core_boot_volume_size_in_gbs + vpus_per_gb = var.core_boot_volume_vpus_per_gb + xrc_kms_key_id = var.core_boot_volume_xrc_kms_key_id + boot_volume_replicas_deletion = var.core_boot_volume_boot_volume_replicas_deletion + + dynamic "autotune_policies" { + iterator = autotune_policies + for_each = var.core_boot_volume_autotune_policies + + content { + # Required + autotune_type = lookup(autotune_policies.value, "autotune_type", null) + + # Optional + max_vpus_per_gb = lookup(autotune_policies.value, "max_vpus_per_gb", null) + } + } + + dynamic "boot_volume_replicas" { + iterator = boot_volume_replicas + for_each = var.core_boot_volume_boot_volume_replicas + + content { + # Required + availability_domain = lookup(boot_volume_replicas.value, "availability_domain", null) + + # Optional + display_name = lookup(boot_volume_replicas.value, "display_name", null) + xrr_kms_key_id = lookup(boot_volume_replicas.value, "xrr_kms_key_id", null) + } + } + + defined_tags = merge( + { + Name = var.core_boot_volume_display_name != "" ? var.core_boot_volume_display_name : "${lower(var.name)}-boot-volume-${lower(var.environment)}" + }, + var.tags + ) + freeform_tags = var.core_boot_volume_freeform_tags + + dynamic "timeouts" { + iterator = timeouts + for_each = length(keys(var.core_boot_volume_timeouts)) > 0 ? [var.core_boot_volume_timeouts] : [] + + content { + create = lookup(timeouts.value, "create", null) + update = lookup(timeouts.value, "update", null) + delete = lookup(timeouts.value, "delete", null) + } + } + + lifecycle { + create_before_destroy = true + ignore_changes = [] + } + + depends_on = [] + +} \ No newline at end of file diff --git a/oracle_cloud/modules/core_volume/boot_volume_backup.tf b/oracle_cloud/modules/core_volume/boot_volume_backup.tf new file mode 100644 index 00000000..e6f8fb8b --- /dev/null +++ b/oracle_cloud/modules/core_volume/boot_volume_backup.tf @@ -0,0 +1,40 @@ +#----------------------------------------------------------- +# core boot volume backup +#----------------------------------------------------------- +resource "oci_core_boot_volume_backup" "core_boot_volume_backup" { + count = var.enable_core_boot_volume_backup ? 1 : 0 + + # Required + boot_volume_id = var.core_boot_volume_backup_boot_volume_id != "" && !var.enable_core_boot_volume ? var.core_boot_volume_backup_boot_volume_id : (var.enable_core_boot_volume ? element(oci_core_boot_volume.core_boot_volume.*.id, 0) : null) + + # Optional + display_name = var.core_boot_volume_backup_display_name != "" ? var.core_boot_volume_backup_display_name : "${lower(var.name)}-boot-volume-backup-${lower(var.environment)}" + kms_key_id = var.core_boot_volume_backup_kms_key_id + type = var.core_boot_volume_backup_type + + defined_tags = merge( + { + Name = var.core_boot_volume_backup_display_name != "" ? var.core_boot_volume_backup_display_name : "${lower(var.name)}-boot-volume-backup-${lower(var.environment)}" + }, + var.tags + ) + freeform_tags = var.core_boot_volume_backup_freeform_tags + + dynamic "timeouts" { + iterator = timeouts + for_each = length(keys(var.core_boot_volume_backup_timeouts)) > 0 ? [var.core_boot_volume_backup_timeouts] : [] + + content { + create = lookup(timeouts.value, "create", null) + update = lookup(timeouts.value, "update", null) + delete = lookup(timeouts.value, "delete", null) + } + } + + lifecycle { + create_before_destroy = true + ignore_changes = [] + } + + depends_on = [] +} \ No newline at end of file diff --git a/oracle_cloud/modules/core_volume/outputs.tf b/oracle_cloud/modules/core_volume/outputs.tf new file mode 100644 index 00000000..6bbdd420 --- /dev/null +++ b/oracle_cloud/modules/core_volume/outputs.tf @@ -0,0 +1,616 @@ +#----------------------------------------------------------- +# core boot volume +#----------------------------------------------------------- +output "core_boot_volume_compartment_id" { + description = "The OCID of the compartment that contains the boot volume." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.compartment_id, [""]), 0) +} + +output "core_boot_volume_display_name" { + description = "A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.display_name, [""]), 0) +} + +output "core_boot_volume_id" { + description = "The boot volume's Oracle ID (OCID)." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.id, [""]), 0) +} + +output "core_boot_volume_cluster_placement_group_id" { + description = "The clusterPlacementGroup Id of the volume for volume placement." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.cluster_placement_group_id, [""]), 0) +} + +output "core_boot_volume_availability_domain" { + description = "The availability domain of the boot volume. Example: Uocm:PHX-AD-1" + value = element(concat(oci_core_boot_volume.core_boot_volume.*.availability_domain, [""]), 0) +} + +output "core_boot_volume_boot_volume_replicas" { + description = "The list of boot volume replicas of this boot volume" + value = concat(oci_core_boot_volume.core_boot_volume.*.boot_volume_replicas, [""]) +} + +output "core_boot_volume_auto_tuned_vpus_per_gb" { + description = "The number of Volume Performance Units per GB that this boot volume is effectively tuned to." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.auto_tuned_vpus_per_gb, [""]), 0) +} + +output "core_boot_volume_autotune_policies" { + description = "The list of autotune policies enabled for this volume." + value = concat(oci_core_boot_volume.core_boot_volume.*.autotune_policies, [""]) +} + +output "core_boot_volume_volume_group_id" { + description = "The OCID of the source volume group." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.volume_group_id, [""]), 0) +} + +output "core_boot_volume_vpus_per_gb" { + description = "The number of volume performance units (VPUs) that will be applied to this boot volume per GB, representing the Block Volume service's elastic performance options. See Block Volume Performance Levels for more information." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.vpus_per_gb, [""]), 0) +} + +output "core_boot_volume_state" { + description = "The current state of a boot volume." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.state, [""]), 0) +} + +output "core_boot_volume_image_id" { + description = "The image OCID used to create the boot volume." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.image_id, [""]), 0) +} + +output "core_boot_volume_is_auto_tune_enabled" { + description = "Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the DetachedVolumeAutotunePolicy instead to enable the volume for detached autotune." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.is_auto_tune_enabled, [""]), 0) +} + +output "core_boot_volume_is_hydrated" { + description = "Specifies whether the boot volume's data has finished copying from the source boot volume or boot volume backup." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.is_hydrated, [""]), 0) +} + +output "core_boot_volume_kms_key_id" { + description = "The OCID of the Vault service master encryption key assigned to the boot volume." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.kms_key_id, [""]), 0) +} + +output "core_boot_volume_size_in_gbs" { + description = "The size of the boot volume in GBs." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.size_in_gbs, [""]), 0) +} + +output "core_boot_volume_size_in_mbs" { + description = "The size of the volume in MBs. The value must be a multiple of 1024. This field is deprecated. Please use size_in_gbs." + value = element(concat(oci_core_boot_volume.core_boot_volume.*.size_in_mbs, [""]), 0) +} + +output "core_boot_volume_source_details" { + description = "Output block of source details for Boot Volume" + value = concat(oci_core_boot_volume.core_boot_volume.*.source_details, [""]) +} + +#----------------------------------------------------------- +# core boot volume backup +#----------------------------------------------------------- +output "core_boot_volume_backup_id" { + description = "The OCID of the boot volume backup." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.id, [""]), 0) +} + +output "core_boot_volume_backup_image_id" { + description = "The image OCID used to create the boot volume the backup is taken from." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.image_id, [""]), 0) +} + +output "core_boot_volume_backup_kms_key_id" { + description = "The OCID of the Vault service master encryption assigned to the boot volume backup. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.kms_key_id, [""]), 0) +} + +output "core_boot_volume_backup_size_in_gbs" { + description = "The size of the boot volume, in GBs." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.size_in_gbs, [""]), 0) +} + +output "core_boot_volume_backup_source_boot_volume_backup_id" { + description = "The OCID of the source boot volume backup." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.source_boot_volume_backup_id, [""]), 0) +} + +output "core_boot_volume_backup_source_type" { + description = "Specifies whether the backup was created manually, or via scheduled backup policy." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.source_type, [""]), 0) +} + +output "core_boot_volume_backup_state" { + description = "The current state of a boot volume backup." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.state, [""]), 0) +} + +output "core_boot_volume_backup_type" { + description = "The type of a volume backup. Supported values are 'FULL' or 'INCREMENTAL'." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.type, [""]), 0) +} + +output "core_boot_volume_backup_unique_size_in_gbs" { + description = "The size used by the backup, in GBs. It is typically smaller than sizeInGBs, depending on the space consumed on the boot volume and whether the backup is full or incremental." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.unique_size_in_gbs, [""]), 0) +} + +output "core_boot_volume_backup_boot_volume_id" { + description = "The OCID of the boot volume." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.boot_volume_id, [""]), 0) +} + +output "core_boot_volume_backup_compartment_id" { + description = "The OCID of the compartment that contains the boot volume backup." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.compartment_id, [""]), 0) +} + +output "core_boot_volume_backup_display_name" { + description = "A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.display_name, [""]), 0) +} + +output "core_boot_volume_backup_expiration_time" { + description = "The date and time the volume backup will expire and be automatically deleted. Format defined by RFC3339. This parameter will always be present for backups that were created automatically by a scheduled-backup policy. For manually created backups, it will be absent, signifying that there is no expiration time and the backup will last forever until manually deleted." + value = element(concat(oci_core_boot_volume_backup.core_boot_volume_backup.*.expiration_time, [""]), 0) +} + +#----------------------------------------------------------- +# core volume +#----------------------------------------------------------- +output "core_volume_id" { + description = "The OCID of the volume." + value = element(concat(oci_core_volume.core_volume.*.id, [""]), 0) +} + +output "core_volume_is_auto_tune_enabled" { + description = "Specifies whether the auto-tune performance is enabled for this volume. This field is deprecated. Use the DetachedVolumeAutotunePolicy instead to enable the volume for detached autotune." + value = element(concat(oci_core_volume.core_volume.*.is_auto_tune_enabled, [""]), 0) +} + +output "core_volume_is_hydrated" { + description = "Specifies whether the cloned volume's data has finished copying from the source volume or backup." + value = element(concat(oci_core_volume.core_volume.*.is_hydrated, [""]), 0) +} + +output "core_volume_kms_key_id" { + description = "The OCID of the Vault service key which is the master encryption key for the volume." + value = element(concat(oci_core_volume.core_volume.*.kms_key_id, [""]), 0) +} + +output "core_volume_size_in_gbs" { + description = "The size of the volume in GBs." + value = element(concat(oci_core_volume.core_volume.*.size_in_gbs, [""]), 0) +} + +output "core_volume_size_in_mbs" { + description = "The size of the volume in MBs. This field is deprecated. Use sizeInGBs instead." + value = element(concat(oci_core_volume.core_volume.*.size_in_mbs, [""]), 0) +} + +output "core_volume_source_details" { + description = "Output of source details" + value = concat(oci_core_volume.core_volume.*.source_details, [""]) +} + +output "core_volume_cluster_placement_group_id" { + description = "The clusterPlacementGroup Id of the volume for volume placement." + value = element(concat(oci_core_volume.core_volume.*.cluster_placement_group_id, [""]), 0) +} + +output "core_volume_compartment_id" { + description = "The OCID of the compartment that contains the volume." + value = element(concat(oci_core_volume.core_volume.*.compartment_id, [""]), 0) +} + +output "core_volume_availability_domain" { + description = "The availability domain of the volume. Example: Uocm:PHX-AD-1" + value = element(concat(oci_core_volume.core_volume.*.availability_domain, [""]), 0) +} + +output "core_volume_block_volume_replicas" { + description = "The list of block volume replicas of this volume." + value = element(concat(oci_core_volume.core_volume.*.block_volume_replicas, [""]), 0) +} + +output "core_volume_auto_tuned_vpus_per_gb" { + description = "The number of Volume Performance Units per GB that this volume is effectively tuned to." + value = element(concat(oci_core_volume.core_volume.*.auto_tuned_vpus_per_gb, [""]), 0) +} + +output "core_volume_autotune_policies" { + description = "The list of autotune policies enabled for this volume." + value = concat(oci_core_volume.core_volume.*.autotune_policies, [""]) +} + +output "core_volume_state" { + description = "The current state of a volume." + value = element(concat(oci_core_volume.core_volume.*.state, [""]), 0) +} + +output "core_volume_volume_group_id" { + description = "The OCID of the source volume group." + value = element(concat(oci_core_volume.core_volume.*.volume_group_id, [""]), 0) +} + +output "core_volume_vpus_per_gb" { + description = "The number of volume performance units (VPUs) that will be applied to this volume per GB, representing the Block Volume service's elastic performance options. See Block Volume Performance Levels for more information." + value = element(concat(oci_core_volume.core_volume.*.vpus_per_gb, [""]), 0) +} + +#----------------------------------------------------------- +# core volume group +#----------------------------------------------------------- +output "core_volume_group_id" { + description = "The OCID for the volume group." + value = element(concat(oci_core_volume_group.core_volume_group.*.id, [""]), 0) +} + +output "core_volume_group_volume_ids" { + description = "OCIDs for the current volumes in this volume group." + value = element(concat(oci_core_volume_group.core_volume_group.*.volume_ids, [""]), 0) +} + +output "core_volume_group_state" { + description = "The current state of a volume group." + value = element(concat(oci_core_volume_group.core_volume_group.*.state, [""]), 0) +} + +output "core_volume_group_source_details" { + description = "Specifies the source for a volume group." + value = concat(oci_core_volume_group.core_volume_group.*.source_details, [""]) +} + +output "core_volume_group_is_hydrated" { + description = "Specifies whether the newly created cloned volume group's data has finished copying from the source volume group or backup." + value = element(concat(oci_core_volume_group.core_volume_group.*.is_hydrated, [""]), 0) +} + +output "core_volume_group_size_in_gbs" { + description = "The aggregate size of the volume group in GBs." + value = element(concat(oci_core_volume_group.core_volume_group.*.size_in_gbs, [""]), 0) +} + +output "core_volume_group_size_in_mbs" { + description = "The aggregate size of the volume group in MBs." + value = element(concat(oci_core_volume_group.core_volume_group.*.size_in_mbs, [""]), 0) +} + +output "core_volume_group_availability_domain" { + description = "The availability domain of the volume group." + value = element(concat(oci_core_volume_group.core_volume_group.*.availability_domain, [""]), 0) +} + +output "core_volume_group_compartment_id" { + description = "The OCID of the compartment that contains the volume group." + value = element(concat(oci_core_volume_group.core_volume_group.*.compartment_id, [""]), 0) +} + +output "core_volume_group_display_name" { + description = "user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + value = element(concat(oci_core_volume_group.core_volume_group.*.display_name, [""]), 0) +} + +#----------------------------------------------------------- +# core volume group backup +#----------------------------------------------------------- +output "core_volume_group_compartment_id" { + description = "The OCID of the compartment that contains the volume group backup." + value = element(concat(oci_core_volume_group.core_volume_group.*.compartment_id, [""]), 0) +} + +output "core_volume_group_display_name" { + description = "A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + value = element(concat(oci_core_volume_group.core_volume_group.*.display_name, [""]), 0) +} + +output "core_volume_group_expiration_time" { + description = "The date and time the volume group backup will expire and be automatically deleted. Format defined by RFC3339. This parameter will always be present for volume group backups that were created automatically by a scheduled-backup policy. For manually created volume group backups, it will be absent, signifying that there is no expiration time and the backup will last forever until manually deleted." + value = element(concat(oci_core_volume_group.core_volume_group.*.expiration_time, [""]), 0) +} + +output "core_volume_group_id" { + description = "The OCID of the volume group backup." + value = element(concat(oci_core_volume_group.core_volume_group.*.id, [""]), 0) +} + +output "core_volume_group_size_in_gbs" { + description = "The aggregate size of the volume group backup, in GBs." + value = element(concat(oci_core_volume_group.core_volume_group.*.size_in_gbs, [""]), 0) +} + +output "core_volume_group_size_in_mbs" { + description = "The aggregate size of the volume group backup, in MBs." + value = element(concat(oci_core_volume_group.core_volume_group.*.size_in_mbs, [""]), 0) +} + +output "core_volume_group_source_type" { + description = "Specifies whether the volume group backup was created manually, or via scheduled backup policy." + value = element(concat(oci_core_volume_group.core_volume_group.*.source_type, [""]), 0) +} + +output "core_volume_group_source_volume_group_backup_id" { + description = "The OCID of the source volume group backup." + value = element(concat(oci_core_volume_group.core_volume_group.*.source_volume_group_backup_id, [""]), 0) +} + +output "core_volume_group_state" { + description = "The current state of a volume group backup." + value = element(concat(oci_core_volume_group.core_volume_group.*.state, [""]), 0) +} + +output "core_volume_group_time_request_received" { + description = "The date and time the request to create the volume group backup was received. Format defined by RFC3339." + value = element(concat(oci_core_volume_group.core_volume_group.*.time_request_received, [""]), 0) +} + +output "core_volume_group_type" { + description = "The type of backup." + value = element(concat(oci_core_volume_group.core_volume_group.*.type, [""]), 0) +} + +output "core_volume_group_unique_size_in_gbs" { + description = "The aggregate size used by the volume group backup, in GBs. It is typically smaller than size_in_gbs, depending on the space consumed on the volume group and whether the volume backup is full or incremental." + value = element(concat(oci_core_volume_group.core_volume_group.*.unique_size_in_gbs, [""]), 0) +} + +output "core_volume_group_unique_size_in_mbs" { + description = "The aggregate size used by the volume group backup, in MBs. It is typically smaller than size_in_mbs, depending on the space consumed on the volume group and whether the volume backup is full or incremental." + value = element(concat(oci_core_volume_group.core_volume_group.*.unique_size_in_mbs, [""]), 0) +} + +output "core_volume_group_volume_backup_ids" { + description = "OCIDs for the volume backups in this volume group backup." + value = element(concat(oci_core_volume_group.core_volume_group.*.volume_backup_ids, [""]), 0) +} + +output "core_volume_group_volume_group_id" { + description = "The OCID of the source volume group." + value = element(concat(oci_core_volume_group.core_volume_group.*.volume_group_id, [""]), 0) +} + +#----------------------------------------------------------- +# core volume backup +#----------------------------------------------------------- +output "core_volume_backup_compartment_id" { + description = "The OCID of the compartment that contains the volume backup." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.compartment_id, [""]), 0) +} + +output "core_volume_backup_display_name" { + description = "A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.display_name, [""]), 0) +} + +output "core_volume_backup_expiration_time" { + description = "The date and time the volume backup will expire and be automatically deleted. Format defined by RFC3339. This parameter will always be present for backups that were created automatically by a scheduled-backup policy. For manually created backups, it will be absent, signifying that there is no expiration time and the backup will last forever until manually deleted." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.expiration_time, [""]), 0) +} + +output "core_volume_backup_id" { + description = "The OCID of the volume backup." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.id, [""]), 0) +} + +output "core_volume_backup_kms_key_id" { + description = "The OCID of the Vault service key which is the master encryption key for the volume backup. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.kms_key_id, [""]), 0) +} + +output "core_volume_backup_size_in_gbs" { + description = "The size of the volume, in GBs." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.size_in_gbs, [""]), 0) +} + +output "core_volume_backup_size_in_mbs" { + description = "The size of the volume in MBs. The value must be a multiple of 1024. This field is deprecated. Please use size_in_gbs." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.size_in_mbs, [""]), 0) +} + +output "core_volume_backup_source_type" { + description = "Specifies whether the backup was created manually, or via scheduled backup policy." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.source_type, [""]), 0) +} + +output "core_volume_backup_source_volume_backup_id" { + description = "The OCID of the source volume backup." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.source_volume_backup_id, [""]), 0) +} + +output "core_volume_backup_state" { + description = "The current state of a volume backup." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.state, [""]), 0) +} + +output "core_volume_backup_time_request_received" { + description = "The date and time the request to create the volume backup was received. Format defined by [RFC3339]https://tools.ietf.org/html/rfc3339." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.time_request_received, [""]), 0) +} + +output "core_volume_backup_type" { + description = "The type of a volume backup. Supported values are 'FULL' or 'INCREMENTAL'." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.type, [""]), 0) +} + +output "core_volume_backup_unique_size_in_gbs" { + description = "The size used by the backup, in GBs. It is typically smaller than sizeInGBs, depending on the space consumed on the volume and whether the backup is full or incremental." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.unique_size_in_gbs, [""]), 0) +} + +output "core_volume_backup_unique_size_in_mbs" { + description = "The size used by the backup, in MBs. It is typically smaller than sizeInMBs, depending on the space consumed on the volume and whether the backup is full or incremental. This field is deprecated. Please use uniqueSizeInGBs." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.unique_size_in_mbs, [""]), 0) +} + +output "core_volume_backup_volume_id" { + description = "The OCID of the volume." + value = element(concat(oci_core_volume_backup.core_volume_backup.*.volume_id, [""]), 0) +} + +#----------------------------------------------------------- +# core volume_ backup policy +#----------------------------------------------------------- +output "core_volume_backup_policy_compartment_id" { + description = "The OCID of the compartment that contains the volume backup." + value = element(concat(oci_core_volume_backup_policy.core_volume_backup_policy.*.compartment_id, [""]), 0) +} + +output "core_volume_backup_policy_destination_region" { + description = "The paired destination region for copying scheduled backups to. Example us-ashburn-1. See Region Pairs for details about paired regions." + value = element(concat(oci_core_volume_backup_policy.core_volume_backup_policy.*.destination_region, [""]), 0) +} + +output "core_volume_backup_policy_display_name" { + description = "A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + value = element(concat(oci_core_volume_backup_policy.core_volume_backup_policy.*.display_name, [""]), 0) +} + +output "core_volume_backup_policy_id" { + description = "The OCID of the volume backup policy." + value = element(concat(oci_core_volume_backup_policy.core_volume_backup_policy.*.id, [""]), 0) +} + +output "core_volume_backup_policy_schedules" { + description = "The collection of schedules that this policy will apply." + value = concat(oci_core_volume_backup_policy.core_volume_backup_policy.*.schedules, [""]) +} + +#----------------------------------------------------------- +# core volume backup policy assignment +#----------------------------------------------------------- +output "core_volume_backup_policy_assignment_asset_id" { + description = "The OCID of the volume or volume group the policy has been assigned to." + value = element(concat(oci_core_volume_backup_policy_assignment.core_volume_backup_policy_assignment.*.asset_id, [""]), 0) +} + +output "core_volume_backup_policy_assignment_id" { + description = "The OCID of the volume backup policy assignment." + value = element(concat(oci_core_volume_backup_policy_assignment.core_volume_backup_policy_assignment.*.id, [""]), 0) +} + +output "core_volume_backup_policy_assignment_policy_id" { + description = "The OCID of the volume backup policy that has been assigned to the volume or volume group. For a volume group, only the user defined policy is allowed to use. For more information, see Policy-Based Backups." + value = element(concat(oci_core_volume_backup_policy_assignment.core_volume_backup_policy_assignment.*.policy_id, [""]), 0) +} + +output "core_volume_backup_policy_assignment_xrc_kms_key_id" { + description = "The OCID of the Vault service key which is the master encryption key for the block / boot volume cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys." + value = element(concat(oci_core_volume_backup_policy_assignment.core_volume_backup_policy_assignment.*.xrc_kms_key_id, [""]), 0) +} + +#----------------------------------------------------------- +# core volume attachment +#----------------------------------------------------------- +output "core_volume_attachment_port" { + description = "The volume's iSCSI port, usually port 860 or 3260. Example: 3260" + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.port, [""]), 0) +} + +output "core_volume_attachment_state" { + description = "The current state of the volume attachment." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.state, [""]), 0) +} + +output "core_volume_attachment_volume_id" { + description = "The OCID of the volume." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.volume_id, [""]), 0) +} + +output "core_volume_attachment_is_multipath" { + description = "Whether the Iscsi or Paravirtualized attachment is multipath or not, it is not applicable to NVMe attachment." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.is_multipath, [""]), 0) +} + +output "core_volume_attachment_is_pv_encryption_in_transit_enabled" { + description = "Whether in-transit encryption for the data volume's paravirtualized attachment is enabled or not." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.is_pv_encryption_in_transit_enabled, [""]), 0) +} + +output "core_volume_attachment_is_read_only" { + description = "Whether the attachment was created in read-only mode." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.is_read_only, [""]), 0) +} + +output "core_volume_attachment_iscsi_login_state" { + description = "The iscsi login state of the volume attachment. For a Iscsi volume attachment, all iscsi sessions need to be all logged-in or logged-out to be in logged-in or logged-out state." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.iscsi_login_state, [""]), 0) +} + +output "core_volume_attachment_is_volume_created_during_launch" { + description = "Flag indicating if this volume was created for the customer as part of a simplified launch. Used to determine whether the volume requires deletion on instance termination." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.is_volume_created_during_launch, [""]), 0) +} + +output "core_volume_attachment_iscsi_login_state" { + description = "The iscsi login state of the volume attachment. For a Iscsi volume attachment, all iscsi sessions need to be all logged-in or logged-out to be in logged-in or logged-out state." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.iscsi_login_state, [""]), 0) +} + +output "core_volume_attachment_chap_secret" { + description = "The Challenge-Handshake-Authentication-Protocol (CHAP) secret valid for the associated CHAP user name." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.chap_secret, [""]), 0) +} + +output "core_volume_attachment_chap_username" { + description = "The volume's system-generated Challenge-Handshake-Authentication-Protocol (CHAP) user name. See RFC 1994 for more on CHAP. Example: ocid1.volume.oc1.phx." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.chap_username, [""]), 0) +} + +output "core_volume_attachment_compartment_id" { + description = "The OCID of the compartment." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.compartment_id, [""]), 0) +} + +output "core_volume_attachment_device" { + description = "The device name." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.device, [""]), 0) +} + +output "core_volume_attachment_display_name" { + description = "A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.display_name, [""]), 0) +} + +output "core_volume_attachment_encryption_in_transit_type" { + description = "Refer the top-level definition of encryptionInTransitType. The default value is NONE." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.encryption_in_transit_type, [""]), 0) +} + +output "core_volume_attachment_id" { + description = "The OCID of the volume attachment." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.id, [""]), 0) +} + +output "core_volume_attachment_instance_id" { + description = "The OCID of the instance the volume is attached to." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.instance_id, [""]), 0) +} + +output "core_volume_attachment_ipv4" { + description = "The volume's iSCSI IP address. Example: 169.254.0.2" + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.ipv4, [""]), 0) +} + +output "core_volume_attachment_iqn" { + description = "The target volume's iSCSI Qualified Name in the format defined by RFC 3720. Example: iqn.2015-12.us.oracle.com:" + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.iqn, [""]), 0) +} + +output "core_volume_attachment_is_agent_auto_iscsi_login_enabled" { + description = "Whether Oracle Cloud Agent is enabled perform the iSCSI login and logout commands after the volume attach or detach operations for non multipath-enabled iSCSI attachments." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.is_agent_auto_iscsi_login_enabled, [""]), 0) +} + +output "core_volume_attachment_attachment_type" { + description = "The type of volume attachment." + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.attachment_type, [""]), 0) +} + +output "core_volume_attachment_availability_domain" { + description = "The availability domain of an instance. Example: Uocm:PHX-AD-1" + value = element(concat(oci_core_volume_attachment.core_volume_attachment.*.availability_domain, [""]), 0) +} diff --git a/oracle_cloud/modules/core_volume/variables.tf b/oracle_cloud/modules/core_volume/variables.tf new file mode 100644 index 00000000..9925e3ae --- /dev/null +++ b/oracle_cloud/modules/core_volume/variables.tf @@ -0,0 +1,514 @@ +#----------------------------------------------------------- +# Global +#----------------------------------------------------------- +variable "name" { + description = "The name for resources" + default = "test" +} + +variable "environment" { + description = "The environment for resources" + default = "dev" +} + +variable "tags" { + description = "Add additional tags" + default = {} +} + +#----------------------------------------------------------- +# core boot volume +#----------------------------------------------------------- +variable "enable_core_boot_volume" { + description = "Enable core boot volume usages" + default = false +} + +variable "core_boot_volume_compartment_id" { + description = "(Required) (Updatable) The OCID of the compartment that contains the boot volume." + default = null +} + +variable "core_boot_volume_source_details" { + description = "(Required) - Set list of boot volume source details" + default = [] +} + +variable "volume_source_details_type" { + description = "(Optional) Specifies the volume source details for a new Block volume. The volume source is either another Block volume in the same Availability Domain or a Block volume backup. This is an optional field. If not specified or set to null, the new Block volume will be empty. When specified, the new Block volume will contain data from the source volume or backup." + default = [] +} + +variable "core_boot_volume_availability_domain" { + description = "(Optional) The availability domain of the volume. Omissible for cloning a volume. The new volume will be created in the availability domain of the source volume. Example: Uocm:PHX-AD-1" + default = null +} + +variable "core_boot_volume_backup_policy_id" { + description = "(Optional) If provided, specifies the ID of the boot volume backup policy to assign to the newly created boot volume. If omitted, no policy will be assigned. This field is deprecated. Use the oci_core_volume_backup_policy_assignments instead to assign a backup policy to a boot volume." + default = null +} + +variable "core_boot_volume_cluster_placement_group_id" { + description = "(Optional) The clusterPlacementGroup Id of the volume for volume placement." + default = null +} + +variable "core_boot_volume_display_name" { + description = "(Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + default = null +} + +variable "core_boot_volume_is_auto_tune_enabled" { + description = "(Optional) (Updatable) Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the DetachedVolumeAutotunePolicy instead to enable the volume for detached autotune." + default = null +} + +variable "core_boot_volume_kms_key_id" { + description = "(Optional) (Updatable) The OCID of the Vault service key to assign as the master encryption key for the boot volume." + default = null +} + +variable "core_boot_volume_size_in_gbs" { + description = "(Optional) (Updatable) The size of the volume in GBs." + default = null +} + +variable "core_boot_volume_vpus_per_gb" { + description = "(Optional) (Updatable) The number of volume performance units (VPUs) that will be applied to this volume per GB, representing the Block Volume service's elastic performance options. See Block Volume Performance Levels for more information." + default = null +} + +variable "core_boot_volume_xrc_kms_key_id" { + description = "(Optional) The OCID of the Vault service key which is the master encryption key for the boot volume cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys." + default = null +} + +variable "core_boot_volume_boot_volume_replicas_deletion" { + description = "Set boot volume replicas deletion usages" + default = null +} + +variable "core_boot_volume_autotune_policies" { + description = "(Optional) (Updatable) The list of autotune policies to be enabled for this volume." + default = [] +} + +variable "core_boot_volume_boot_volume_replicas" { + description = "(Optional) (Updatable) The list of boot volume replicas to be enabled for this boot volume in the specified destination availability domains." + default = [] +} + +variable "core_boot_volume_freeform_tags" { + description = "(Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags" + default = {} +} + +variable "core_boot_volume_timeouts" { + description = "The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Boot Volume * update - (Defaults to 20 minutes), when updating the Boot Volume * delete - (Defaults to 20 minutes), when destroying the Boot Volume" + default = {} +} + +#----------------------------------------------------------- +# core boot volume backup +#----------------------------------------------------------- +variable "enable_core_boot_volume_backup" { + description = "Enable core boot volume backup usages" + default = false +} + +variable "core_boot_volume_backup_boot_volume_id" { + description = "The OCID of the source volume backup." + default = "" +} + +variable "core_boot_volume_backup_display_name" { + description = "(Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + default = null +} + +variable "core_boot_volume_backup_kms_key_id" { + description = "(Optional) (Updatable) The OCID of the Vault service key which is the master encryption key for the volume backup. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys." + default = null +} + +variable "core_boot_volume_backup_type" { + description = "(Optional) The type of backup to create. If omitted, defaults to incremental. Supported values are 'FULL' or 'INCREMENTAL'." + default = null +} + +variable "core_boot_volume_backup_freeform_tags" { + description = "(Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags." + default = {} +} + +variable "core_boot_volume_backup_timeouts" { + description = "The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Boot Volume Backup * update - (Defaults to 20 minutes), when updating the Boot Volume Backup * delete - (Defaults to 20 minutes), when destroying the Boot Volume Backup" + default = {} +} + +#----------------------------------------------------------- +# core volume +#----------------------------------------------------------- +variable "enable_core_volume" { + description = "Enable core volume usages" + default = false +} + +variable "core_volume_compartment_id" { + description = "(Required) (Updatable) The OCID of the compartment that contains the volume." + default = null +} + +variable "core_volume_availability_domain" { + description = "(Optional) The availability domain of the volume. Omissible for cloning a volume. The new volume will be created in the availability domain of the source volume. Example: Uocm:PHX-AD-1" + default = null +} + +variable "core_volume_backup_policy_id" { + description = "(Optional) If provided, specifies the ID of the volume backup policy to assign to the newly created volume. If omitted, no policy will be assigned. This field is deprecated. Use the oci_core_volume_backup_policy_assignments instead to assign a backup policy to a volume." + default = null +} + +variable "core_volume_cluster_placement_group_id" { + description = "(Optional) The clusterPlacementGroup Id of the volume for volume placement." + default = null +} + +variable "core_volume_display_name" { + description = "(Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + default = null +} + +variable "core_volume_is_auto_tune_enabled" { + description = "(Optional) (Updatable) Specifies whether the auto-tune performance is enabled for this volume. This field is deprecated. Use the DetachedVolumeAutotunePolicy instead to enable the volume for detached autotune." + default = null +} + +variable "core_volume_kms_key_id" { + description = "(Optional) (Updatable) The OCID of the Vault service key to assign as the master encryption key for the volume." + default = null +} + +variable "core_volume_size_in_gbs" { + description = "(Optional) (Updatable) The size of the volume in GBs." + default = null +} + +variable "core_volume_size_in_mbs" { + description = "(Optional) The size of the volume in MBs. The value must be a multiple of 1024. This field is deprecated. Use sizeInGBs instead." + default = null +} + +variable "core_volume_vpus_per_gb" { + description = "(Optional) (Updatable) The number of volume performance units (VPUs) that will be applied to this volume per GB, representing the Block Volume service's elastic performance options. See Block Volume Performance Levels for more information." + default = null +} + +variable "core_volume_xrc_kms_key_id" { + description = "(Optional) The OCID of the Vault service key which is the master encryption key for the block volume cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys." + default = null +} + +variable "core_volume_block_volume_replicas_deletion" { + description = "Set the replicas deletion for volume" + default = null +} + +variable "core_volume_autotune_policies" { + description = "(Optional) (Updatable) The list of autotune policies to be enabled for this volume." + default = [] +} + +variable "core_volume_block_volume_replicas" { + description = "(Optional) (Updatable) The list of block volume replicas to be enabled for this volume in the specified destination availability domains." + default = [] +} + +variable "core_volume_source_details" { + description = "(Optional) Specifies the volume source details for a new Block volume. The volume source is either another Block volume in the same Availability Domain or a Block volume backup. This is an optional field. If not specified or set to null, the new Block volume will be empty. When specified, the new Block volume will contain data from the source volume or backup." + default = [] +} + +variable "core_volume_freeform_tags" { + description = "(Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags." + default = {} +} + +variable "core_volume_timeouts" { + description = "The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume * update - (Defaults to 20 minutes), when updating the Volume * delete - (Defaults to 20 minutes), when destroying the Volume" + default = {} +} + +#----------------------------------------------------------- +# core volume group +#----------------------------------------------------------- +variable "enable_core_volume_group" { + description = "Enable core volume group usages" + default = false +} + +variable "core_volume_group_availability_domain" { + description = "(Required) The availability domain of the volume group." + default = null +} + +variable "core_volume_group_compartment_id" { + description = "(Required) (Updatable) The OCID of the compartment that contains the volume group." + default = null +} + +variable "core_volume_group_source_details" { + description = "(Required) Specifies the source for a volume group." + default = [] +} + +variable "core_volume_group_backup_policy_id" { + description = "(Optional) If provided, specifies the ID of the volume backup policy to assign to the newly created volume group. If omitted, no policy will be assigned. This field is deprecated. Use the oci_core_volume_backup_policy_assignments instead to assign a backup policy to a volume group." + default = null +} + +variable "core_volume_group_cluster_placement_group_id" { + description = "(Optional) The clusterPlacementGroup Id of the volume group for volume group placement." + default = null +} + +variable "core_volume_group_display_name" { + description = "(Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + default = null +} + +variable "core_volume_group_volume_ids" { + description = "(Optional) (Updatable) Use this for update operation only. This field is not supported during creation. For create use volume_ids under source_details" + default = null +} + +variable "core_volume_group_xrc_kms_key_id" { + description = "(Optional) The OCID of the Vault service key which is the master encryption key for the volume's cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys." + default = null +} + +variable "core_volume_group_volume_group_replicas" { + description = "(Optional) (Updatable) The list of volume group replicas that this volume group will be enabled to have in the specified destination availability domains." + default = [] +} + +variable "core_volume_group_freeform_tags" { + description = "(Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags." + default = {} +} + +variable "core_volume_group_timeouts" { + description = "The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Group * update - (Defaults to 20 minutes), when updating the Volume Group * delete - (Defaults to 20 minutes), when destroying the Volume Group" + default = {} +} + +#----------------------------------------------------------- +# core volume group backup +#----------------------------------------------------------- +variable "enable_core_volume_group_backup" { + description = "Enable core volume group backup usages" + default = false +} + +variable "core_volume_group_backup_volume_group_id" { + description = "(Required) The OCID of the volume group that needs to be backed up." + default = null +} + +variable "core_volume_group_backup_compartment_id" { + description = "(Optional) (Updatable) The OCID of the compartment that will contain the volume group backup. This parameter is optional, by default backup will be created in the same compartment and source volume group." + default = null +} + +variable "core_volume_group_backup_display_name" { + description = "(Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + default = null +} + +variable "core_volume_group_backup_type" { + description = "(Optional) The type of backup to create. If omitted, defaults to incremental." + default = null +} + +variable "core_volume_group_backup_freeform_tags" { + description = "(Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags." + default = {} +} + +variable "core_volume_group_backup_timeouts" { + description = "The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Group Backup * update - (Defaults to 20 minutes), when updating the Volume Group Backup * delete - (Defaults to 20 minutes), when destroying the Volume Group Backup" + default = {} +} + +#----------------------------------------------------------- +# core volume backup +#----------------------------------------------------------- +variable "enable_core_volume_backup" { + description = "Enable core volume backup usages" + default = false +} + +variable "core_volume_backup_volume_id" { + description = "(Optional) The OCID of the volume that needs to be backed up.**Note: To create the resource either volume_id or source_details is required to be set." + default = null +} + +variable "core_volume_backup_display_name" { + description = "(Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + default = null +} + +variable "core_volume_backup_kms_key_id" { + description = "(Optional) (Updatable) The OCID of the Vault service key which is the master encryption key for the volume backup. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys." + default = null +} + +variable "core_volume_backup_type" { + description = "(Optional) The type of backup to create. If omitted, defaults to INCREMENTAL. Supported values are 'FULL' or 'INCREMENTAL'." + default = null +} + +variable "core_volume_backup_freeform_tags" { + description = "(Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags." + default = {} +} + +variable "core_volume_backup_timeouts" { + description = "The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Backup * update - (Defaults to 20 minutes), when updating the Volume Backup * delete - (Defaults to 20 minutes), when destroying the Volume Backup" + default = {} +} + +#----------------------------------------------------------- +# core volume_ backup policy +#----------------------------------------------------------- +variable "enable_core_volume_backup_policy" { + description = "Enable core volume backup policy usages" + default = false +} + +variable "core_volume_backup_policy_compartment_id" { + description = "(Required) The OCID of the compartment." + default = null +} + +variable "core_volume_backup_policy_destination_region" { + description = "(Optional) (Updatable) The paired destination region for copying scheduled backups to. Example: us-ashburn-1. See Region Pairs for details about paired regions." + default = null +} + +variable "core_volume_backup_policy_display_name" { + description = "(Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + default = null +} + +variable "core_volume_backup_policy_schedules" { + description = "(Optional) (Updatable) The collection of schedules for the volume backup policy. See see Schedules in Policy-Based Backups for more information." + default = [] +} + +variable "core_volume_backup_policy_freeform_tags" { + description = "(Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags." + default = {} +} + +variable "core_volume_backup_policy_timeouts" { + description = "The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Backup Policy * update - (Defaults to 20 minutes), when updating the Volume Backup Policy * delete - (Defaults to 20 minutes), when destroying the Volume Backup Policy" + default = {} +} + +#----------------------------------------------------------- +# core volume backup policy assignment +#----------------------------------------------------------- +variable "enable_core_volume_backup_policy_assignment" { + description = "Enable core volume backup policy assignment usages" + default = false +} + +variable "core_volume_backup_policy_assignment_asset_id" { + description = "The OCID of the volume or volume group to assign the policy to." + default = "" +} + +variable "core_volume_backup_policy_assignment_policy_id" { + description = "The OCID of the volume backup policy to assign to the volume." + default = "" +} + +variable "core_volume_backup_policy_assignment_xrc_kms_key_id" { + description = "(Optional) The OCID of the Vault service key which is the master encryption key for the block / boot volume cross region backups, which will be used in the destination region to encrypt the backup's encryption keys. For more information about the Vault service and encryption keys, see Overview of Vault service and Using Keys." + default = null +} + +variable "core_volume_backup_policy_assignment_timeouts" { + description = "The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Backup Policy Assignment * update - (Defaults to 20 minutes), when updating the Volume Backup Policy Assignment * delete - (Defaults to 20 minutes), when destroying the Volume Backup Policy Assignment" + default = {} +} + +#----------------------------------------------------------- +# core volume attachment +#----------------------------------------------------------- +variable "enable_core_volume_attachment" { + description = "Enable core volume attachment usages" + default = false +} + +variable "core_volume_attachment_attachment_type" { + description = "(Required) The type of volume. The only supported values are 'iscsi' and 'paravirtualized'." + default = null +} + +variable "core_volume_attachment_instance_id" { + description = "(Required) The OCID of the instance." + default = null +} + +variable "core_volume_attachment_volume_id" { + description = "The OCID of the volume." + default = "" +} + +variable "core_volume_attachment_device" { + description = "(Optional) The device name. To retrieve a list of devices for a given instance, see ListInstanceDevices." + default = null +} + +variable "core_volume_attachment_display_name" { + description = "(Optional) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information." + default = null +} + +variable "core_volume_attachment_encryption_in_transit_type" { + description = "(Applicable when attachment_type=iscsi) Refer the top-level definition of encryptionInTransitType. The default value is NONE." + default = null +} + +variable "core_volume_attachment_is_agent_auto_iscsi_login_enabled" { + description = "(Applicable when attachment_type=iscsi) Whether to enable Oracle Cloud Agent to perform the iSCSI login and logout commands after the volume attach or detach operations for non multipath-enabled iSCSI attachments." + default = null +} + +variable "core_volume_attachment_is_pv_encryption_in_transit_enabled" { + description = "(Applicable when attachment_type=paravirtualized) Whether to enable in-transit encryption for the data volume's paravirtualized attachment. The default value is false." + default = null +} + +variable "core_volume_attachment_is_read_only" { + description = "(Optional) Whether the attachment was created in read-only mode." + default = null +} + +variable "core_volume_attachment_is_shareable" { + description = "(Optional) Whether the attachment should be created in shareable mode. If an attachment is created in shareable mode, then other instances can attach the same volume, provided that they also create their attachments in shareable mode. Only certain volume types can be attached in shareable mode. Defaults to false if not specified." + default = null +} + +variable "core_volume_attachment_use_chap" { + description = "(Applicable when attachment_type=iscsi) Whether to use CHAP authentication for the volume attachment. Defaults to false." + default = null +} + +variable "core_volume_attachment_timeouts" { + description = "The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Volume Attachment * update - (Defaults to 20 minutes), when updating the Volume Attachment * delete - (Defaults to 20 minutes), when destroying the Volume Attachment" + default = {} +} diff --git a/oracle_cloud/modules/core_volume/volume.tf b/oracle_cloud/modules/core_volume/volume.tf new file mode 100644 index 00000000..f9199b53 --- /dev/null +++ b/oracle_cloud/modules/core_volume/volume.tf @@ -0,0 +1,92 @@ +#----------------------------------------------------------- +# core volume +#----------------------------------------------------------- +resource "oci_core_volume" "core_volume" { + count = var.enable_core_volume ? 1 : 0 + + # Required + compartment_id = var.core_volume_compartment_id + + # Optional + availability_domain = var.core_volume_availability_domain + backup_policy_id = var.core_volume_backup_policy_id + cluster_placement_group_id = var.core_volume_cluster_placement_group_id + display_name = var.core_volume_display_name != "" ? var.core_volume_display_name : "${lower(var.name)}-volume-${lower(var.environment)}" + is_auto_tune_enabled = var.core_volume_is_auto_tune_enabled + kms_key_id = var.core_volume_kms_key_id + size_in_gbs = var.core_volume_size_in_gbs + size_in_mbs = var.core_volume_size_in_mbs + vpus_per_gb = var.core_volume_vpus_per_gb + xrc_kms_key_id = var.core_volume_xrc_kms_key_id + block_volume_replicas_deletion = var.core_volume_block_volume_replicas_deletion + + dynamic "autotune_policies" { + iterator = autotune_policies + for_each = length(keys(var.core_volume_autotune_policies)) > 0 ? [var.core_volume_autotune_policies] : [] + + content { + # Required + autotune_type = lookup(autotune_policies.value, "autotune_type", null) + + #Optional + max_vpus_per_gb = lookup(autotune_policies.value, "autotune_type", null) + } + } + + dynamic "block_volume_replicas" { + iterator = block_volume_replicas + for_each = length(keys(var.core_volume_block_volume_replicas)) > 0 ? [var.core_volume_block_volume_replicas] : [] + + content { + # Required + availability_domain = lookup(block_volume_replicas.value, "availability_domain", null) + + # Optional + display_name = lookup(block_volume_replicas.value, "display_name", null) + xrr_kms_key_id = lookup(block_volume_replicas.value, "xrr_kms_key_id", null) + } + } + + dynamic "source_details" { + iterator = source_details + for_each = length(keys(var.core_volume_source_details)) > 0 ? [var.core_volume_source_details] : [] + + content { + # Required + type = var.volume_source_details_type + + # Optional + change_block_size_in_bytes = lookup(source_details.value, "change_block_size_in_bytes", null) + first_backup_id = lookup(source_details.value, "first_backup_id", null) + id = lookup(source_details.value, "id", null) + second_backup_id = lookup(source_details.value, "second_backup_id", null) + } + } + + defined_tags = merge( + { + Name = var.core_volume_display_name != "" ? var.core_volume_display_name : "${lower(var.name)}-volume-${lower(var.environment)}" + }, + var.tags + ) + freeform_tags = var.core_volume_freeform_tags + + dynamic "timeouts" { + iterator = timeouts + for_each = length(keys(var.core_volume_timeouts)) > 0 ? [var.core_volume_timeouts] : [] + + content { + create = lookup(timeouts.value, "create", null) + update = lookup(timeouts.value, "update", null) + delete = lookup(timeouts.value, "delete", null) + } + } + + lifecycle { + create_before_destroy = true + ignore_changes = [] + } + + depends_on = [] + +} \ No newline at end of file diff --git a/oracle_cloud/modules/core_volume/volume_attachment.tf b/oracle_cloud/modules/core_volume/volume_attachment.tf new file mode 100644 index 00000000..1d0e0cb1 --- /dev/null +++ b/oracle_cloud/modules/core_volume/volume_attachment.tf @@ -0,0 +1,39 @@ +#----------------------------------------------------------- +# core volume attachment +#----------------------------------------------------------- +resource "oci_core_volume_attachment" "core_volume_attachment" { + count = var.enable_core_volume_attachment ? 1 : 0 + + # Required + attachment_type = var.core_volume_attachment_attachment_type + instance_id = var.core_volume_attachment_instance_id + volume_id = var.core_volume_attachment_volume_id != "" && !var.enable_core_volume ? var.core_volume_attachment_volume_id : (var.enable_core_volume ? element(oci_core_volume.core_volume.*.id, 0) : null) + + # Optional + device = var.core_volume_attachment_device + display_name = var.core_volume_attachment_display_name + encryption_in_transit_type = var.core_volume_attachment_encryption_in_transit_type + is_agent_auto_iscsi_login_enabled = var.core_volume_attachment_is_agent_auto_iscsi_login_enabled + is_pv_encryption_in_transit_enabled = var.core_volume_attachment_is_pv_encryption_in_transit_enabled + is_read_only = var.core_volume_attachment_is_read_only + is_shareable = var.core_volume_attachment_is_shareable + use_chap = var.core_volume_attachment_use_chap + + dynamic "timeouts" { + iterator = timeouts + for_each = length(keys(var.core_volume_attachment_timeouts)) > 0 ? [var.core_volume_attachment_timeouts] : [] + + content { + create = lookup(timeouts.value, "create", null) + update = lookup(timeouts.value, "update", null) + delete = lookup(timeouts.value, "delete", null) + } + } + + lifecycle { + create_before_destroy = true + ignore_changes = [] + } + + depends_on = [] +} \ No newline at end of file diff --git a/oracle_cloud/modules/core_volume/volume_backup.tf b/oracle_cloud/modules/core_volume/volume_backup.tf new file mode 100644 index 00000000..0b776e12 --- /dev/null +++ b/oracle_cloud/modules/core_volume/volume_backup.tf @@ -0,0 +1,40 @@ +#----------------------------------------------------------- +# core volume backup +#----------------------------------------------------------- +resource "oci_core_volume_backup" "core_volume_backup" { + count = var.enable_core_volume_backup ? 1 : 0 + + # Required + volume_id = var.core_volume_backup_volume_id != "" && !var.enable_core_volume ? var.core_volume_backup_volume_id : (var.enable_core_volume ? element(oci_core_volume_group.core_volume_group.*.id, 0) : null) + + # Optional + display_name = var.core_volume_backup_display_name + kms_key_id = var.core_volume_backup_kms_key_id + type = var.core_volume_backup_type + + defined_tags = merge( + { + Name = var.core_volume_backup_display_name != "" ? var.core_volume_backup_display_name : "${lower(var.name)}-volume-backup-${lower(var.environment)}" + }, + var.tags + ) + freeform_tags = var.core_volume_backup_freeform_tags + + dynamic "timeouts" { + iterator = timeouts + for_each = length(keys(var.core_volume_backup_timeouts)) > 0 ? [var.core_volume_backup_timeouts] : [] + + content { + create = lookup(timeouts.value, "create", null) + update = lookup(timeouts.value, "update", null) + delete = lookup(timeouts.value, "delete", null) + } + } + + lifecycle { + create_before_destroy = true + ignore_changes = [] + } + + depends_on = [] +} \ No newline at end of file diff --git a/oracle_cloud/modules/core_volume/volume_backup_policy.tf b/oracle_cloud/modules/core_volume/volume_backup_policy.tf new file mode 100644 index 00000000..6b0acffe --- /dev/null +++ b/oracle_cloud/modules/core_volume/volume_backup_policy.tf @@ -0,0 +1,60 @@ +#----------------------------------------------------------- +# core volume backup policy +#----------------------------------------------------------- +resource "oci_core_volume_backup_policy" "core_volume_backup_policy" { + count = var.enable_core_volume_backup_policy ? 1 : 0 + + # Required + compartment_id = var.core_volume_backup_policy_compartment_id + + # Optional + destination_region = var.core_volume_backup_policy_destination_region + display_name = var.core_volume_backup_policy_display_name != "" ? var.core_volume_backup_policy_display_name : "${lower(var.name)}-volume-backup-policy-${lower(var.environment)}" + + dynamic "schedules" { + iterator = schedules + for_each = var.core_volume_backup_policy_schedules + + content { + # Required + backup_type = lookup(schedules.value, "backup_type", null) + period = lookup(schedules.value, "period", null) + retention_seconds = lookup(schedules.value, "retention_seconds", null) + + # Optional + day_of_month = lookup(schedules.value, "day_of_month", null) + day_of_week = lookup(schedules.value, "day_of_week", null) + hour_of_day = lookup(schedules.value, "hour_of_day", null) + month = lookup(schedules.value, "month", null) + offset_seconds = lookup(schedules.value, "offset_seconds", null) + offset_type = lookup(schedules.value, "offset_type", null) + time_zone = lookup(schedules.value, "time_zone", null) + } + } + + defined_tags = merge( + { + Name = var.core_volume_backup_policy_display_name != "" ? var.core_volume_backup_policy_display_name : "${lower(var.name)}-volume-backup-policy-${lower(var.environment)}" + }, + var.tags + ) + freeform_tags = var.core_volume_backup_policy_freeform_tags + + dynamic "timeouts" { + iterator = timeouts + for_each = length(keys(var.core_volume_backup_policy_timeouts)) > 0 ? [var.core_volume_backup_policy_timeouts] : [] + + content { + create = lookup(timeouts.value, "create", null) + update = lookup(timeouts.value, "update", null) + delete = lookup(timeouts.value, "delete", null) + } + } + + lifecycle { + create_before_destroy = true + ignore_changes = [] + } + + depends_on = [] +} \ No newline at end of file diff --git a/oracle_cloud/modules/core_volume/volume_backup_policy_assignment.tf b/oracle_cloud/modules/core_volume/volume_backup_policy_assignment.tf new file mode 100644 index 00000000..e547fce9 --- /dev/null +++ b/oracle_cloud/modules/core_volume/volume_backup_policy_assignment.tf @@ -0,0 +1,31 @@ +#----------------------------------------------------------- +# core volume backup policy assignment +#----------------------------------------------------------- +resource "oci_core_volume_backup_policy_assignment" "core_volume_backup_policy_assignment" { + count = var.enable_core_volume_backup_policy_assignment ? 1 : 0 + + # Required + asset_id = var.core_volume_backup_policy_assignment_asset_id != "" && !var.enable_core_volume ? var.core_volume_backup_policy_assignment_asset_id : (var.enable_core_volume ? element(oci_core_volume.core_volume.*.id, 0) : null) + policy_id = var.core_volume_backup_policy_assignment_policy_id != "" && !var.enable_core_volume_backup_policy ? var.core_volume_backup_policy_assignment_policy_id : (var.enable_core_volume_backup_policy ? element(oci_core_volume_backup_policy.core_volume_backup_policy.*.id, 0) : null) + + # Optional + xrc_kms_key_id = var.core_volume_backup_policy_assignment_xrc_kms_key_id + + dynamic "timeouts" { + iterator = timeouts + for_each = length(keys(var.core_volume_backup_policy_assignment_timeouts)) > 0 ? [var.core_volume_backup_policy_assignment_timeouts] : [] + + content { + create = lookup(timeouts.value, "create", null) + update = lookup(timeouts.value, "update", null) + delete = lookup(timeouts.value, "delete", null) + } + } + + lifecycle { + create_before_destroy = true + ignore_changes = [] + } + + depends_on = [] +} \ No newline at end of file diff --git a/oracle_cloud/modules/core_volume/volume_group.tf b/oracle_cloud/modules/core_volume/volume_group.tf new file mode 100644 index 00000000..9dca6133 --- /dev/null +++ b/oracle_cloud/modules/core_volume/volume_group.tf @@ -0,0 +1,68 @@ +#----------------------------------------------------------- +# core volume group +#----------------------------------------------------------- +resource "oci_core_volume_group" "core_volume_group" { + count = var.enable_core_volume_group ? 1 : 0 + + # Required + availability_domain = var.core_volume_group_availability_domain + compartment_id = var.core_volume_group_compartment_id + + dynamic "source_details" { + iterator = source_details + for_each = var.core_volume_group_source_details + + content { + # Required + type = lookup(source_details.value, "type", null) + volume_ids = lookup(source_details.value, "volume_ids", null) + } + } + + # Optional + backup_policy_id = var.core_volume_group_backup_policy_id + cluster_placement_group_id = var.core_volume_group_cluster_placement_group_id + display_name = var.core_volume_group_display_name != "" ? var.core_volume_group_display_name : "${lower(var.name)}-volume-group-${lower(var.environment)}" + volume_ids = var.core_volume_group_volume_ids + xrc_kms_key_id = var.core_volume_group_xrc_kms_key_id + + dynamic "volume_group_replicas" { + iterator = volume_group_replicas + for_each = var.core_volume_group_volume_group_replicas + + content { + # Required + availability_domain = lookup(volume_group_replicas.value, "create", null) + + # Optional + display_name = lookup(volume_group_replicas.value, "display_name", null) + xrr_kms_key_id = lookup(volume_group_replicas.value, "xrr_kms_key_id", null) + } + } + + defined_tags = merge( + { + Name = var.core_volume_group_display_name != "" ? var.core_volume_group_display_name : "${lower(var.name)}-volume-group-${lower(var.environment)}" + }, + var.tags + ) + freeform_tags = var.core_volume_group_freeform_tags + + dynamic "timeouts" { + iterator = timeouts + for_each = length(keys(var.core_volume_group_timeouts)) > 0 ? [var.core_volume_group_timeouts] : [] + + content { + create = lookup(timeouts.value, "create", null) + update = lookup(timeouts.value, "update", null) + delete = lookup(timeouts.value, "delete", null) + } + } + + lifecycle { + create_before_destroy = true + ignore_changes = [] + } + + depends_on = [] +} \ No newline at end of file diff --git a/oracle_cloud/modules/core_volume/volume_group_backup.tf b/oracle_cloud/modules/core_volume/volume_group_backup.tf new file mode 100644 index 00000000..c75377e7 --- /dev/null +++ b/oracle_cloud/modules/core_volume/volume_group_backup.tf @@ -0,0 +1,40 @@ +#----------------------------------------------------------- +# core volume group backup +#----------------------------------------------------------- +resource "oci_core_volume_group_backup" "core_volume_group_backup" { + count = var.enable_core_volume_group_backup ? 1 : 0 + + # Required + volume_group_id = var.core_volume_group_backup_volume_group_id != "" && !var.enable_core_volume_group ? var.core_volume_group_backup_volume_group_id : (var.enable_core_volume_group ? element(oci_core_volume_group.core_volume_group.*.id, 0) : null) + + # Optional + compartment_id = var.core_volume_group_backup_compartment_id + display_name = var.core_volume_group_backup_display_name != "" ? var.core_volume_group_backup_display_name : "${lower(var.name)}-volume-group-backup-${lower(var.environment)}" + type = var.core_volume_group_backup_type + + defined_tags = merge( + { + Name = var.core_volume_group_backup_display_name != "" ? var.core_volume_group_backup_display_name : "${lower(var.name)}-volume-group-backup-${lower(var.environment)}" + }, + var.tags + ) + freeform_tags = var.core_volume_group_backup_freeform_tags + + dynamic "timeouts" { + iterator = timeouts + for_each = length(keys(var.core_volume_group_backup_timeouts)) > 0 ? [var.core_volume_group_backup_timeouts] : [] + + content { + create = lookup(timeouts.value, "create", null) + update = lookup(timeouts.value, "update", null) + delete = lookup(timeouts.value, "delete", null) + } + } + + lifecycle { + create_before_destroy = true + ignore_changes = [] + } + + depends_on = [] +} \ No newline at end of file diff --git a/oracle_cloud/modules/core_volumes/boot_volume.tf b/oracle_cloud/modules/core_volumes/boot_volume.tf deleted file mode 100644 index 7d2a6e0f..00000000 --- a/oracle_cloud/modules/core_volumes/boot_volume.tf +++ /dev/null @@ -1,5 +0,0 @@ -#----------------------------------------------------------- -# boot_volume -#----------------------------------------------------------- - -# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_boot_volume \ No newline at end of file diff --git a/oracle_cloud/modules/core_volumes/boot_volume_backup.tf b/oracle_cloud/modules/core_volumes/boot_volume_backup.tf deleted file mode 100644 index 9569ea6e..00000000 --- a/oracle_cloud/modules/core_volumes/boot_volume_backup.tf +++ /dev/null @@ -1,5 +0,0 @@ -#----------------------------------------------------------- -# boot_volume_backup -#----------------------------------------------------------- - -# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_boot_volume_backup \ No newline at end of file diff --git a/oracle_cloud/modules/core_volumes/outputs.tf b/oracle_cloud/modules/core_volumes/outputs.tf deleted file mode 100644 index ccb71a2d..00000000 --- a/oracle_cloud/modules/core_volumes/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -#----------------------------------------------------------- -# TMP -#----------------------------------------------------------- diff --git a/oracle_cloud/modules/core_volumes/variables.tf b/oracle_cloud/modules/core_volumes/variables.tf deleted file mode 100644 index aeaf4a81..00000000 --- a/oracle_cloud/modules/core_volumes/variables.tf +++ /dev/null @@ -1,17 +0,0 @@ -#----------------------------------------------------------- -# Global -#----------------------------------------------------------- -variable "name" { - description = "The name for resources" - default = "test" -} - -variable "environment" { - description = "The environment for resources" - default = "dev" -} - -#----------------------------------------------------------- -# TMP -#----------------------------------------------------------- - diff --git a/oracle_cloud/modules/core_volumes/volume.tf b/oracle_cloud/modules/core_volumes/volume.tf deleted file mode 100644 index d916e9b1..00000000 --- a/oracle_cloud/modules/core_volumes/volume.tf +++ /dev/null @@ -1,5 +0,0 @@ -#----------------------------------------------------------- -# core_volumes -#----------------------------------------------------------- - -# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_volume \ No newline at end of file diff --git a/oracle_cloud/modules/core_volumes/volume_attachment.tf b/oracle_cloud/modules/core_volumes/volume_attachment.tf deleted file mode 100644 index 87522ff1..00000000 --- a/oracle_cloud/modules/core_volumes/volume_attachment.tf +++ /dev/null @@ -1,5 +0,0 @@ -#----------------------------------------------------------- -# volume_attachment -#----------------------------------------------------------- - -# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_volume_attachment \ No newline at end of file diff --git a/oracle_cloud/modules/core_volumes/volume_backup.tf b/oracle_cloud/modules/core_volumes/volume_backup.tf deleted file mode 100644 index 886755d7..00000000 --- a/oracle_cloud/modules/core_volumes/volume_backup.tf +++ /dev/null @@ -1,5 +0,0 @@ -#----------------------------------------------------------- -# volume_backup -#----------------------------------------------------------- - -# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_volume_backup \ No newline at end of file diff --git a/oracle_cloud/modules/core_volumes/volume_backup_policy.tf b/oracle_cloud/modules/core_volumes/volume_backup_policy.tf deleted file mode 100644 index 660af381..00000000 --- a/oracle_cloud/modules/core_volumes/volume_backup_policy.tf +++ /dev/null @@ -1,5 +0,0 @@ -#----------------------------------------------------------- -# volume_backup_policy -#----------------------------------------------------------- - -# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_volume_backup_policy \ No newline at end of file diff --git a/oracle_cloud/modules/core_volumes/volume_backup_policy_assignment.tf b/oracle_cloud/modules/core_volumes/volume_backup_policy_assignment.tf deleted file mode 100644 index 210902b2..00000000 --- a/oracle_cloud/modules/core_volumes/volume_backup_policy_assignment.tf +++ /dev/null @@ -1,5 +0,0 @@ -#----------------------------------------------------------- -# volume_backup_policy_assignment -#----------------------------------------------------------- - -# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_volume_backup_policy_assignment \ No newline at end of file diff --git a/oracle_cloud/modules/core_volumes/volume_group.tf b/oracle_cloud/modules/core_volumes/volume_group.tf deleted file mode 100644 index ce2482eb..00000000 --- a/oracle_cloud/modules/core_volumes/volume_group.tf +++ /dev/null @@ -1,5 +0,0 @@ -#----------------------------------------------------------- -# volume_group -#----------------------------------------------------------- - -# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_volume_group \ No newline at end of file diff --git a/oracle_cloud/modules/core_volumes/volume_group_backup.tf b/oracle_cloud/modules/core_volumes/volume_group_backup.tf deleted file mode 100644 index 6329e524..00000000 --- a/oracle_cloud/modules/core_volumes/volume_group_backup.tf +++ /dev/null @@ -1,5 +0,0 @@ -#----------------------------------------------------------- -# volume_group_backup -#----------------------------------------------------------- - -# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_volume_group_backup \ No newline at end of file