Create Infrastructure via STK CLI
In this section, you will find a guide on how to create Infrastructure via STK CLI.
To create Infrastructure on StackSpot, you can use Infrastructure Plugins that generate infrastructure pieces (IaC code). This process is similar to creating an Application, which generates source code from Application Plugins.
Check the steps

Prerequisites
- Have STK CLI installed and be a member of a Workspace.
- Be logged in to your StackSpot Account.
- Have access to a Studio.
- Have a Stack and a Starter.
- Have environments created in your account.
- Have Deployment via Self-Hosted configured to set up and connect environments in the Cloud Account.
- Have your SCM configured (your Account administrator is responsible for this configuration).
- If your account is Enterprise and the administrator decides that users should manage access to via Personal Access Token (PAT) individually, you must configure it in 'External Connections'.SCM
If you still need to meet any of these requirements, use the links above to complete them before proceeding.
Follow the steps to create your Infrastructure via STK CLI
You will follow the steps below via STK CLI.
Step 1. Open your terminal, select the Workspace you want to use for Infrastructure and execute:
stk use workspace
Choose the Workspace from the list and press Enter.
To see the list of available Workspaces from your terminal, run the command stk list workspace.
The Workspace in use is marked with an asterisk (*).
You can also see the list on the StackSpot Platform, in the 'Workspaces' section.
Step 2. To create an Infrastructure, execute:
stk create infra
Answer the questions in the terminal:
-
Name your Infrastructure: enter the name of your Infrastructure.
The Infrastructure name has a 60-character limit.
-
Do you want to start a Git repository?: answer '(Y/n) Yes or No' to start a Git repository in the Infrastructure folder. If the answer is '(Y) Yes', then you must enter the URL of the remote repository.
-
Infrastructure description: enter a brief description for your Infrastructure.
-
Select the Studio: select one of the Studios available in your account.
-
Select the Stack: select the desired Stack.
-
Select the version of the Stack: select the version of the Stack you want to use.
-
Select the desired Infrastructure plugins: select the desired Infrastructure plugins from the list displayed in the terminal.
-
Name the usage of the Plugin: the Plugin usage is automatically filled. Then, you must answer the Plugin inputs.
You can apply the same Plugin more than once in your Infrastructure. That is why the question below appears every time:
? Name the usage of the plugin (studio/stack/name-of-plugin)
This is the alias of the Plugin usage and it is pre-filled by STK CLI. For example:
- The name of the Plugin is bucket-s3.
- If it is the first time you apply this Plugin, the
aliasis pre-filled with a name like bucket-s3-1694809616257. This number is a Unix Timestamp.
The alias indicates the purpose of this Plugin application and avoids duplicate names.
The alias is immutable once configured.
Step 3. Answer the remaining questions in your terminal. If any Plugin requires a Connection Interface, provide the usage alias.
Repeat the process for all the Plugins you apply.
Your Infrastructure was created.
You must not manually edit the stk.yaml file of an Application or Infrastructure. You can modify the Plugins in your Application or Infrastructure using the commands below:
- To modify the version or settings of a Plugin:
stk update plugin
- To remove a Plugin:
stk remove plugin
- To add new features to your project:
stk apply plugin
Step 4. Register your Infrastructure in your account. Access its directory:
cd <infrastructure-name>
Then, execute the command below to register:
stk register infra
Answer the questions:
- Repository URL: inform the repository that will store your infrastructure code.
- Base branch: inform the branch you will use in the repository.
Your Infrastructure was created and registered.
You can now view your Infrastructure data within your Workspace on the StackSpot Platform. Access the 'Infrastructure' section.
How to Use Account Variables to Configure Plugins in Your Infrastructure
You can choose to use Account Variables created by your Organization to fill in the inputs for Plugins and Actions when creating your Infrastructure.
To do this, type {{ when responding to the input and select the Variable you want to use.
Visit the How to Create Account Variables page to learn more.
The infrastructure deployment is only performed at this stage if your organization has configured the deployment via Runtime Self-Hosted.
Next steps
- Learn how to deploy your Infrastructure in the Deployment section.
- Manage how you run Actions in your Infrastructure.
- Manage and monitor your Application.
- To destroy your Infrastructure, see the Destroy section.