<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def template(self, lambda_arn, role_arn, output=None, json=False):
 """ Only build the template file. """


        if not lambda_arn:
            raise ClickException("Lambda ARN is required to template.")

        if not role_arn:
            raise ClickException("Role ARN is required to template.")

        self.zappa.credentials_arn = role_arn

        # Create the template!
        template = self.zappa.create_stack_template(
                                            lambda_arn=lambda_arn,
                                            lambda_name=self.lambda_name,
                                            api_key_required=self.api_key_required,
                                            iam_authorization=self.iam_authorization,
                                            authorizer=self.authorizer,
                                            cors_options=self.cors,
                                            description=self.apigateway_description,
                                            policy=self.apigateway_policy,
                                            endpoint_configuration=self.endpoint_configuration
                                        )

        if not output:
            template_file = self.lambda_name + '-template-' + str(int(time.time())) + '.json'
        else:
            template_file = output
        with open(template_file, 'wb') as out:
            out.write(bytes(template.to_json(indent=None, separators=(',',':')), "utf-8"))

        if not json:
            click.echo(click.style("Template created", fg="green", bold=True) + ": " + click.style(template_file, bold=True))
        else:
            with open(template_file, 'r') as out:
                print(out.read())