OCI Network Security Group Not Applying Rules as Expected in Python SDK
I'm optimizing some code but After trying multiple solutions online, I still can't figure this out. This might be a silly question, but Hey everyone, I'm running into an issue that's driving me crazy... I'm experiencing an scenario with the OCI Python SDK where the security rules I define for a Network Security Group (NSG) are not being applied as expected. I am using version 2.43.0 of the OCI SDK and I have followed the official documentation, but the NSG seems to be ignoring the rules I set. After creating a security rule, I am checking the rules associated with the NSG and the output does not reflect the new rules. Here's the code I used to create and apply the security rule: ```python import oci config = oci.config.from_file() # Load default config network_client = oci.core.VirtualNetworkClient(config) # Create a new security rule rule_details = oci.core.models.AddSecurityRuleDetails( direction='INGRESS', protocol='6', # TCP source='0.0.0.0/0', source_type='CIDR', ip_port_range='22', description='Allow SSH' ) nsg_id = 'ocid1.networksecuritygroup.oc1..example' # replace with your NSG OCID try: response = network_client.add_security_rule(nsg_id, rule_details) print('Security rule added:', response) except oci.exceptions.ServiceError as e: print('ServiceError:', e) ``` After I run this code, I am checking the NSG rules with: ```python nsg = network_client.get_network_security_group(nsg_id) print(nsg.data) ``` However, the output does not show the newly added rule. I’ve confirmed the NSG OCID is correct and that I have the necessary permissions to modify it. I also verified that the region and compartment ID are set correctly in the configuration file. Is there something I might be doing wrong with the security rule creation or the SDK calls? Any insights into why the rules aren't being applied would be greatly appreciated. My development environment is Ubuntu. Am I missing something obvious? For reference, this is a production web app. I'm open to any suggestions.