Create an executable service

You can create an executable service to run scripts or applications stored in a Git repository. Executable services use a pre-defined executable object to determine how to run your script.

Prerequisites

  • An executable object that defines the command to run your script
  • A Git repository that contains your script or application
  • Operator role permissions
  • Repository authentication configured (if using a private repository)

Create a basic executable service

Use the iagctl create service executable command to create a new executable service.

Syntax:

$iagctl create service executable <service-name> \
> --executable-object <object-name> \
> --repository <repository-name> \
> --working-dir <directory-path> \
> --filename <script-filename>

Parameters:

  • <service-name>: A unique name for the executable service
  • --executable-object: The name of the executable object that runs your script
  • --repository: The name of the Git repository that contains your script
  • --working-dir: The path within the repository where your script is located
  • --filename: The name of the script file to execute

Example:

Create an executable service that runs a Bash script:

$iagctl create service executable simple-bash \
> --executable-object my-obj \
> --repository gateway-resources \
> --working-dir executable_services/simple-script \
> --filename test.sh

This example uses the executable object named my-obj (which would be configured to use /usr/bin/bash) to run the test.sh script.

Create an executable service with argument formatting

Add the --arg-format parameter to define how IAG passes arguments to your script at runtime.

Syntax:

$iagctl create service executable <service-name> \
> --executable-object <object-name> \
> --repository <repository-name> \
> --working-dir <directory-path> \
> --filename <script-filename> \
> --arg-format "<format-template>"

Example:

Create an executable service with custom argument formatting:

$iagctl create service executable simple-executable \
> --executable-object my-obj \
> --arg-format "{{.Key}} {{.Value}}" \
> --repository gateway-resources \
> --working-dir executable_services/simple-script \
> --filename test.sh

Additional examples

Create an executable service for a Terraform script

$iagctl create service executable terraform-deploy \
> --executable-object terraform-latest \
> --repository infrastructure-repo \
> --working-dir terraform/production \
> --filename main.tf \
> --description "Deploy production infrastructure"

Create an executable service for a Python script

$iagctl create service executable python-util \
> --executable-object python311-standard \
> --repository utility-scripts \
> --working-dir python \
> --filename data-processor.py \
> --description "Process daily data files"

Create an executable service with complex argument formatting

$iagctl create service executable advanced-script \
> --executable-object bash-standard \
> --repository gateway-resources \
> --working-dir scripts \
> --filename process.sh \
> --arg-format "--{{.Key}}={{.Value}}" \
> --description "Process data with custom flags"