Skip to end of metadata
Go to start of metadata

Managing Farm Templates Overview

Below is an example Environment Scope Farm Templates tab.  From this page we can see the available Farm Templates.  Similar to other objects in Scalr, scoping will be represented by color code next to each list entry. 

Search may be used to refine the items listed.  Within each Environment you may filter to see the Environment specific templates, just as we can for other objects across scopes:

Promote to Account Scope

Environment scoped templates are not available across all Environments in this Account.  Similar to other objects (Images/Roles), Farm Templates can be created at the Environment scope and later be promoted to the Account scope.  To promote, simply select Promote template to account scope:


Confirm promotion:

Successful promotion will result in the template being move to the Account Scope where it may then be used across all Environments within the Account:

Note: Pay attention to the scope of the objects referenced in the Farm Template.  If Roles or Orchestration Scripts referenced in the Farm Template do not exist at the Account Scope, promotion will fail with an error describing the objects in conflict. 


Used By

If you are managing Farm templates, you can easily drill down to the Used By relationship from the Farm Template page:


Require user to supply a value

After creating a template from an existing Farm, you may want to remove values from the Farm Template to require a user to enter the appropriate value rather than pre-populating the value defined in the template.  The Project defined in a template may not exist across all Environments which will cause errors for "Invalid Farm/Project configuration" when attempting to launch from the template.  We will remove that setting from the template.  Additionally, attempting to launch a Farm from a template with a name that already exists on another Farm will cause a naming conflict.  This might be a common error occurrence for some users if the name for the Farm is already defined in the template.  We will remove the name field from the template so that users are required to input their own names when launching from the template. We will also remove the instance type so the user must set their own.

Before:

{
    "_meta": {
        "schema_version": "v1beta0-7.4.0"
    },
    "farm": {
        "name": "Template Test",
        "description": "",
        "project": {
            "id": "30c59dba-fc9b-4d0f-83ec-4b5043b12f72"
        },
        "timezone": "America\/Denver",
        "launchOrder": "simultaneous"
    },
    "roles": [
        {
            "alias": "base-ubuntu1604-hvm",
            "platform": "ec2",
            "role": {
                "id": 82948
            },
            "scaling": {
                "enabled": true,
                "minInstances": 1,
                "maxInstances": 2,
                "rules": []
            },
            "placement": {
                "region": "us-east-1",
                "placementConfigurationType": "AwsClassicPlacementConfiguration",
                "availabilityZones": null
            },
            "instance": {
                "instanceConfigurationType": "AwsInstanceConfiguration",
                "instanceType": {
                    "id": "m3.medium"
                }
            },
            "orchestration": {
                "rules": []
            }
        }
    ]
}

After:

{
    "_meta": {
        "schema_version": "v1beta0-7.4.0"
    },
    "farm": {
		"description": "",
        "timezone": "America\/Denver",
        "launchOrder": "simultaneous"
    },
    "roles": [
        {
            "alias": "base-ubuntu1604-hvm",
            "platform": "ec2",
            "role": {
                "id": 82948
            },
            "scaling": {
                "enabled": true,
                "minInstances": 1,
                "maxInstances": 2,
                "rules": []
            },
            "placement": {
                "region": "us-east-1",
                "placementConfigurationType": "AwsClassicPlacementConfiguration",
                "availabilityZones": null
            },
            "instance": {
                "instanceConfigurationType": "AwsInstanceConfiguration"
            },
            "orchestration": {
                "rules": []
            }
        }
    ]
}

Remember to Save your edits.

The resulting end user experience from the above configuration can be viewed in Using the Service Catalog.

Global Variables in Farm Templates

You can use Global Variables in your templates just as you can for scripts.  This allows for easy reusability of template just like scripts.  Perhaps we will have an Orchestration Script that will install a different software package depending on the environment.  We might create an Environment Scope Global Variable named {ENV_SPECIFIC_SCRIPT_URL} and reference that in our Orchestration configuration within the Farm Template:

Note: Global Variables may currently only be used for fields that support Global Variables. (Noted with {X} in the Scalr UI) The Farm Template itself does not support Global Variables.

{
    "_meta": {
        "schema_version": "v1beta0-7.4.0"
    },
    "farm": {
        "name": "Template with script URL GV",
        "description": "",
        "timezone": "America\/Denver",
        "launchOrder": "simultaneous"
    },
    "roles": [
        {
            "alias": "base-ubuntu1604-hvm",
            "platform": "ec2",
            "role": {
                "id": 82948
            },
            "scaling": {
                "enabled": true,
                "minInstances": 1,
                "maxInstances": 2,
                "scalingBehavior": "launch-terminate",
                "considerSuspendedServers": "running",
                "rules": []
            },
            "placement": {
                "region": "us-east-1",
                "placementConfigurationType": "AwsClassicPlacementConfiguration",
                "availabilityZones": null
            },
            "instance": {
                "instanceConfigurationType": "AwsInstanceConfiguration",
                "instanceType": {
                    "id": "m3.medium"
                }
            },
            "orchestration": {
                "rules": [
                    {
                        "trigger": {
                            "triggerType": "SpecificEventTrigger",
                            "event": {
                                "id": "BeforeHostUp"
                            }
                        },
                        "target": {
                            "targetType": "TriggeringServerTarget"
                        },
                        "action": {
                            "actionType": "UriAction",
                            "path": "https:\/\/{ENV_SPECIFIC_SCRIPT_URL}"
                        },
                        "timeout": 1200,
                        "runAs": "",
                        "order": 10,
                        "blocking": true
                    }
                ]
            }
        }
    ]
}

Launch from Template

Farms may be launched directly from the Farm Templates list by clicking New Farm from Template:


Deleting a Farm Template

To delete a Farm Template, simply click the Delete icon.  Keep in mind that the template must not be "In Use" to be Deleted, and must not be defined at a higher scope.