Infrastructure Commands
In this section, you can find the list of Infrastructure commands.
| Command | Description |
|---|---|
| stk create infra | Creates an Infrastructure. |
| stk deploy infra | Deploys your Infrastructure. |
| stk destroy infra | Destroys the Infrastructure in an environment. |
| stk list infra | Lists the Infrastructures registered in your Workspace. |
| stk register infra | Registers Infrastructure information in a Workspace. |
| stk rollback infra | Executes the rollback of your Infrastructure. |
| stk update infra | Updates the information of an Infrastructure. |
| stk validate infra | Validates the structure of an Infrastructure. |
stk create infra
The stk create infra command creates one or more Infrastructure resources from infra type Plugins in a Stack.
You cannot register or deploy Infrastructures created outside a Workspace.
The -o, --target option lets you define a different folder name to create the Infrastructure content. If the folder does not exist, it will be created.
If you do not use the -o or --target option, the folder name for the Infrastructure content will be the same as the name you gave when creating your Infrastructure.
Usage
stk create infra [INFRA_NAME] --stack [STUDIO/STACK]
Parameters
| Options | Description | Example |
|---|---|---|
INFRA_NAME | Sets the name of the Infrastructure. If not provided, the name is taken from the repository defined in the --remote parameter. | stk create infra my-infra-name |
-s, --stack | Stack that contains the list of infra Plugins to be applied to your Infrastructure. It must follow the [STUDIO]/[STACK] pattern. You can also select the Stack interactively in the terminal. | stk create infra my-infra-name --stack my-studio/my-stack |
-sr, --starter, --starter studio-slug/stack-slug/starter-slug | Defines the Starter that will apply the set of Plugins to your Infrastructure. You must provide the Starter name and its origin data, such as Studio and Stack. You can select the Stack interactively in the terminal. You can select the Stack version by using --starter studio-slug/stack-slug@[number-version]/starter-slug. You can also provide the path to a Starter file ( starter.yaml) to create the Infrastructure with a local Starter. | stk create infra my-infra-name --starter my-studio/my-stack/starter-nameSelect the Stack version: stk create infra my-infra-name --starter my-studio/my-stack@3.0.0/starter-nameUse a local Starter: stk create infra my-infra-name --starter User/Documents/My-Local-Starters/starter-name.yaml |
-r, --remote <git-url> | Sets the URL of the remote Git repository used as the project origin. If not provided, a remote repository will not be configured and you must set it manually. | stk create infra my-infra-name --remote https://github.com/my-git-repository-url |
-sgi, --skip-git-init | Use this option to avoid initializing a Git repository when creating the Infrastructure. | stk create infra my-infra-name --skip-git-init |
-d, --description | Sets a description for your Infrastructure and its purpose. | stk create infra my-infra-name --description "my infra description" |
-q, --non-interactive | Does not prompt the user for input parameters and returns an error if any required parameter is missing. | stk create infra my-infra-name --non-interactive |
-sp, --spec [TEXT] | Path to the specification file that contains input and connection data for each applied Plugin. | stk create infra my-infra-name --spec /home/user/specs-folder/infra.yaml |
-o, --target | Defines a different folder name to create the Infrastructure content. If the folder does not exist, it will be created. If you do not use -o or --target, the folder name will be the same as the Infrastructure name. | stk create infra my-infra-name --stack my-studio/my-stack --target home/user/Shared-Infra/my-infra |
-er, --extra-repositories TEXT | Provides a list of additional repositories for your Infrastructure. Each repository must be a JSON object in the following structure: "[{"name":"repository_name", "description": "repository_description", "provider": "repository_provider", "url": "repository_url"}]" | stk create infra my-example-infra --starter studio/stack/starter-name --extra-repositories "[{"name":"my-example-infra-repo", "description": "repository for test my infra", "provider": "github", "url": "https://github.com/my-organization-name/my-example-infra-repo"}]" |
-wf, --workflow TEXT | Name of the Workflow used to create the Infrastructure. | stk create infra my-example-infra --workflow studio-name/stack-name/workflow-name |
-rs, --report-status | Workflow only. Reports the execution status as an activity in the current Application or Infrastructure. | stk create infra my-example-infra --workflow studio-name/stack-name/workflow-name --report-status |
-i, --inputs-json TEXT | Workflow only. Workflow inputs in JSON format. | stk create infra my-example-infra --workflow studio-name/stack-name/workflow-name --inputs-json "[{"label":"Host","name":"host","type":"text","required":true},{"label":"Port","name":"port","type":"int","required":true}]" |
-h, --help | Shows the command help and exits. | stk create infra --help |
stk deploy infra
The stk deploy infra command deploys your Infrastructure to an Environment in your Workspace.
Before running the command, you must:
- Log in to your account with the stk login command.
- Have an active Workspace. Access a Workspace with the stk use workspace command.
Usage
stk deploy infra
Parameters
| Options | Description | Example |
|---|---|---|
-v, --version | Sets the deploy tag version. You must use semantic versioning (for example, 1.0.0). | stk deploy infra --version 1.0.0 |
-e, --env | Sets the name of the Environment to use for the application deploy. Check the available Environments in your Workspace with the stk list infra command. | stk deploy infra --env qa |
-b, --branch | Name of the Git branch that will be used in the deployment. Optional. | stk deploy infra --branch infra-last-release |
--open-api-path | Path to the Open API file relative to the root of the Git repository. Optional. | stk deploy infra --open-api-path /home/user/my-infra-folder |
-w, --watch | Monitors the deployment status automatically. | stk deploy infra --env qa --watch |
-wf, --workflow | Sets the deploy Workflow name when using a Workflow to deploy the Infrastructure. The Workflow name must be its qualifier. | stk deploy infra --workflow studio/stack/workflow-name@1.0.0 |
-rs, --report-status | Reports the deploy execution status as an activity on the current Infrastructure, which is available in the StackSpot Portal. | stk deploy infra --workflow studio/stack/workflow-name@1.0.0 --report-status |
-q, --non-interactive | Enables non-interactive mode. It will not prompt for missing parameters. | stk deploy infra --workflow studio/stack/workflow-name@1.0.0 --report-status --non-interactive |
-bc, --backend-config | Input used only with StackSpot Workflows. It defines which Terraform backend should be used, that is, where the deploy state is stored. When the type is S3, only the s3 object is required. When the type is AZURERM, only the azurerm object is required. Use the contracts presented in the deploy guide. | stk deploy infra --workflow studio/stack/workflow-name@1.0.0 --report-status --non-interactive --backend-config '{"type":"S3","s3":{"iac":{"bucket":"","region":""},"tfstate":{"bucket":"","region":""}}}' |
-rwc, --resume-workflow-config | Receives a JSON string with Azure, GitHub, or GitLab configuration (one at a time). Examples: {"azure": {"pipeline_name": "...", "org": "...", "project_name": "...","branch": "..."}} ou {"github":{"repository_name": "...", "org": "...", "workflow_name": "...", "branch": "..."}} ou {"gitlab": {"id": "...", "slug": "..."}}. | stk deploy infra --workflow studio/stack/workflow-name@1.0.0 --report-status --non-interactive --backend-config '{"type":"S3","s3":{"iac":{"bucket":"","region":""},"tfstate":{"bucket":"","region":""}}}' --resume-workflow-config '{"azure": {"pipeline_name": "...", "org": "...", "project_name": "...","branch": "..."}}' |
-h, --help | Shows the command help and exits. | stk deploy infra --help |
stk destroy infra
This feature is temporarily disabled. During this period, if you need to destroy an Infrastructure, contact our support.
The stk destroy infra command destroys an Infrastructure from an environment.
Usage
Syntax
stk destroy infra --env <ENV_NAME>
Example
You must access the folder of the Infrastructure you want to destroy and run:
cd my-shared-infra-folder
stk destroy infra --env prod
Parameters
| Options | Description | Example |
|---|---|---|
-e, --env | Environment where the Infrastructure was deployed. Required. | stk destroy infra --env prod |
-w, --watch | Automatically monitors the Infrastructure destruction status. | stk destroy infra --env prod --watch |
-q, --non-interactive | Does not prompt the user for input parameters and returns an error if any required parameter is missing. | stk destroy infra --env prod --non-interactive |
-wf, --workflow TEXT | Name of the Workflow used to destroy the Infrastructure. | stk destroy infra --env prod --workflow studio-name/stack-name/workflow-name |
-rs, --report-status | Exclusive use with Workflow. Reports the execution status as an activity in the Application or Infrastructure. | stk destroy infra --env prod --workflow studio-name/stack-name/workflow-name --report-status |
-h, --help | Shows the command help and exits. | stk destroy infra --help |
stk list infra
The stk list infra command prints in the terminal a list of all Infrastructures registered in your Workspace.
Before running the command, you must:
- Log in to your account with the stk login command.
- Have an active Workspace. Access a Workspace with the stk use workspace command.
Usage
stk list infra
Parameters
| Options | Description | Example |
|---|---|---|
-h, --help | Shows the command help and exits. | stk list infra --help |
stk register infra
The stk register infra command registers an Infrastructure in your Workspace.
Before running the command, you must:
- Log in to your account with the stk login command.
- Have an active Workspace. Access a Workspace with the stk use workspace command.
Usage
stk register infra
Parameters
| Options | Description | Example |
|---|---|---|
-r, --remote | Sets the URL of the remote Git repository used to host your Infrastructure. | stk register infra --remote https://github.com/my-git-repository-url |
-bb, --base-branch | Name of the base branch of your Infrastructure repository. | stk register infra --base-branch my-shared-infra-branch |
-er, --extra-repositories TEXT | Provides a list of additional repositories for your Infrastructure. Each repository must be a JSON object in the following structure: "[{"name":"repository_name", "description": "repository_description", "provider": "repository_provider", "url": "repository_url"}]" | stk register infra --remote https://github.com/my-git-repository-url --extra-repositories "[{"name":"my-example-infra-repo", "description": "repository for test my infra", "provider": "github", "url": "https://github.com/my-organization-name/my-example-infra-repo"}]" |
-h, --help | Shows the command help and exits. | stk register infra --help |
stk rollback infra
The stk rollback infra command executes the rollback of your Infrastructure.
Usage
Syntax
stk rollback infra --version <VERSION> --env <ENV_NAME>
Example
stk rollback infra --version 2.2.0 --env prod
Parameters
| Options | Description | Example |
|---|---|---|
-v, --version | Tag version used in the deploy. The value must follow semantic versioning. | stk rollback infra --version 2.2.0 --env prod |
-e, --env | Environment that will be used to execute the rollback. You can check available environments using the stk list env command. | stk rollback infra --version 2.2.0 --env prod |
-w, --watch | Automatically monitors the Infrastructure rollback status. | stk rollback infra --version 2.2.0 --env prod --watch |
-q, --non-interactive | Does not prompt the user for input parameters and returns an error if any required parameter is missing. | stk rollback infra --version 2.2.0 --env prod --non-interactive |
-wf, --workflow TEXT | Name of the Workflow for Infrastructure rollback. | stk rollback infra --version 1.2.0 --env prod --workflow studio-name/stack-name/workflow-name |
-bc, --backend-config | Exclusive use with StackSpot Workflows. Sets the Terraform backend used to store the deployment state. For S3, provide only the S3 object; for AZURERM, only the azurerm object. See contracts in the deployment guide. | stk rollback infra --version 1.2.0 --env prod --report-status --non-interactive --backend-config '{{"type":"S3","s3":{"iac":{"bucket":"","region":""},"tfstate":{"bucket":"","region":""}}}}' |
-rs, --report-status | Exclusive use with Workflow. Reports the execution status as an activity. | stk rollback infra --version 1.2.0 --env prod --report-status |
-h, --help | Shows the command help and exits. | stk rollback infra --help |
stk update infra
The stk update infra command updates the information of an Infrastructure in StackSpot.
You can update the following Infrastructure information:
name;description;repository URL;default branch.
Usage
Syntax
stk update infra [OPTIONS]
Example
stk update infra --name infra-renamed-example
The data stored in the Infrastructure metadata will be synchronized with the API.
Parameters
| Options | Description | Example |
|---|---|---|
-n, --name TEXT | Updates the Infrastructure name. | stk update infra --name infra-renamed |
-d, --description TEXT | Updates the Infrastructure description. | stk update infra --description "my new infra description" |
-r, --repo-url TEXT | Adds or updates the Infrastructure Git repository URL. | stk update infra --repo-url https://github.com/my-org/my-new-infra-repository |
-b, --repo-base-branch TEXT | Updates the base Git branch of the Infrastructure repository. | stk update infra --repo-base-branch "update/infra-branch-name" |
-q, --non-interactive | Enables non-interactive mode and does not prompt for missing parameters. | stk update infra --non-interactive |
-er, --extra-repositories TEXT | Provides a list of additional repositories for your Infrastructure. Each repository must be a JSON object in the following structure: "[{"name":"repository_name", "description": "repository_description", "provider": "repository_provider", "url": "repository_url"}]" | stk update infra --name infra-renamed --extra-repositories "[{"name":"my-example-infra-repo", "description": "repository for test my infra", "provider": "github", "url": "https://github.com/my-organization-name/my-example-infra-repo"}]" |
-h, --help | Shows the command help and exits. | stk update infra --help |
stk validate infra
The stk validate infra command validates the structure of an Infrastructure. To validate an Infrastructure, run the command inside the Infrastructure folder.
The command will:
- Validate the structure of your Infrastructure;
- Remove empty folders;
- Ignore files and folders that you do not want to keep after finishing your application development.
Files ignored in the .gitignore file will not be validated by the command.
At the end of the command execution, it prints a message with any inconsistencies and the validation result.
Usage
stk validate infra
Parameters
| Options | Description | Example |
|---|---|---|
-v, --verbose | Lists the details of all items analyzed, validated, and ignored in your Infrastructure. | stk validate infra --verbose |
-h, --help | Shows the command help and exits. | stk validate infra --help |