Policy management made easy with Templates in SAP API Management
Have you ever created a bunch of Policies and seen that they are being repeatedly used in many of your API Proxies?
Have you ever wondered if someone could share with you their Policy solutions so that you don’t have to re-invent the wheel to solve an old problem?
Have you ever looked out for best practice recommendations on implementing solutions using Policies?
If your answer to at least one of the above is ‘yes’, then jump into using Policy Templates!
As the name suggests, Policy Templates offer you a capability to Create and Save a Policy sequence modeled in an API Proxy and Apply the same on any other API Proxy.
Create & Apply a Policy Template
A step-by-step guide on creating your first Policy Template and applying it on API Proxies has been wonderfully explained by Sven in this blog.
You can Apply as many Templates as you want to an API Proxy, the Policies get appended towards the end of the flow. You are free to modify the Policies after the Apply function. Note that the Template acts as a ‘Copy by Value’ function which means there is no reference maintained to the original Template object in the API Proxy. Hence any subsequent changes to the Template do not have any impact on the API proxies that had already made use of the Template.
Export & Import of a Policy Template
In case you need the Policy Templates created in one API Portal instance to be available for API Proxies in another instance, you can use the Export option to download a zip from the source and Import the zip as is at the target. That’s it 🙂
Policy Template Lifecycle
It is possible to delete an unwanted Policy Template from your API Portal.
In case you want to modify an existing Policy Template, open the API Proxy which is using it, perform the necessary changes to the Policies and the use the ‘Update’ option as shown below. This will overwrite the existing Template content with the content from the API Proxy.
However, the update or delete functions on a Template have no impact on the API Proxies where it has already been applied.
Pre-shipped Policy Templates from SAP
By now, you must have realized how powerful this capability is which helps you create custom Templates for your use. Now comes the icing on the cake – SAP is committed to ship Policy Templates as part of API Packages on API Business Hub! The first set of content is already published and can be accessed via the following links:
- Security best practices
- Cross Origin Resource Sharing
- Hybris Connectivity
- SAP Cloud Platform Connectivity
- Concur Connectivity
Apart from looking at the Template content, you can see that you have an option to Download it as a zip. This can now be imported in your API Portal and put to use in your own API Proxies.
In my next blogpost, I will show you how you could browse through the API Packages in the API Business Hub from your API Portal and easily copy the Policy Templates for your use with a single click!
So, stay tuned 🙂
are there any plans to change this behaviour:
I've created 18 API Proxies that contain a IP filtering policy. Now this policy needs to be updated and a new IP Address range must be added. With the current behaviour I have to go into each API Proxy, edit the Policy, save the Policy and save the changed API Proxy. This is quite cumbersome, error prone and doesn't really scale.
Looking forward for your reply.
Policy templates today fulfill the reuse requirements by a simple copy. They are not built for reuse by reference. We do have plans to enable such reusable policy sets, but currently the timelines are unknown. What you could do at this moment is create a single API proxy with all the necessary policies and invoke it via a call out in other API Proxies. If they are local proxies (in the same tenant), they do not go outside the network adding to the latency. Hope this helps.