Skip to content

Commit

Permalink
Removed unused reverse dependencies from the task-reference file (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
eamonnfaherty committed Oct 21, 2022
1 parent 8fe44f3 commit e404f04
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 43 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[tool.poetry]
name = "aws-service-catalog-puppet"
version = "0.196.0"
version = "0.197.0"
description = "Making it easier to deploy ServiceCatalog products"
classifiers = ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Natural Language :: English"]
homepage = "https://service-catalog-tools-workshop.com/"
Expand Down
4 changes: 3 additions & 1 deletion servicecatalog_puppet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,9 @@ def setup_config(
os.environ[environmental_variables.ON_COMPLETE_URL] = on_complete_url
os.environ[
environmental_variables.SPOKE_EXECUTION_MODE_DEPLOY_ENV
] = remote_config.get_spoke_deploy_environment_compute_type(puppet_account_id_to_use, home_region)
] = remote_config.get_spoke_deploy_environment_compute_type(
puppet_account_id_to_use, home_region
)


@cli.command()
Expand Down
39 changes: 1 addition & 38 deletions servicecatalog_puppet/commands/task_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def get_spoke_local_portfolio_common_args(
execution=task_to_add.get("execution"),
dependencies_by_reference=[all_tasks_task_reference]
+ extra_dependencies_by_reference,
reverse_dependencies_by_reference=list(),
portfolio_task_reference=all_tasks_task_reference,
)

Expand Down Expand Up @@ -87,7 +86,6 @@ def generate_complete_task_reference(puppet_account_id, manifest, output_file_pa
manifest_account_ids=dict(),
task_reference=constants.CREATE_POLICIES,
dependencies_by_reference=list(),
reverse_dependencies_by_reference=list(),
section_name=constants.CREATE_POLICIES,
organizations_to_share_with=list(organizations_to_share_with.keys()),
ous_to_share_with=list(ous_to_share_with.keys()),
Expand Down Expand Up @@ -130,7 +128,6 @@ def generate_complete_task_reference(puppet_account_id, manifest, output_file_pa
task_to_add["item_name"] = item_name
# set up for later pass
task_to_add["dependencies_by_reference"] = [constants.CREATE_POLICIES]
task_to_add["reverse_dependencies_by_reference"] = list()

task_reference = (
f"{task_to_add.get('account_id')}-{task_to_add.get('region')}"
Expand Down Expand Up @@ -213,7 +210,6 @@ def generate_complete_task_reference(puppet_account_id, manifest, output_file_pa
account_id=output_account_id,
region=output_region,
dependencies_by_reference=[all_tasks_task_reference],
reverse_dependencies_by_reference=list(),
task_generating_output=all_tasks_task_reference,
status=task_to_add.get("status"),
section_name=constants.SSM_OUTPUTS,
Expand Down Expand Up @@ -332,7 +328,6 @@ def generate_complete_task_reference(puppet_account_id, manifest, output_file_pa
task_def = dict(
account_id=owning_account,
region=owning_region,
reverse_dependencies_by_reference=list(),
manifest_section_names=dict(
**task.get("manifest_section_names")
),
Expand All @@ -356,9 +351,7 @@ def generate_complete_task_reference(puppet_account_id, manifest, output_file_pa
f"{constants.SSM_PARAMETERS}-", f"{constants.SSM_OUTPUTS}-"
)
if all_tasks.get(potential_output_task_ref):
dependency = [
potential_output_task_ref
]
dependency = [potential_output_task_ref]
else:
dependency = []
task_def["dependencies_by_reference"] = dependency
Expand Down Expand Up @@ -434,7 +427,6 @@ def generate_complete_task_reference(puppet_account_id, manifest, output_file_pa
manifest_section_names=dict(),
manifest_item_names=dict(),
manifest_account_ids=dict(),
reverse_dependencies_by_reference=list(),
account_id=account_id_to_use_for_boto3_call,
region=region_to_use_for_boto3_call,
arguments=boto3_parameter_details.get("arguments"),
Expand Down Expand Up @@ -518,8 +510,6 @@ def generate_complete_task_reference(puppet_account_id, manifest, output_file_pa
raise Exception(
f"invalid use of account-and-region affinity - {name} is not deployed in the account_id and region: {account_and_region} for task {task_reference}"
)
for dep in task["dependencies_by_reference"]:
all_tasks[dep]["reverse_dependencies_by_reference"].append(task_reference)
resources = resources_factory.create(
task.get("section_name"), task, puppet_account_id
)
Expand Down Expand Up @@ -553,7 +543,6 @@ def handle_service_control_policies(
policy_description=task_to_add.get("description"),
policy_content=task_to_add.get("content"),
dependencies_by_reference=list(),
reverse_dependencies_by_reference=list(),
manifest_section_names=dict(),
manifest_item_names=dict(),
manifest_account_ids=dict(),
Expand Down Expand Up @@ -598,7 +587,6 @@ def handle_tag_policies(
policy_description=task_to_add.get("description"),
policy_content=task_to_add.get("content"),
dependencies_by_reference=list(),
reverse_dependencies_by_reference=list(),
manifest_section_names=dict(),
manifest_item_names=dict(),
manifest_account_ids=dict(),
Expand Down Expand Up @@ -640,7 +628,6 @@ def handle_stacks(
region=constants.HOME_REGION,
puppet_account_id=puppet_account_id,
dependencies_by_reference=[constants.CREATE_POLICIES],
reverse_dependencies_by_reference=list(),
manifest_section_names=dict(),
manifest_item_names=dict(),
manifest_account_ids=dict(),
Expand Down Expand Up @@ -671,7 +658,6 @@ def handle_stacks(
puppet_account_id=puppet_account_id,
account_id=puppet_account_id,
dependencies_by_reference=[constants.CREATE_POLICIES],
reverse_dependencies_by_reference=list(),
manifest_section_names=dict(),
manifest_item_names=dict(),
manifest_account_ids=dict(),
Expand Down Expand Up @@ -709,7 +695,6 @@ def handle_workspaces(
puppet_account_id=puppet_account_id,
task_reference=workspace_account_preparation_ref,
dependencies_by_reference=[constants.CREATE_POLICIES],
reverse_dependencies_by_reference=[],
account_id=task_to_add.get("account_id"),
section_name=constants.WORKSPACE_ACCOUNT_PREPARATION,
manifest_section_names=dict(),
Expand Down Expand Up @@ -759,7 +744,6 @@ def handle_spoke_local_portfolios(
portfolio=task_to_add.get("portfolio"),
execution=task_to_add.get("execution"),
dependencies_by_reference=[constants.CREATE_POLICIES],
reverse_dependencies_by_reference=list(),
task_reference=ref,
spoke_local_portfolio_name=item_name,
section_name=constants.PORTFOLIO_ASSOCIATIONS,
Expand Down Expand Up @@ -790,7 +774,6 @@ def handle_spoke_local_portfolios(
portfolio=task_to_add.get("portfolio"),
execution=task_to_add.get("execution"),
dependencies_by_reference=[constants.CREATE_POLICIES],
reverse_dependencies_by_reference=list(),
task_reference=ref,
section_name=constants.PORTFOLIO_CONSTRAINTS_LAUNCH,
spoke_local_portfolio_name=item_name,
Expand Down Expand Up @@ -821,7 +804,6 @@ def handle_spoke_local_portfolios(
portfolio=task_to_add.get("portfolio"),
execution=task_to_add.get("execution"),
dependencies_by_reference=[constants.CREATE_POLICIES],
reverse_dependencies_by_reference=list(),
task_reference=ref,
section_name=constants.PORTFOLIO_CONSTRAINTS_RESOURCE_UPDATE,
spoke_local_portfolio_name=item_name,
Expand All @@ -848,7 +830,6 @@ def handle_spoke_local_portfolios(
puppet_account_id=puppet_account_id,
task_reference=spoke_portfolio_ref,
dependencies_by_reference=[constants.CREATE_POLICIES],
reverse_dependencies_by_reference=[],
account_id=task_to_add.get("account_id"),
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -878,7 +859,6 @@ def handle_spoke_local_portfolios(
puppet_account_id=puppet_account_id,
task_reference=spoke_portfolio_all_products_and_versions_ref,
dependencies_by_reference=[spoke_portfolio_ref],
reverse_dependencies_by_reference=[],
account_id=task_to_add.get("account_id"),
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -908,7 +888,6 @@ def handle_spoke_local_portfolios(
spoke_portfolio_ref,
constants.CREATE_POLICIES,
],
reverse_dependencies_by_reference=[],
account_id=task_to_add.get("account_id"),
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -942,7 +921,6 @@ def handle_spoke_local_portfolios(
spoke_portfolio_ref,
constants.CREATE_POLICIES,
],
reverse_dependencies_by_reference=[],
account_id=task_to_add.get("account_id"),
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -979,7 +957,6 @@ def handle_spoke_local_portfolios(
all_tasks_task_reference,
constants.CREATE_POLICIES,
],
reverse_dependencies_by_reference=[],
account_id=task_to_add.get("account_id"),
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -1035,7 +1012,6 @@ def handle_spoke_local_portfolios(
puppet_account_id=puppet_account_id,
task_reference=hub_portfolio_ref,
dependencies_by_reference=[],
reverse_dependencies_by_reference=[],
account_id=puppet_account_id,
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -1073,7 +1049,6 @@ def handle_spoke_local_portfolios(
hub_portfolio_ref,
constants.CREATE_POLICIES,
],
reverse_dependencies_by_reference=[],
account_id=puppet_account_id,
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -1114,7 +1089,6 @@ def handle_spoke_local_portfolios(
hub_portfolio_ref,
constants.CREATE_POLICIES,
],
reverse_dependencies_by_reference=[],
portfolio=task_to_add.get("portfolio"),
execution=task_to_add.get("execution"),
portfolio_task_reference=hub_portfolio_ref,
Expand Down Expand Up @@ -1145,7 +1119,6 @@ def handle_spoke_local_portfolios(
hub_portfolio_puppet_association_ref, # TODO reduce this down to one ?
],
portfolio_task_reference=hub_portfolio_ref,
reverse_dependencies_by_reference=[],
account_id=puppet_account_id,
region=task_to_add.get("region"),
execution=task_to_add.get("execution"),
Expand Down Expand Up @@ -1175,7 +1148,6 @@ def handle_spoke_local_portfolios(
all_tasks_task_reference,
constants.CREATE_POLICIES,
],
reverse_dependencies_by_reference=[],
account_id=task_to_add.get("account_id"),
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -1359,7 +1331,6 @@ def handle_launches(
puppet_account_id=puppet_account_id,
task_reference=hub_portfolio_ref,
dependencies_by_reference=[],
reverse_dependencies_by_reference=[],
account_id=puppet_account_id,
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -1404,7 +1375,6 @@ def handle_launches(
hub_portfolio_ref,
constants.CREATE_POLICIES,
],
reverse_dependencies_by_reference=[],
portfolio=task_to_add.get("portfolio"),
execution=task_to_add.get("execution"),
portfolio_task_reference=hub_portfolio_ref,
Expand All @@ -1431,7 +1401,6 @@ def handle_launches(
puppet_account_id=puppet_account_id,
task_reference=spoke_portfolio_ref,
dependencies_by_reference=[share_and_accept_ref],
reverse_dependencies_by_reference=[],
account_id=task_to_add.get("account_id"),
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -1461,7 +1430,6 @@ def handle_launches(
task_reference=spoke_portfolio_puppet_association_ref,
portfolio_task_reference=spoke_portfolio_ref,
dependencies_by_reference=[spoke_portfolio_ref],
reverse_dependencies_by_reference=[],
account_id=task_to_add.get("account_id"),
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -1495,7 +1463,6 @@ def handle_launches(
hub_portfolio_ref,
# TODO check this still works for a new portfolio after changing it from: portfolio_deploying_from
], # associations are added here and so this is a dependency
reverse_dependencies_by_reference=[],
account_id=puppet_account_id,
region=task_to_add.get("region"),
portfolio=task_to_add.get("portfolio"),
Expand Down Expand Up @@ -1529,7 +1496,6 @@ def handle_launches(
task_reference=portfolio_get_all_products_and_their_versions_ref,
dependencies_by_reference=deps,
portfolio_task_reference=portfolio_deploying_from,
reverse_dependencies_by_reference=[],
account_id=puppet_account_id,
region=task_to_add.get("region"),
section_name=constants.PORTFOLIO_GET_ALL_PRODUCTS_AND_THEIR_VERSIONS,
Expand Down Expand Up @@ -1599,7 +1565,6 @@ def generate_hub_task_reference(puppet_account_id, all_tasks, output_file_path):
task_reference=generate_manifest_ref,
section_name=constants.GENERATE_MANIFEST,
dependencies_by_reference=[],
reverse_dependencies_by_reference=[],
)

replacement_ref = (
Expand All @@ -1614,7 +1579,6 @@ def generate_hub_task_reference(puppet_account_id, all_tasks, output_file_path):
task_reference=replacement_ref,
generate_manifest_ref=generate_manifest_ref,
dependencies_by_reference=[generate_manifest_ref,],
reverse_dependencies_by_reference=list(),
)

# make sure everything runs before we zip up the output directory
Expand Down Expand Up @@ -1688,7 +1652,6 @@ def deploy_from_task_reference(path):
"manifest_section_names",
"manifest_item_names",
"manifest_account_ids",
"reverse_dependencies_by_reference",
]:
if task.get(a):
del task[a]
Expand Down
2 changes: 1 addition & 1 deletion servicecatalog_puppet/environmental_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
IS_CACHING_ENABLED = "SCT_IS_CACHING_ENABLED"
GLOBAL_SHARING_MODE = "SCT_GLOBAL_SHARING_MODE"
ON_COMPLETE_URL = "SCT_ON_COMPLETE_URL"
SPOKE_EXECUTION_MODE_DEPLOY_ENV = "SCT_SPOKE_EXECUTION_MODE_DEPLOY_ENV"
SPOKE_EXECUTION_MODE_DEPLOY_ENV = "SCT_SPOKE_EXECUTION_MODE_DEPLOY_ENV"
3 changes: 2 additions & 1 deletion servicecatalog_puppet/remote_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@ def get_spoke_deploy_environment_compute_type(puppet_account_id, default_region)
)
)
return get_config(puppet_account_id, default_region).get(
"spoke_deploy_environment_compute_type", constants.SPOKE_EXECUTION_MODE_DEPLOY_ENV_DEFAULT
"spoke_deploy_environment_compute_type",
constants.SPOKE_EXECUTION_MODE_DEPLOY_ENV_DEFAULT,
)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

setup_kwargs = {
'name': 'aws-service-catalog-puppet',
'version': '0.196.0',
'version': '0.197.0',
'description': 'Making it easier to deploy ServiceCatalog products',
'long_description': '# aws-service-catalog-puppet\n\n![logo](./docs/logo.png) \n\n## Badges\n\n[![codecov](https://codecov.io/gh/awslabs/aws-service-catalog-puppet/branch/master/graph/badge.svg?token=e8M7mdsmy0)](https://codecov.io/gh/awslabs/aws-service-catalog-puppet)\n\n\n## What is it?\nThis is a python3 framework that makes it easier to share multi region AWS Service Catalog portfolios and makes it \npossible to provision products into accounts declaratively using a metadata based rules engine.\n\nWith this framework you define your accounts in a YAML file. You give each account a set of tags, a default region and \na set of enabled regions.\n\nOnce you have done this you can define portfolios should be shared with each set of accounts using the tags and you \ncan specify which regions the shares occur in.\n\nIn addition to this, you can also define products that should be provisioned into accounts using the same tag based \napproach. The framework will assume role into the target account and provision the product on your behalf.\n\n\n## Getting started\n\nYou can read the [installation how to](https://service-catalog-tools-workshop.com/30-how-tos/10-installation/30-service-catalog-puppet.html)\nor you can read through the [every day use](https://service-catalog-tools-workshop.com/30-how-tos/50-every-day-use.html)\nguides.\n\nYou can read the [documentation](https://aws-service-catalog-puppet.readthedocs.io/en/latest/) to understand the inner \nworkings. \n\n\n## Going further\n\nThe framework is one of a pair. The other is [aws-service-catalog-factory](https://github.com/awslabs/aws-service-catalog-factory).\nWith Service Catalog Factory you can create pipelines that deploy multi region portfolios very easily. \n\n## License\n\nThis library is licensed under the Apache 2.0 License. \n \n',
'author': 'Eamonn Faherty',
Expand Down

0 comments on commit e404f04

Please sign in to comment.