|
| 1 | +// Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + |
| 3 | +variable "tenancy_ocid" {} |
| 4 | +variable "user_ocid" {} |
| 5 | +variable "fingerprint" {} |
| 6 | +variable "private_key_path" {} |
| 7 | +variable "region" {} |
| 8 | +variable "compartment_ocid" {} |
| 9 | + |
| 10 | +provider "oci" { |
| 11 | + tenancy_ocid = "${var.tenancy_ocid}" |
| 12 | + user_ocid = "${var.user_ocid}" |
| 13 | + fingerprint = "${var.fingerprint}" |
| 14 | + private_key_path = "${var.private_key_path}" |
| 15 | + region = "${var.region}" |
| 16 | +} |
| 17 | + |
| 18 | +resource "oci_core_subnet" "test_subnet" { |
| 19 | + cidr_block = "10.0.0.0/24" |
| 20 | + compartment_id = "${var.compartment_ocid}" |
| 21 | + vcn_id = "${oci_core_vcn.test_vcn.id}" |
| 22 | +} |
| 23 | + |
| 24 | +resource "oci_core_vcn" "test_vcn" { |
| 25 | + cidr_block = "10.0.0.0/16" |
| 26 | + compartment_id = "${var.compartment_ocid}" |
| 27 | +} |
| 28 | + |
| 29 | +resource "oci_mysql_mysql_backup" "test_mysql_backup" { |
| 30 | + db_system_id = "${oci_mysql_mysql_db_system.test_mysql_backup_db_system.id}" |
| 31 | +} |
| 32 | + |
| 33 | +resource "oci_mysql_mysql_db_system" "test_mysql_backup_db_system" { |
| 34 | + #Required |
| 35 | + admin_password = "BEstrO0ng_#11" |
| 36 | + admin_username = "adminUser" |
| 37 | + availability_domain = "${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}" |
| 38 | + compartment_id = "${var.compartment_ocid}" |
| 39 | + configuration_id = "${data.oci_mysql_mysql_configurations.test_mysql_configurations.configurations.0.id}" |
| 40 | + shape_name = "VM.Standard.E2.2" |
| 41 | + subnet_id = "${oci_core_subnet.test_subnet.id}" |
| 42 | + |
| 43 | + #Optional |
| 44 | + data_storage_size_in_gb = "50" |
| 45 | +} |
| 46 | + |
| 47 | +resource "oci_mysql_mysql_db_system" "test_mysql_db_system" { |
| 48 | + #Required |
| 49 | + admin_password = "BEstrO0ng_#11" |
| 50 | + admin_username = "adminUser" |
| 51 | + availability_domain = "${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}" |
| 52 | + compartment_id = "${var.compartment_ocid}" |
| 53 | + configuration_id = "${data.oci_mysql_mysql_configurations.test_mysql_configurations.configurations.0.id}" |
| 54 | + shape_name = "VM.Standard.E2.2" |
| 55 | + subnet_id = "${oci_core_subnet.test_subnet.id}" |
| 56 | + |
| 57 | + #Optional |
| 58 | + backup_policy { |
| 59 | + is_enabled = "false" |
| 60 | + retention_in_days = "10" |
| 61 | + window_start_time = "01:00-00:00" |
| 62 | + } |
| 63 | + |
| 64 | + #defined_tags = "${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "${var.mysql_defined_tags_value}")}" |
| 65 | + #freeform_tags = "${var.mysql_freeform_tags}" |
| 66 | + description = "MySQL Database Service" |
| 67 | + |
| 68 | + display_name = "DBSystem001" |
| 69 | + fault_domain = "FAULT-DOMAIN-1" |
| 70 | + hostname_label = "hostnameLabel" |
| 71 | + ip_address = "10.0.0.8" |
| 72 | + |
| 73 | + maintenance { |
| 74 | + window_start_time = "sun 01:00" |
| 75 | + } |
| 76 | + |
| 77 | + mysql_version = "${data.oci_mysql_mysql_versions.test_mysql_versions.versions.0.versions.0.version}" |
| 78 | + port = "3306" |
| 79 | + port_x = "33306" |
| 80 | + |
| 81 | + # Creating DB System using a backup |
| 82 | + source { |
| 83 | + backup_id = "${oci_mysql_mysql_backup.test_mysql_backup.id}" |
| 84 | + source_type = "BACKUP" |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +data "oci_mysql_mysql_versions" "test_mysql_versions" { |
| 89 | + compartment_id = "${var.compartment_ocid}" |
| 90 | +} |
| 91 | + |
| 92 | +data "oci_mysql_mysql_configurations" "test_mysql_configurations" { |
| 93 | + compartment_id = "${var.compartment_ocid}" |
| 94 | + |
| 95 | + #Optional |
| 96 | + state = "ACTIVE" |
| 97 | + display_name = "VM.Standard.E2.2.Built-in" |
| 98 | + shape_name = "VM.Standard.E2.2" |
| 99 | +} |
| 100 | + |
| 101 | +data "oci_mysql_shapes" "test_shapes" { |
| 102 | + compartment_id = "${var.compartment_ocid}" |
| 103 | + availability_domain = "${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}" |
| 104 | +} |
| 105 | + |
| 106 | +data "oci_identity_availability_domains" "test_availability_domains" { |
| 107 | + compartment_id = "${var.tenancy_ocid}" |
| 108 | +} |
| 109 | + |
| 110 | +output "version_value" { |
| 111 | + value = "${data.oci_mysql_mysql_versions.test_mysql_versions.versions.0.versions.0.version}" |
| 112 | +} |
| 113 | + |
| 114 | +output "configuration_id" { |
| 115 | + value = "${data.oci_mysql_mysql_configurations.test_mysql_configurations.configurations.0.id}" |
| 116 | +} |
0 commit comments