def prompt_code_signing_settings(self, stacks: List[Stack]):
        (functions_with_code_sign,
         layers_with_code_sign) = signer_config_per_function(stacks)

        # if no function or layer definition found with code signing, skip it
        if not functions_with_code_sign and not layers_with_code_sign:
            LOG.debug(
                "No function or layer definition found with code sign config, skipping"
            )
            return

        click.echo(
            "\n\t#Found code signing configurations in your function definitions"
        )
        sign_functions = confirm(
            f"\t{self.start_bold}Do you want to sign your code?{self.end_bold}",
            default=True,
        )

        if not sign_functions:
            LOG.debug(
                "User skipped code signing, continuing rest of the process")
            self.signing_profiles = None
            return

        if not self.signing_profiles:
            self.signing_profiles = {}

        click.echo(
            "\t#Please provide signing profile details for the following functions & layers"
        )

        for function_name in functions_with_code_sign:
            (profile_name,
             profile_owner) = extract_profile_name_and_owner_from_existing(
                 function_name, self.signing_profiles)

            click.echo(
                f"\t#Signing profile details for function '{function_name}'")
            profile_name = prompt_profile_name(profile_name, self.start_bold,
                                               self.end_bold)
            profile_owner = prompt_profile_owner(profile_owner,
                                                 self.start_bold,
                                                 self.end_bold)
            self.signing_profiles[function_name] = {
                "profile_name": profile_name,
                "profile_owner": profile_owner
            }
            self.signing_profiles[function_name][
                "profile_owner"] = "" if not profile_owner else profile_owner

        for layer_name, functions_use_this_layer in layers_with_code_sign.items(
        ):
            (profile_name,
             profile_owner) = extract_profile_name_and_owner_from_existing(
                 layer_name, self.signing_profiles)
            click.echo(
                f"\t#Signing profile details for layer '{layer_name}', "
                f"which is used by functions {functions_use_this_layer}")
            profile_name = prompt_profile_name(profile_name, self.start_bold,
                                               self.end_bold)
            profile_owner = prompt_profile_owner(profile_owner,
                                                 self.start_bold,
                                                 self.end_bold)
            self.signing_profiles[layer_name] = {
                "profile_name": profile_name,
                "profile_owner": profile_owner
            }
            self.signing_profiles[layer_name][
                "profile_owner"] = "" if not profile_owner else profile_owner

        LOG.debug("Signing profile names and owners %s", self.signing_profiles)
    def test_signer_config_per_function(self):
        function_name_1 = "HelloWorldFunction1"
        function_name_2 = "HelloWorldFunction2"
        layer_name = "HelloWorldFunctionLayer"
        template_dict = {
            "AWSTemplateFormatVersion": "2010-09-09",
            "Transform": "AWS::Serverless-2016-10-31",
            "Description": "\nSample SAM Template for Tests\n",
            "Globals": OrderedDict([("Function", OrderedDict([("Timeout", 3)]))]),
            "Resources": OrderedDict(
                [
                    (
                        function_name_1,
                        OrderedDict(
                            [
                                ("Type", "AWS::Serverless::Function"),
                                (
                                    "Properties",
                                    OrderedDict(
                                        [
                                            ("CodeUri", "HelloWorldFunction"),
                                            ("Handler", "app.lambda_handler"),
                                            ("Runtime", "python3.7"),
                                            ("CodeSigningConfigArn", "MyCodeSigningConfigArn"),
                                            (
                                                "Layers",
                                                [
                                                    OrderedDict([("Ref", layer_name)]),
                                                ],
                                            ),
                                        ]
                                    ),
                                ),
                            ]
                        ),
                    ),
                    (
                        function_name_2,
                        OrderedDict(
                            [
                                ("Type", "AWS::Serverless::Function"),
                                (
                                    "Properties",
                                    OrderedDict(
                                        [
                                            ("CodeUri", "HelloWorldFunction2"),
                                            ("Handler", "app.lambda_handler2"),
                                            ("Runtime", "python3.7"),
                                            ("CodeSigningConfigArn", "MyCodeSigningConfigArn"),
                                            (
                                                "Layers",
                                                [
                                                    OrderedDict([("Ref", layer_name)]),
                                                ],
                                            ),
                                        ]
                                    ),
                                ),
                            ]
                        ),
                    ),
                    (
                        layer_name,
                        OrderedDict(
                            [
                                ("Type", "AWS::Serverless::LayerVersion"),
                                (
                                    "Properties",
                                    OrderedDict(
                                        [
                                            ("LayerName", "dependencies"),
                                            ("ContentUri", "dependencies/"),
                                            ("CompatibleRuntimes", ["python3.7"]),
                                        ]
                                    ),
                                ),
                            ]
                        ),
                    ),
                ]
            ),
        }
        (functions_with_code_sign, layers_with_code_sign) = signer_config_per_function({}, template_dict)

        self.assertEqual(functions_with_code_sign, {function_name_1, function_name_2})
        self.assertEqual(layers_with_code_sign, {layer_name: {function_name_1, function_name_2}})