Skip to content

Commit f2a1c0e

Browse files
authored
Adding configuration target region for creating resource
1 parent 8fa3082 commit f2a1c0e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ads/common/auth.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __post_init__(self):
7373
self.oci_key_profile = self.oci_key_profile or os.environ.get(
7474
"OCI_CONFIG_PROFILE", DEFAULT_PROFILE
7575
)
76-
self.oci_config = self.oci_config or {}
76+
self.oci_config = self.oci_config or {"region": os.environ["OCI_RESOURCE_REGION"]} if os.environ.get("OCI_RESOURCE_REGION") else {}
7777
self.oci_signer_kwargs = self.oci_signer_kwargs or {}
7878
self.oci_client_kwargs = self.oci_client_kwargs or {}
7979

@@ -82,7 +82,7 @@ def set_auth(
8282
auth: Optional[str] = AuthType.API_KEY,
8383
oci_config_location: Optional[str] = DEFAULT_LOCATION,
8484
profile: Optional[str] = DEFAULT_PROFILE,
85-
config: Optional[Dict] = {},
85+
config: Optional[Dict] = {"region": os.environ["OCI_RESOURCE_REGION"]} if os.environ.get("OCI_RESOURCE_REGION") else {},
8686
signer: Optional[Any] = None,
8787
signer_callable: Optional[Callable] = None,
8888
signer_kwargs: Optional[Dict] = {},
@@ -678,7 +678,7 @@ def create_signer(self) -> Dict:
678678
>>> signer_generator = AuthFactory().signerGenerator(AuthType.RESOURCE_PRINCIPAL)
679679
>>> signer_generator(signer_args).create_signer()
680680
"""
681-
configuration = ads.telemetry.update_oci_client_config()
681+
configuration = ads.telemetry.update_oci_client_config(AuthState().oci_config)
682682
signer_dict = {
683683
"config": configuration,
684684
"signer": oci.auth.signers.get_resource_principals_signer(),
@@ -739,7 +739,7 @@ def create_signer(self) -> Dict:
739739
>>> signer_generator = AuthFactory().signerGenerator(AuthType.INSTANCE_PRINCIPAL)
740740
>>> signer_generator(signer_args).create_signer()
741741
"""
742-
configuration = ads.telemetry.update_oci_client_config()
742+
configuration = ads.telemetry.update_oci_client_config(AuthState().oci_config)
743743
signer_dict = {
744744
"config": configuration,
745745
"signer": oci.auth.signers.InstancePrincipalsSecurityTokenSigner(

0 commit comments

Comments
 (0)