As a cloud administrator, you can use the custom naming allocation helper to generate custom names for your resources in Automation Assembler. You can use the custom naming allocation helper with any resource type.

After you define custom naming templates in Automation Assembler, you can use the custom naming allocation helper to reference the custom naming templates in the Design canvas. See Custom resource naming for more information.

These use cases demonstrate how to use the custom naming allocation helper with the Generic resource type and the Machine resource type. The Generic resource type covers all possible resources and is linked exclusively to the custom naming allocation helper.

Note:

When you create a custom naming template with the Generic resource type, you must use the custom naming allocation helper to generate a custom name for your resource. If you do not add the allocation helper, a name will not be generated for the resource.

See Plug-in based designs and deployments Automation Assembler for more information about allocation and allocation helpers.

Before you begin

You must set up a cloud account and build your resource infrastructure before you can use allocation helpers. See Adding cloud accounts and Building your resource infrastructure for more information.

Create a Generic naming template

You must create a custom naming template to use the custom naming allocation helper. In this example, you create a Generic, organization-level naming template for your deployments. Organization-level naming templates are applied to all deployments by default.

You can also create project-level naming templates. See Custom resource naming for more information.

To create an organization-level naming template:

  1. Select Infrastructure > Administration > Custom Names and click New Custom Name.
  2. Enter a name and description for the custom naming template.
  3. Select Organization as the scope.
  4. Click New Naming Template and configure the following options.
    Option Value
    Resource type Generic
    Template name my-custom template

    The template name is a user-defined string and serves as an identifier for the given template.

    The template name must be specified if the resource type is Generic.

    If you choose Machine as the resource type, you do not need to reference the template name because you can only create one template of type Machine per project.

    Template format resource-${#####}
    Starting counter value 1
    Increment step 1

    With this configuration, the deployments in the assigned projects will increment from this starting point.

    In this example, where the starting counter is 1 and the increment is 1, the first deployment is numbered as 2. If you need the deployment to start at 1, then set the starting counter to zero and the increment step to 1.

  5. Click Add.
  6. If needed, add additional custom naming templates.
  7. Click Create.

The following sections contain some template examples that use the custom naming allocation helper.

Provision a resource with a Generic template

The following cloud template shows how to use a template of type Generic to generate a name for a plug-in based AWS EC2 instance. In this example, you must reference the name of the template, my-custom-template.

formatVersion: 1
inputs: {}
resources:
  Allocations_CustomNaming_1:
    type: Allocations.CustomNaming
    properties:
      resourceType: Generic 
      templateName: my-custom-template
      numberOfNamesToGenerate: 1
  Idem_AWS_EC2_INSTANCE_2:
    type: Idem.AWS.EC2.INSTANCE
    properties:
      name: ${resource.Allocations_CustomNaming_1.selectedNames[0]} # an array of generated custom names
      region: us-west-2
      account: aws
      availability_zone: us-west-2b
      image_id: ami-022e8df2148a65830
      instance_type: t2.nano

Provision a resource with a Machine template

The following template shows how you might use a template of type Machine to generate a custom naming for an AWS EC2 instance. You do not need to specify the name of the template because you can only create one Machine template per project.

formatVersion: 1
inputs: {}
resources:
  Allocations_CustomNaming_1:
    type: Allocations.CustomNaming
    properties:
      resourceType: Machine
      numberOfNamesToGenerate: 1
  Idem_AWS_EC2_INSTANCE_2:
    type: Idem.AWS.EC2.INSTANCE
    properties:
      name: ${resource.Allocations_CustomNaming_1.selectedNames[0]}
      region: us-west-2
      account: aws
      availability_zone: us-west-2b
      image_id: ami-022e8df2148a65830
      instance_type: t2.nano

Provision multiple resources with a Machine template

The following template shows how you might use a template of type Machine to generate names for multiple AWS EC2 instances. You do not need to specify the name of the template because you can only create one Machine template per project.

formatVersion: 1
inputs: {}
resources:
  Allocations_CustomNaming_1:
    type: Allocations.CustomNaming
    properties:
      resourceType: Machine
      numberOfNamesToGenerate: 2
  Idem_AWS_EC2_INSTANCE_1:
    type: Idem.AWS.EC2.INSTANCE
    properties:
      name: ${resource.Allocations_CustomNaming_1.selectedNames[0]}
      region: us-west-2
      account: aws
      availability_zone: us-west-2b
      image_id: ami-022e8df2148a65830
      instance_type: t2.nano
  Idem_AWS_EC2_INSTANCE_2:
    type: Idem.AWS.EC2.INSTANCE
    properties:
      name: ${resource.Allocations_CustomNaming_1.selectedNames[1]}
      region: us-west-2
      account: aws
      availability_zone: us-west-2b
      image_id: ami-022e8df2148a65830
      instance_type: t2.nano

Provision a cluster of resources with a Generic template

The following template shows how you might use a Generic template to provision a cluster of AWS EC2 instances. In this example, you must reference the name of the template, my-custom-template.

formatVersion: 1
inputs: {}
resources:
  Allocations_CustomNaming_1:
    type: Allocations.CustomNaming
    properties:
      resourceType: Generic
      templateName: my-custom-template
      numberOfNamesToGenerate: 2
  Idem_AWS_EC2_INSTANCE_2:
    type: Idem.AWS.EC2.INSTANCE
    allocatePerInstance: true
    properties:
      name: ${resource.Allocations_CustomNaming_1.selectedNames[count.index]}
      region: us-west-2
      account: aws
      availability_zone: us-west-2b
      image_id: ami-022e8df2148a65830
      instance_type: t2.nano
      count: 2