Skip to content

Commit

Permalink
Store parameters with consistent paths
Browse files Browse the repository at this point in the history
  • Loading branch information
sbkok committed Mar 26, 2024
1 parent cb9db06 commit ad3b48a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def lambda_handler(event, _):
try:
parameter_store = ParameterStore(DEPLOYMENT_ACCOUNT_REGION, boto3)
default_scm_codecommit_account_id = parameter_store.fetch_parameter(
"scm/default-scm-codecommit-account-id",
"scm/default_scm_codecommit_account_id",
)
except ParameterNotFoundError:
default_scm_codecommit_account_id = deployment_account_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def lambda_handler(event, _):

parameter_store = ParameterStore(DEPLOYMENT_ACCOUNT_REGION, boto3)
auto_create_repositories = parameter_store.fetch_parameter(
"auto_create_repositories"
"scm/auto_create_repositories"
)
LOGGER.debug("Auto create repositories is: %s", auto_create_repositories)
if auto_create_repositories != "enabled":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def fetch_required_ssm_params(pipeline_input, regions):
"deployment_account_bucket"
)
output["default_scm_branch"] = parameter_store.fetch_parameter(
"default_scm_branch",
"scm/default_scm_branch",
)
output["default_scm_codecommit_account_id"] = parameter_store.fetch_parameter(
"scm/default-scm-codecommit-account-id",
"scm/default_scm_codecommit_account_id",
)
codestar_connection_path = (
pipeline_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Resources:
Action:
- "ssm:GetParameter"
Resource:
- !Sub "arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/adf/auto_create_repositories"
- !Sub "arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/adf/scm/auto_create_repositories"

GeneratePipelineInputsLambdaRole:
Type: "AWS::IAM::Role"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,18 @@ def prepare_deployment_account(sts, deployment_account_id, config):
'scm', {}).get('auto-create-repositories')
if auto_create_repositories is not None:
deployment_account_parameter_store.put_parameter(
'auto_create_repositories', str(auto_create_repositories)
'scm/auto_create_repositories', str(auto_create_repositories)
)
deployment_account_parameter_store.put_parameter(
'default_scm_branch',
'scm/default_scm_branch',
(
config.config
.get('scm', {})
.get('default-scm-branch', ADF_DEFAULT_SCM_FALLBACK_BRANCH)
)
)
deployment_account_parameter_store.put_parameter(
'scm/default-scm-codecommit-account-id',
'scm/default_scm_codecommit_account_id',
(
config.config
.get('scm', {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def fetch_parameters_by_path(self, path):

@staticmethod
def _build_param_name(name, adf_only=True):
param_prefix = PARAMETER_PREFIX if adf_only else '/'
param_prefix = PARAMETER_PREFIX if adf_only else ''
prefix_seperator = '' if name.startswith('/') else '/'
return f"{param_prefix}{prefix_seperator}{name}"

Expand All @@ -100,10 +100,7 @@ def fetch_parameter(self, name, with_decryption=False, adf_only=True):
"""
param_name = ParameterStore._build_param_name(name, adf_only)
try:
LOGGER.debug(
'Fetching Parameter %s',
param_name,
)
LOGGER.debug('Fetching Parameter %s', param_name)
response = self.client.get_parameter(
Name=param_name,
WithDecryption=with_decryption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def test_prepare_deployment_account_defaults(param_store_cls, cls, sts):
)
deploy_param_store.put_parameter.assert_has_calls(
[
call('default_scm_branch', 'main'),
call('scm/default_scm_branch', 'main'),
call(
'scm/default-scm-codecommit-account-id',
'scm/default_scm_codecommit_account_id',
deployment_account_id,
),
call('deployment_maps/allow_empty_target', 'False'),
Expand Down Expand Up @@ -254,10 +254,10 @@ def test_prepare_deployment_account_specific_config(param_store_cls, cls, sts):
)
deploy_param_store.put_parameter.assert_has_calls(
[
call('auto_create_repositories', 'disabled'),
call('default_scm_branch', 'main'),
call('scm/auto_create_repositories', 'disabled'),
call('scm/default_scm_branch', 'main'),
call(
'scm/default-scm-codecommit-account-id',
'scm/default_scm_codecommit_account_id',
deployment_account_id,
),
call('deployment_maps/allow_empty_target', 'False'),
Expand Down

0 comments on commit ad3b48a

Please sign in to comment.