Skip to main content

Create your first environment

Managing multiple virtual machines, volumes, and other resources can become challenging due to the lack of organization.

To address this issue, you can group your resources within environments. In Infrahub, each resource, including SSH keypairs, virtual machines, volumes, etc., is created within a designated environment. These environments provide users with an organized management system.

Creating an environment

/core/environments

Using this API endpoint, you can create multiple environments to efficiently manage all your resources.
For example, if you are handling two distinct projects with designated environments for development and production, you can assign them meaningful names like project-1-development and project-1-production. You can then create the necessary resources for each corresponding environment.


To create an environment:

  • Send a request to https://infrahub-api.nexgencloud.com/v1/core/environments with the following headers and request body:

    • Include the following headers:
      • To authenticate the request include the api_key header containing your API Key generated in the previous step.
      • Include the "Content-Type: application/json" header so that the request body will be accepted.
    • Include the following fields in the request body:
      • name: Name of the environment you are creating.
      • region: Specify the region in which to create the environment, choose either CANADA-1, or NORWAY-1.
Example request
curl -X POST "https://infrahub-api.nexgencloud.com/v1/core/environments"\
-H "api_key: YOUR-API-KEY"\
-H "Content-Type: application/json"
-d '{
"name": "development",
"region": "NORWAY-1"
}'
Response
{
"status": true,
"message": "Environment is created successfully",
"environment": {
"id": 2,
"name": "development",
"region": "NORWAY-1",
"created_at": "2023-04-19T05:09:16"
}
}

Next, to gain access to your resources, let's import your first SSH key.


Back to top