glennguzzo
ServiceNow Employee
ServiceNow Employee

Following on from a previous article where Cloud Cost Management assists with decisions integrated into Cloud Services Catalog.    Cloud Services Catalog allows the Day 1 provisioning of a new stack, and the ability to apply day 2 actions against existing stacks.  For now this article focusses on Day 1 provisioning policy considerations for Cloud Cost & Change Management.

 

This guide helps with leveraging Governance policies withing Cloud Services Catalog for the following use cases:

(A) determine the budget approver & exposing the proposed budget of the new stack, against existing spend to the budget approver

(B) defining the change management policy for the new stack

 

Use Case (A) : Budget approval

 

For this example, we will be using the Business Service's Cost Center on the form, to determine who will be approving the budget.   There are many other fields that could be used on the form for this.  The reason the Business Service was chosen in this example, as this is usually how the resource was 'Tagged' to an Application Service as part of the Common Service Data Model.

 

This assumes you have Cloud Cost Management running to collect Billing data, and there are Budget Policies configured at a Service Account level.

 

One way this could be done, for an example, is to ensure that:

  • Application Service is mandated on the form
  • Application Service, with an Active Cost Center Manager, is a reference qualifier on the form

 

This example is using the 'CSC Content Pack' scope and variable set 'General Info'.

 

Reference qualifier of ‘Cost Centre.Manager.Active=True' - show Related Fields - highlighted in Light Blue below.

glennguzzo_0-1735251453214.png

 

 

Display & Search for the Cost Center underneath the Business Service.  NB: other fields could be added here, such as Manager, Code, etc.

glennguzzo_1-1735251453215.png

 

 

Create a Client Script to display a field message underneath to show the requestor 'who is approving' this new Stack provisioning.

 

glennguzzo_2-1735251453215.png

 

 

glennguzzo_3-1735251453215.png

 

 

 

glennguzzo_4-1735251453215.png

 

 

 

Before creating a Custom Policy, a new Workflow will need to be created.

 

By going into the 'Cloud Provisioning & Governance' scope, and Workflow Editor, open 'Cloud Approval WF' and copy it and rename it to 'Budget Cloud Approval WF' (or whatever deemed appropriate to your naming standards).

 

Go to 'Cloud Admin Portal > Govern > Operate', create a new Custom Policy, attached to the Blueprint Item where you want Budget review.

 

glennguzzo_5-1735251453215.png

 

 

Create policy rule

glennguzzo_6-1735251453215.png

 

 

 

Create Rule Action - Custom Approval.

glennguzzo_7-1735251453215.png

 

 

Linked to Duplicated workflow.

glennguzzo_8-1735251453215.png

 

 

Then ensure the Policy is published.

glennguzzo_9-1735251453215.png

 

 

 

Now we need to update the Workflow to ensure we have (A) the cost center manager as approver, and (B) the budget information is presented to them during the approval process.  The budget that is used is the one configured in Cloud Cost Management.   The example, shown here retrieves the budget based off Cloud Service Accounts.

 

In the first 'Run Script' area, here is where the Manager will be performing the approval is put into the ScratchPad, so change it to:

 

// Gather Budget approver
workflow.scratchpad.managerId = current.variables.BusinessService.cost_center.manager;
// Gather request number to present
workflow.scratchpad.ritm_number = current.number;
// Gather request spend
workflow.scratchpad.request_spend=parseFloat(current.variables.instance_price_details.u_recurring_price).toFixed(2);

// find Budget and policy based on variable Cloud Account - linked to Service account
var serviceAccount='';
// find service account first
var cloudDC = new GlideRecord('sn_cmp_ca_assc_datacenter');
cloudDC.addEncodedQuery('alias=' + current.variables.Location + '^cloud_account.name=' + current.variables.CloudAccount);
cloudDC.query();
while(cloudDC.next()){ 
    var relDC = new GlideRecord('cmdb_rel_ci');
    relDC.addEncodedQuery('parent=' +cloudDC.getValue('ldc_id') + '^child.sys_class_name=cmdb_ci_cloud_service_account');
    relDC.query();
    while(relDC.next()){
        serviceAccount=relDC.getValue('child');
    }
}

var bp = new GlideRecord('sn_clin_core_budget_policy');
bp.addEncodedQuery('service_accountsIN' + serviceAccount);
bp.query();
while(bp.next()){
    // find Budget summary to present information back to Cost Center Manager
    var bs = new GlideRecord('sn_clin_core_budget_summary');
    bs.addEncodedQuery('budget=' + bp.sys_id);
    bs.query();
    while(bs.next()){      
        workflow.scratchpad.budget_spend = parseFloat(bs.getValue('spend')).toFixed(2);
        workflow.scratchpad.budget = bp.getValue('name');
        workflow.scratchpad.consumed_forecast = parseFloat(bs.getValue('consumed_forecast')).toFixed(2);
        workflow.scratchpad.cost_forecast = parseFloat(bs.getValue('cost_forecast')).toFixed(2);
        workflow.scratchpad.different_forecast = parseFloat(bs.getValue('different_forecast')).toFixed(2);
        workflow.scratchpad.budget_amount = parseFloat(bp.getValue('budget_amount')).toFixed(2);           
    }
}

 

Between run script and Approval - user step, create a new 'Notification' step with the following title 'Send Budget Info'

In to = 'answer = workflow.scratchpad.managerId;'

Subject = Budget review required for ${workflow.scratchpad.ritm_number}

Message =

Current Budget settings:

Budget Name: ${workflow.scratchpad.budget}

Budget Amount: $${cworkflow.scratchpad.budget_amount}

Budget Spend: $${workflow.scratchpad.budget_spend}

Budget Consumed Forecast: ${workflow.scratchpad.consumed_forecast}%

Budget Cost Forecast: $${workflow.scratchpad.cost_forecast}

 

This request will consume $${workflow.scratchpad.request_spend} per month based on the Instance Type ${current.variables.Linux_basic_with_many_AMIs_instancetype} requested.

 

 

This will display back to the user, similar to below:

 

 

Subject: Budget review required for RITM0010058

 

Current Budget settings:

Budget Name: AWS SNOW Monthly

Budget Amount: $100.00

Budget Spend: $48.68

Budget Consumed Forecast: 125.00%

Budget Cost Forecast: $125.00

 

This request will consume $45.95 per month based on the Instance Type t2.small requested.

 

Use Case B : Change Management approval on Provision

 

When spinning up a new stack it may be important that it is raised with Change Management, especially in Production Environments, when the introduction of a new stack could impact the existing landscape.

 

The existing workflow for Budget could also be extended to include a hand off to a Flow/Subflow, that manages the submission/approval of a Change Request based on what has been entered.

 

In this example, this is a basic example, that could create a Catalog Task first, then the Standard Change based off a Template, closing out when moving into Implementation state of beyond to then commence the 'Provisioning' using the Terraform template embedded into the Catalog.

 

glennguzzo_10-1735251646091.png

 

 

glennguzzo_11-1735251646091.png

Update sets:

Cloud Services Catalog

CSC Content Pack

Cloud Provisioning and Governance