iagctl db import
Import resources and services from a file.
The iagctl db import command imports services and resources from a service configuration file. Use this command to move services and resources from one gateway instance to another, or to import a file you’ve created manually.
You can import from a local file or from a repository. Gateway also provides the --validate and --check flags to verify the import before applying changes.
Syntax
Usage notes
Validate an import
Use the --validate flag to verify that all resources in the file contain the required fields. If any fields are missing, the gateway returns details so you can resolve the issue.
Preview an import
Use the --check flag to preview the actions the gateway would take without making any changes. The gateway reports one of three states for each resource:
Force an import
Use the --force flag to override any existing resources that conflict with the imported file.
If the import file contains secrets, --force replaces any existing secret that has the same name. Run the command with --check first to review the Replacement entries.
Provide credentials for a repository
The iagctl db import command clones the repository directly and requires the actual credential on the command line. It doesn’t accept secret names from the Gateway secret store. Use --private-key with the path to an SSH private key file, or use --username and --password for HTTP and HTTPS repositories.
In client mode, iagctl reads the --private-key file on the client, not on the server.
To keep tokens out of your shell history, supply the value from an environment variable or pipeline secret, for example --password "$GIT_TOKEN".
The --password-name and --private-key-name flags belong to iagctl create repository, which stores secret names that the server resolves when services run. Repositories defined inside an import file can still reference secrets by name with the password-name or private-key-name keys. Gateway resolves those secrets when services run.
For more information, see Configure access to private repositories and Use SSH keys to clone git repositories.
Secrets and users in import files
An import file created with iagctl db export can include encrypted secrets and users. Gateway imports these along with services and resources.
Examples
Import from a local file
Import from a repository
Import from a repository over SSH with a private key
The --private-key flag takes the file path of the SSH private key. In client mode, the file must exist on the client:
Import from a repository over HTTP or HTTPS with a username and password
Validate a service file
Preview an import
Preview a forced import
Service file format
The following example shows the structure of a service configuration file:
The filename value in a service definition is a path relative to the service’s working-directory. The working-directory key is the equivalent of the --working-dir flag in iagctl create service. In the example above, Gateway runs python-scripts/hello-world.py from the xr-resources repository.