# Custom Service Version

Sometimes, customers require a custom version of a service deployed in their environment. This guide will walk you through the process of deploying a custom service version while maintaining best practices and avoiding potential issues.

# Prerequisites

Before starting, gather the following information:

  1. AWS Account ID: Locate this in the deployment organization's settings page.
  2. Deployment ID: Found in the deployment's settings page.

Log in to the production SSO account, and assume the ProdAutoPilotSupportLevelTwo role in the correct AWS account.

# Locating The Correct Stack

  1. Open the CloudFormation service in the AWS console.
  2. Use the Deployment ID to filter and locate the main stack.
  3. To simplify the search, untoggle the "View nested" switch.

Once the main stack is identified, proceed to update it.

# Editing The Template

The recommended method for editing the stack's template is through the "Infrastructure Composer" since you can edit it through your browser. Once in the editor, follow these steps:

  1. Navigate to the Template tab within the editor.
  2. Ensure the template remains in JSON format.

Proceed to update the template.

# Update The Parameter

Locate the SearchVersion parameter in the template. Update the AllowedValues array to include the desired service version. For instance, to add OpenSearch 2.12:

  1. Find the SearchVersion parameter.
  2. Add 2.12 to the AllowedValues array.
{
    // ...
    "Parameters": {
        // ...
		"SearchVersion": {
			"Description": "OpenSearch version",
			"Type": "String",
			"AllowedValues": [
				"1.2",
				"2.5",
				"2.11"
			],
			"Default": "2.11"
		},
        // ...
    },
    // ...
}
{
    // ...
    "Parameters": {
        // ...
		"SearchVersion": {
			"Description": "OpenSearch version",
			"Type": "String",
			"AllowedValues": [
				"1.2",
				"2.5",
				"2.11",
				"2.12"
			],
			"Default": "2.11"
		},
        // ...
    },
    // ...
}

# Updating The Mapping

Modify the ServiceVersionToImage mapping to include the new version. Here are some things to consider:

  1. Choose a lightweight image with a fast startup time.
  2. If the minor version key exists and is used by another service, add the new version under the existing key.
  3. If the minor version key does not exist, add it following the existing format.
{
    "Mappings": {
        // ...
		"ServiceVersionToImage": {
			// ...
			"2.11": {
				"Search": "opensearchproject/opensearch:2.11.1"
			},
            "2.12": {
				"Foo": "foo/bar:2.12-alpine"
			},
			// ...
		},
        // ...
    },
    // ...
}
{
    "Mappings": {
        // ...
		"ServiceVersionToImage": {
			// ...
			"2.11": {
				"Search": "opensearchproject/opensearch:2.11.1"
			},
			"2.12": {
				"Foo": "foo/bar:2.12-alpine",
				"Search": "opensearchproject/opensearch:2.12.0"
			},
			// ...
		},
        // ...
    },
    // ...
}

# Applying the Changes

  1. Validate the updated template.
  2. Update the stack's new template.
  3. Use the wizard to apply the changes.

Once the update is complete, the new service version will be available for deployment in the AutoPilot interface. You can then update the version directly through the interface.