cs-icon.svg

Auto-populate Environment Variables from a Linked Stack

Importing a Starter app or any application with the Contentstack SDK requires adding key-value pairs of environment variables like CONTENTSTACK_API_KEY, CONTENTSTACK_DELIVERY_TOKEN, etc. Adding these environment variables manually is a tedious task.

Launch allows you to auto-populate the Environment Variables from your stack, by linking the stack to your project. This allows you to easily use the CMS environment variables while deploying your Launch project.

This step-by-step guide lets you link a stack to your project to auto-populate Environment Variables.

Note: This feature can also be used when creating or configuring an environment.

Prerequisites

  1. Contentstack account
  2. Access to Launch for your organization

Steps for execution

Follow the steps to link a stack to your project:

  1. Click Launch from the left navigation panel, as shown below. Launch_New_LeftNav_Hover.png
  2. Click the + New Project button.Launch_Landing_Page_2024Latest.png
  3. Select Import from a Git Repository or Upload a file as usual from the Create New Project modal.
  4. In the Environment Variables section, click the Connect and Import Variables button.

    Launch_Auto-Populate-Env-Var_Connect-and-Import

  5. Select the Stack which has the Starter app installed and then select the Delivery Token for your stack.

    Note: On selecting a delivery token, Launch automatically selects a Stack environment available for the selected token.

    Launch-LinkedStack-Select_Stack_DeliveryToken.png

  6. Click the Import Variables button.
    Launch-LinkedStack-Import_Variables.png

    You can see that the Environment Variables were auto-populated from your selected stack.

    Launch_Auto-Populate-Env-Var_Auto-Populated

  7. Click the Deploy button.Launch-LinkedStack-Deployment.png

    Your project is now deployed.

View a linked stack

Follow the step to view the linked stack after project creation:

  1. Click the Settings icon in the left panel and then click Stack Integration to view the linked stack.

    Launch_Linked_Stack_Venus2_ClicktoView.png

    You can see the linked stack.

    Launch_Linked_Stack_Venus2_ExistingStack.png

Update a linked stack

Follow the steps below to update a linked stack:

  1. Click the Settings icon in the left panel and then click Stack Integration.
  2. Choose a stack from the dropdown and then click Connect Stack button.

    Launch_Linked_Stack_Venus2_NewStack.png

  3. Once you choose a different stack, you must sync the stack variables. To do this, follow the steps below:
    1. Click Environments under Settings.
    2. Select your environment (Default in this example).
    3. Click Environment Variables.
    4. Click Sync Stack Variables.Launch_Linked_Stack_Venus2_Sync_Stack.png
    5. A popup displays asking for your confirmation. Select your delivery token and then click the Sync Stack Variables button.Launch_Linked_Stack_Venus2_Sync_Modal.png
    6. Click the Save button.

    This will sync your new stack’s Environment Variables to your project.

Was this article helpful?
^