Preserve managed Bastion identity and canonical API type
This commit is contained in:
parent
f134b77bf1
commit
6fbbd5ae6a
|
|
@ -229,7 +229,7 @@ resource "oci_core_network_security_group" "email" {
|
|||
|
||||
resource "oci_bastion_bastion" "homelab" {
|
||||
count = var.enabled && var.bastion_enabled && trimspace(var.bastion_existing_id) == "" ? 1 : 0
|
||||
bastion_type = "standard"
|
||||
bastion_type = "STANDARD"
|
||||
compartment_id = local.target_compartment_id
|
||||
target_subnet_id = local.bastion_target_subnet_id
|
||||
name = var.bastion_name
|
||||
|
|
|
|||
|
|
@ -169,8 +169,15 @@ def recorded(values, state):
|
|||
values["LAB_OCI_STATE_BASTION_MANAGED"] = str("oci_bastion_bastion.homelab" in managed).lower()
|
||||
if "oci_core_nat_gateway.homelab" in managed:
|
||||
values["LAB_OCI_NAT_ENABLED"] = "true"
|
||||
if "oci_bastion_bastion.homelab" in managed:
|
||||
bastion = managed.get("oci_bastion_bastion.homelab")
|
||||
if bastion:
|
||||
values["LAB_OCI_BASTION_ENABLED"] = "true"
|
||||
# These creation inputs must follow the selected state, not stale
|
||||
# scratch-config values merged during migration. A name change forces
|
||||
# replacement even when the Bastion OCID/ownership flag is correct.
|
||||
values["LAB_OCI_BASTION_ID"] = bastion["id"]
|
||||
values["LAB_OCI_BASTION_NAME"] = bastion["name"]
|
||||
values["LAB_OCI_BASTION_TARGET_SUBNET_ID"] = bastion["target_subnet_id"]
|
||||
for address, setting in (
|
||||
("oci_objectstorage_bucket.homelab_backups", "LAB_OCI_BACKUP_BUCKET_COMPARTMENT_ID"),
|
||||
("oci_ons_notification_topic.monitoring", "LAB_OCI_MONITORING_TOPIC_COMPARTMENT_ID"),
|
||||
|
|
|
|||
|
|
@ -97,6 +97,28 @@ class ResolverTests(unittest.TestCase):
|
|||
with patch("subprocess.run", return_value=response), self.assertRaises(ValueError):
|
||||
resolver.OCI().call("compute", "instance", "get", "--instance-id", "recorded")
|
||||
|
||||
def test_managed_bastion_restores_identity_over_stale_scratch_inputs(self):
|
||||
state = {"resources": [{
|
||||
"mode": "managed", "type": "oci_bastion_bastion", "name": "homelab",
|
||||
"instances": [{"index_key": 0, "attributes": {
|
||||
"id": "ocid1.bastion.current", "name": "homelab-bastion",
|
||||
"target_subnet_id": "ocid1.subnet.current", "bastion_type": "STANDARD",
|
||||
}}],
|
||||
}]}
|
||||
values = {"LAB_OCI_BASTION_ENABLED": "false",
|
||||
"LAB_OCI_BASTION_ID": "ocid1.bastion.stale",
|
||||
"LAB_OCI_BASTION_NAME": "homelab-bastion-yruxcl7q",
|
||||
"LAB_OCI_BASTION_TARGET_SUBNET_ID": "ocid1.subnet.stale"}
|
||||
resolver.recorded(values, state)
|
||||
self.assertEqual(values["LAB_OCI_STATE_BASTION_MANAGED"], "true")
|
||||
self.assertEqual(values["LAB_OCI_BASTION_ENABLED"], "true")
|
||||
self.assertEqual(values["LAB_OCI_BASTION_ID"], "ocid1.bastion.current")
|
||||
self.assertEqual(values["LAB_OCI_BASTION_NAME"], "homelab-bastion")
|
||||
self.assertEqual(values["LAB_OCI_BASTION_TARGET_SUBNET_ID"], "ocid1.subnet.current")
|
||||
first = dict(values)
|
||||
resolver.recorded(values, state)
|
||||
self.assertEqual(values, first)
|
||||
|
||||
def test_notifications_topic_id_is_normalized_for_get_and_list(self):
|
||||
topic = {"topic-id": "ocid1.onstopic.existing", "name": "homelab-monitoring",
|
||||
"compartment-id": "ocid1.compartment.existing", "lifecycle-state": "ACTIVE"}
|
||||
|
|
|
|||
Loading…
Reference in New Issue