Skip to content

Commit 097db89

Browse files
committed
fixes per PR comments
1 parent 39b7578 commit 097db89

4 files changed

Lines changed: 18 additions & 17 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ cloudshell_config.yml
6464
shells/generic_terraform_service/tests/.env
6565
tests/.env
6666
shells/backends/azure_tf_backend/tests/.env
67+
package/tests/integration_tests/int_tests_secrets.env

package/cloudshell/iac/terraform/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@
3636
TF_WORKING_DIR = "TF_WORKING_DIR"
3737

3838
# CLP models
39+
AZURE1G_MODEL = "Microsoft Azure"
40+
AWS1G_MODEL = "AWS EC2"
41+
3942
AZURE2G_MODEL = "Microsoft Azure Cloud Provider 2G"
4043
AWS2G_MODEL = "Amazon AWS Cloud Provider 2G"
4144

45+
CLP_PROVIDER_MODELS = [AWS1G_MODEL, AWS2G_MODEL, AZURE1G_MODEL, AZURE2G_MODEL]
46+
4247
# Misc
4348
DIRTY_CHARS = r'''
4449
\x1B # ESC

package/cloudshell/iac/terraform/services/provider_handler.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from cloudshell.api.cloudshell_api import ResourceInfo
66

7-
from cloudshell.iac.terraform.constants import AZURE2G_MODEL, ATTRIBUTE_NAMES, AWS2G_MODEL
7+
from cloudshell.iac.terraform.constants import AZURE2G_MODEL, ATTRIBUTE_NAMES, AWS2G_MODEL, CLP_PROVIDER_MODELS
88
from cloudshell.iac.terraform.models.shell_helper import ShellHelperObject
99

1010

@@ -26,20 +26,11 @@ def initialize_provider(shell_helper: ShellHelperObject):
2626
raise ValueError(f"{clpr_res_fam} currently not supported")
2727

2828
try:
29-
if clp_res_model in ['Microsoft Azure', AZURE2G_MODEL]:
29+
if clp_res_model in CLP_PROVIDER_MODELS:
3030
ProviderHandler._set_cloud_env_vars(
3131
clp_details,
3232
clp_res_model,
33-
shell_helper,
34-
ProviderHandler._set_azure_env_vars_based_on_clp
35-
)
36-
37-
elif clp_res_model in ['AWS EC2', AWS2G_MODEL]:
38-
ProviderHandler._set_cloud_env_vars(
39-
clp_details,
40-
clp_res_model,
41-
shell_helper,
42-
ProviderHandler._set_aws_env_vars_based_on_clp
33+
shell_helper
4334
)
4435
else:
4536
shell_helper.logger.error(f"{clp_res_model} currently not supported")
@@ -54,7 +45,6 @@ def _set_cloud_env_vars(
5445
clp_details: ResourceInfo,
5546
clp_res_model: str,
5647
shell_helper: ShellHelperObject,
57-
set_cloud_env_vars_based_on_clp: Callable
5848
):
5949
shell_helper.sandbox_messages.write_message("initializing provider...")
6050
shell_helper.logger.info("Initializing Environment variables with CloudProvider details")
@@ -64,7 +54,12 @@ def _set_cloud_env_vars(
6454
if clp_res_model in [AZURE2G_MODEL, AWS2G_MODEL]:
6555
cloud_attr_name_prefix = clp_res_model + "."
6656

67-
set_cloud_env_vars_based_on_clp(cloud_attr_name_prefix, clp_resource_attributes, shell_helper)
57+
if clp_res_model in ['AWS EC2', AWS2G_MODEL]:
58+
ProviderHandler._set_aws_env_vars_based_on_clp(
59+
cloud_attr_name_prefix, clp_resource_attributes, shell_helper)
60+
elif clp_res_model in ['Microsoft Azure', AZURE2G_MODEL]:
61+
ProviderHandler._set_azure_env_vars_based_on_clp(
62+
cloud_attr_name_prefix, clp_resource_attributes, shell_helper)
6863

6964
@staticmethod
7065
def _set_azure_env_vars_based_on_clp(azure_attr_name_prefix, clp_resource_attributes, shell_helper):

shells/backends/aws_tf_backend/shell-definition.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ node_types:
2222
type: string
2323
tags: [ setting, user_input ]
2424
Region Name:
25-
description: The region in which the bucket resides
25+
description: The region in which the bucket resides (Mendatory)
2626
type: string
2727
tags: [ setting, user_input ]
2828
Access Key:
29-
description: AWS access key
29+
description: AWS access key (Use only if Cloud Provider not specified - Must be paried with Secret Key)
3030
type: cloudshell.datatypes.Password
3131
tags: [ setting, user_input ]
3232
Secret Key:
33-
description: AWS secret key
33+
description: AWS secret key (Use only if Cloud Provider not specified - Must be paried with Access Key)
3434
type: cloudshell.datatypes.Password
3535
tags: [ setting, user_input ]
3636
Cloud Provider:

0 commit comments

Comments
 (0)