Skip to content

Commit 19c4f6c

Browse files
committed
1 parent de3fa36 commit 19c4f6c

File tree

12 files changed

+58
-18
lines changed

12 files changed

+58
-18
lines changed

servicecatalog_puppet/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,12 @@ def setup_config(
580580
os.environ[
581581
environmental_variables.SCHEDULER_ALGORITHM
582582
] = remote_config.get_scheduler_algorithm(puppet_account_id_to_use, home_region)
583+
if not os.environ.get(environmental_variables.AWS_STS_REGIONAL_ENDPOINTS):
584+
os.environ[
585+
environmental_variables.AWS_STS_REGIONAL_ENDPOINTS
586+
] = remote_config.get_aws_sts_regional_endpoints(
587+
puppet_account_id_to_use, home_region
588+
)
583589

584590

585591
@cli.command()

servicecatalog_puppet/commands/bootstrap.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ def bootstrap(
254254
"ParameterValue": puppet_role_path,
255255
"UsePreviousValue": False,
256256
},
257+
{
258+
"ParameterKey": "AWSSTSRegionalEndpoints",
259+
"ParameterValue": config.get_aws_sts_regional_endpoints(),
260+
"UsePreviousValue": False,
261+
},
257262
],
258263
"Tags": [{"Key": "ServiceCatalogPuppet:Actor", "Value": "Framework",}]
259264
+ initialiser_stack_tags,

servicecatalog_puppet/commands/task_reference_helpers/generators/spoke_local_portfolios.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ def handle_spoke_local_portfolios(
473473
all_tasks_task_reference,
474474
constants.CREATE_POLICIES,
475475
share_and_accept_ref,
476-
477476
],
478477
"account_id": task_to_add.get("account_id"),
479478
"region": task_to_add.get("region"),

servicecatalog_puppet/commands/task_reference_helpers/generators/spoke_local_portfolios_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ def test_for_accounts(self):
166166
"share_tag_options": "True",
167167
"task_reference": f"portfolio_share_and_accept-{ou_name}-{region}-{portfolio}",
168168
},
169-
all_tasks[
170-
f"portfolio_share_and_accept-{ou_name}-{region}-{portfolio}"
171-
],
169+
all_tasks[f"portfolio_share_and_accept-{ou_name}-{region}-{portfolio}"],
172170
)
173171

174172
self.assertEqual(

servicecatalog_puppet/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
serialisation_utils,
1717
)
1818

19-
2019
logger = logging.getLogger()
2120

2221

@@ -242,6 +241,10 @@ def get_global_share_principals_default():
242241
return os.environ.get(environmental_variables.GLOBAL_SHARE_PRINCIPALS)
243242

244243

244+
def get_aws_sts_regional_endpoints():
245+
return os.environ.get(environmental_variables.AWS_STS_REGIONAL_ENDPOINTS)
246+
247+
245248
def get_on_complete_url():
246249
return os.environ.get(environmental_variables.ON_COMPLETE_URL, "")
247250

servicecatalog_puppet/constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,9 @@
397397
CACHE_DOWNLOADING_ROLE_NAME = "PuppetRoleForDownloadingFromCache"
398398

399399
SHARE_PRINCIPALS_DEFAULT = False
400-
400+
AWS_STS_REGIONAL_ENDPOINTS_LEGACY = "legacy"
401+
AWS_STS_REGIONAL_ENDPOINTS_REGIONAL = "regional"
402+
AWS_STS_REGIONAL_ENDPOINTS_DEFAULT = AWS_STS_REGIONAL_ENDPOINTS_LEGACY
401403
DESCRIBE_PORTFOLIO_SHARES = "describe-portfolio-shares"
402404

403405
SCHEDULER_ALGORITHM_DEFAULT = "topological_generations"

servicecatalog_puppet/environmental_variables.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@
2828
SPOKE_SCHEDULER_THREADS_OR_PROCESSES = "SCT_SPOKE_SCHEDULER_THREADS_OR_PROCESSES"
2929
SPOKE_SCHEDULER_ALGORITHM = "SCT_SPOKE_SCHEDULER_ALGORITHM"
3030
GLOBAL_SHARE_PRINCIPALS = "SCT_GLOBAL_SHARE_PRINCIPALS"
31+
AWS_STS_REGIONAL_ENDPOINTS = "AWS_STS_REGIONAL_ENDPOINTS"

servicecatalog_puppet/remote_config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ def get_global_share_principals_default(puppet_account_id, default_region=None):
184184
)
185185

186186

187+
@functools.lru_cache(maxsize=32)
188+
def get_aws_sts_regional_endpoints(puppet_account_id, default_region=None):
189+
logger.info(
190+
"getting aws_sts_regional_endpoints, default_region: {}".format(default_region)
191+
)
192+
return get_config(puppet_account_id, default_region).get(
193+
"aws_sts_regional_endpoints", constants.AWS_STS_REGIONAL_ENDPOINTS_DEFAULT
194+
)
195+
196+
187197
def get_spoke_deploy_environment_compute_type(puppet_account_id, default_region):
188198
logger.info(
189199
"getting spoke_deploy_environment_compute_type, default_region: {}".format(

servicecatalog_puppet/template_builder/hub/bootstrap.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ssm,
1616
)
1717

18-
from servicecatalog_puppet import config, constants
18+
from servicecatalog_puppet import config, constants, environmental_variables
1919

2020

2121
def get_template(
@@ -53,6 +53,18 @@ def get_template(
5353
Default="No",
5454
)
5555
)
56+
aws_sts_regional_endpoints_parameter = template.add_parameter(
57+
t.Parameter(
58+
"AWSSTSRegionalEndpoints",
59+
Type="String",
60+
Description="This setting specifies how the SDK determines the AWS service endpoint that it uses to talk to the AWS Security Token Service (AWS STS).",
61+
Default=constants.AWS_STS_REGIONAL_ENDPOINTS_DEFAULT,
62+
AllowedValues=[
63+
constants.AWS_STS_REGIONAL_ENDPOINTS_LEGACY,
64+
constants.AWS_STS_REGIONAL_ENDPOINTS_REGIONAL,
65+
],
66+
)
67+
)
5668
puppet_code_pipeline_role_permission_boundary_parameter = template.add_parameter(
5769
t.Parameter(
5870
"PuppetCodePipelineRolePermissionBoundary",
@@ -586,6 +598,11 @@ def get_template(
586598
"Name": "PUPPET_ROLE_PATH",
587599
"Value": t.Ref(puppet_role_path_parameter),
588600
},
601+
{
602+
"Type": "PLAINTEXT",
603+
"Name": environmental_variables.AWS_STS_REGIONAL_ENDPOINTS,
604+
"Value": t.Ref(aws_sts_regional_endpoints_parameter),
605+
},
589606
]
590607

591608
if is_codecommit:

servicecatalog_puppet/workflow/manifest/generate_manifest_with_ids_task.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ def run(self):
149149
"value": config.get_global_share_principals_default(),
150150
"type": "PLAINTEXT",
151151
},
152+
{
153+
"name": environmental_variables.AWS_STS_REGIONAL_ENDPOINTS,
154+
"value": config.get_aws_sts_regional_endpoints(),
155+
"type": "PLAINTEXT",
156+
},
152157
]
153158

154159
if "http" in version:

0 commit comments

Comments
 (0)