|
43 | 43 | "ocpus": Representation{repType: Optional, create: "2"}, |
44 | 44 | "memory_in_gbs": Representation{repType: Optional, create: `10.0`, update: `20.0`}, |
45 | 45 | } |
| 46 | + instanceShapeConfigRepresentation_ForFlexibleMemoryNoUpdate = map[string]interface{}{ |
| 47 | + "ocpus": Representation{repType: Optional, create: "2"}, |
| 48 | + "memory_in_gbs": Representation{repType: Optional, create: `10.0`, update: `20.0`}, |
| 49 | + } |
| 50 | + instanceRepresentationCore_ForFlexibleMemoryNoUpdate = representationCopyWithRemovedProperties(representationCopyWithNewProperties(instanceRepresentation, map[string]interface{}{ |
| 51 | + "fault_domain": Representation{repType: Optional, create: `FAULT-DOMAIN-3`, update: `FAULT-DOMAIN-2`}, |
| 52 | + "shape": Representation{repType: Required, create: `VM.Standard.E3.Flex`}, |
| 53 | + "image": Representation{repType: Required, create: `${var.FlexInstanceImageOCID[var.region]}`}, |
| 54 | + "shape_config": RepresentationGroup{Optional, instanceShapeConfigRepresentation_ForFlexibleMemoryNoUpdate}, |
| 55 | + "source_details": RepresentationGroup{Optional, instanceFlexSourceDetailsRepresentation}, |
| 56 | + }), []string{ |
| 57 | + "dedicated_vm_host_id", |
| 58 | + }) |
46 | 59 | instanceLaunchOptionsRepresentation_ForLaunchOptionsUpdate = representationCopyWithNewProperties(instanceLaunchOptionsRepresentation, map[string]interface{}{ |
47 | 60 | "boot_volume_type": Representation{repType: Optional, create: `ISCSI`, update: `PARAVIRTUALIZED`}, |
48 | 61 | "is_pv_encryption_in_transit_enabled": Representation{repType: Optional, update: `true`}, |
@@ -1774,6 +1787,58 @@ func TestAccResourceCoreInstance_FlexibleMemory(t *testing.T) { |
1774 | 1787 | ), |
1775 | 1788 | }, |
1776 | 1789 |
|
| 1790 | + // verify updates to updatable parameters but no change in shape_config |
| 1791 | + { |
| 1792 | + Config: config + compartmentIdVariableStr + InstanceResourceDependenciesWithoutDHV + FlexVmImageIdsVariable + |
| 1793 | + generateResourceFromRepresentationMap("oci_core_instance", "test_instance", Optional, Update, instanceRepresentationCore_ForFlexibleMemoryNoUpdate), |
| 1794 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 1795 | + resource.TestCheckResourceAttr(resourceName, "agent_config.#", "1"), |
| 1796 | + resource.TestCheckResourceAttr(resourceName, "agent_config.0.is_management_disabled", "true"), |
| 1797 | + resource.TestCheckResourceAttr(resourceName, "agent_config.0.is_monitoring_disabled", "true"), |
| 1798 | + resource.TestCheckResourceAttrSet(resourceName, "availability_domain"), |
| 1799 | + resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId), |
| 1800 | + resource.TestCheckResourceAttr(resourceName, "create_vnic_details.#", "1"), |
| 1801 | + resource.TestCheckResourceAttr(resourceName, "create_vnic_details.0.assign_public_ip", "true"), |
| 1802 | + resource.TestCheckResourceAttr(resourceName, "create_vnic_details.0.defined_tags.%", "1"), |
| 1803 | + resource.TestCheckResourceAttr(resourceName, "create_vnic_details.0.display_name", "displayName"), |
| 1804 | + resource.TestCheckResourceAttr(resourceName, "create_vnic_details.0.freeform_tags.%", "1"), |
| 1805 | + resource.TestCheckResourceAttr(resourceName, "create_vnic_details.0.hostname_label", "hostnamelabel"), |
| 1806 | + resource.TestCheckResourceAttr(resourceName, "create_vnic_details.0.nsg_ids.#", "0"), |
| 1807 | + resource.TestCheckResourceAttr(resourceName, "create_vnic_details.0.private_ip", "10.0.0.5"), |
| 1808 | + resource.TestCheckResourceAttr(resourceName, "create_vnic_details.0.skip_source_dest_check", "false"), |
| 1809 | + resource.TestCheckResourceAttrSet(resourceName, "create_vnic_details.0.subnet_id"), |
| 1810 | + resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"), |
| 1811 | + resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"), |
| 1812 | + resource.TestCheckResourceAttr(resourceName, "extended_metadata.%", "3"), |
| 1813 | + resource.TestCheckResourceAttr(resourceName, "fault_domain", "FAULT-DOMAIN-2"), |
| 1814 | + resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"), |
| 1815 | + resource.TestCheckResourceAttr(resourceName, "hostname_label", "hostnamelabel"), |
| 1816 | + resource.TestCheckResourceAttrSet(resourceName, "id"), |
| 1817 | + resource.TestCheckResourceAttrSet(resourceName, "image"), |
| 1818 | + resource.TestCheckResourceAttr(resourceName, "ipxe_script", "ipxeScript"), |
| 1819 | + resource.TestCheckResourceAttr(resourceName, "is_pv_encryption_in_transit_enabled", "false"), |
| 1820 | + resource.TestCheckResourceAttr(resourceName, "metadata.%", "2"), |
| 1821 | + resource.TestCheckResourceAttrSet(resourceName, "region"), |
| 1822 | + resource.TestCheckResourceAttr(resourceName, "shape", "VM.Standard.E3.Flex"), |
| 1823 | + resource.TestCheckResourceAttr(resourceName, "shape_config.#", "1"), |
| 1824 | + resource.TestCheckResourceAttr(resourceName, "shape_config.0.memory_in_gbs", "20"), |
| 1825 | + resource.TestCheckResourceAttr(resourceName, "source_details.#", "1"), |
| 1826 | + resource.TestCheckResourceAttrSet(resourceName, "source_details.0.source_id"), |
| 1827 | + resource.TestCheckResourceAttr(resourceName, "source_details.0.source_type", "image"), |
| 1828 | + resource.TestCheckResourceAttr(resourceName, "state", "RUNNING"), |
| 1829 | + resource.TestCheckResourceAttrSet(resourceName, "subnet_id"), |
| 1830 | + resource.TestCheckResourceAttrSet(resourceName, "time_created"), |
| 1831 | + |
| 1832 | + func(s *terraform.State) (err error) { |
| 1833 | + resId2, err = fromInstanceState(s, resourceName, "id") |
| 1834 | + if resId != resId2 { |
| 1835 | + return fmt.Errorf("Resource recreated when it was supposed to be updated.") |
| 1836 | + } |
| 1837 | + return err |
| 1838 | + }, |
| 1839 | + ), |
| 1840 | + }, |
| 1841 | + |
1777 | 1842 | // verify updates to updatable parameters |
1778 | 1843 | { |
1779 | 1844 | Config: config + compartmentIdVariableStr + InstanceResourceDependenciesWithoutDHV + FlexVmImageIdsVariable + |
@@ -1825,6 +1890,7 @@ func TestAccResourceCoreInstance_FlexibleMemory(t *testing.T) { |
1825 | 1890 | }, |
1826 | 1891 | ), |
1827 | 1892 | }, |
| 1893 | + |
1828 | 1894 | // verify datasource |
1829 | 1895 | { |
1830 | 1896 | Config: config + |
|
0 commit comments