In a previous post, we discussed how VMware Aria Automation make use of GCP resources using a new modern approach of Framework plugin-based. Now, let's delve deeper into the enhancements made to the cloud template exploring the role of Allocation Helpers in this process.
Let's take my previous cloud template as a starting point. There's a slight change to what we have been using so far when designing blueprints, the Plugin-based framework itself does not include any logic to resolve constraints or selection of resources. That's why we also release a new type of resource, Allocation Helpers, which helps streamline the process of selecting and reserving the most suitable infrastructure.
There are a few allocations helpers, which one responsible for the selection of the right resource type;
- Compute: for accounts, regions and zones;
- Image: for image mapping and imageID;
- Flavor: for flavor mapping and instance type;
- Network: used to find the network profile;
- Storage: used to find the storage profile;
Let's see how they work, starting with the Image Helper, after dragging it to the canvas, it only requires a image property, I could hardcoded the image but as I want to give my users the flexibility to choose the OS, I created an input that maps to my image mapping and use it as a reference. Sound familiar, right ?
I just did the same for Flavor Helper.
If you click on properties, you can see which property might be used to select the resource you need, but more important which values are returned from the allocation (the ones with a tick), so you can just copy the property to use later on the template, in this case we will use selectedInstanceTypeName.
For Compute allocation, I used the constraint we all know and love to select the desired destination, account and Zone. This time I made it hardcoded, could I use an input to give the user ability to select the destination? Absolutely yes !!!
Now that we computed all destinations and resource selections we need, it's time to use them on GCP and disk resources, just copy the output from the allocation and paste it into the resource input property.
That's it. Every resource will need a slightly different property or value, but now you are capable to work we allocation helpers and build the solution you need.
Here's my full template in case we want to reuse it.
formatVersion: 1 inputs: i-flavor: type: string title: Select your desired t-shit size default: Small enum: - Small - Medium i-image: type: string title: Select your desired OS Disk Image default: CentOS enum: - CentOS - Ubuntu resources: Allocations_Image_1: type: Allocations.Image properties: image: ${input.i-image} Allocations_Flavor_1: type: Allocations.Flavor properties: flavor: ${input.i-flavor} Allocations_Compute_1: type: Allocations.Compute properties: constraints: - tag: env:homolog Idem_GCP_COMPUTE_DISK_1: type: Idem.GCP.COMPUTE.DISK properties: account: ${resource.Allocations_Compute_1.selectedCloudAccount.name} zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.name} name: ${to_lower(env.deploymentName)}-boot-disk size_gb: 20 source_image: ${resource.Allocations_Image_1.selectedImageId} Idem_GCP_COMPUTE_INSTANCE_1: type: Idem.GCP.COMPUTE.INSTANCE properties: name: ${to_lower(env.deploymentName)} account: ${resource.Allocations_Compute_1.selectedCloudAccount.name} zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.name} machine_type: ${'zones/' + resource.Allocations_Compute_1.selectedPlacementCompute.name + '/machineTypes/' + resource.Allocations_Flavor_1.selectedInstanceTypeName} disks: - boot: true device_name: ${resource.Idem_GCP_COMPUTE_DISK_1.name} source: ${resource.Idem_GCP_COMPUTE_DISK_1.resource_id} network_interfaces: - name: eth0 subnetwork: projects/emeirelles-proj/regions/us-east1/subnetworks/default
Happy Automation !!!