Skip to main content

Connect Service to Component

What you’ll learn

How to connect your component to a Managed service (e.g., database, authentication service, messaging service, etc.) or an External service.

The main advantage of doing so within CodeNOW is that you don't have to worry about connection credentials in order to create and use Managed services, all it takes is a few clicks. Therefore, you, as a developer, have everything you need at your disposal.


How to create a new connection to Managed or External service

While creating a new component

  1. Click on the Add new connection button
  2. Choose a name for the connection and select one of the supported services
  3. Click Confirm

This adds the newly defined connection to the .codenow.config.yaml file in the main branch.

Editing an existing component

  1. Go to the Connected Services section in the detail of your component
  2. Select the branch for which you want to add a new service connection and click on the Edit button
  3. Click on the Add connection button
  4. Choose a name for the connection and select one of the supported services
  5. Click Confirm

How to configure Runtime Connectivity

  1. Find Connected Services in component detail and click on the Connection properties button
    • The displayed environment variables will be set during deployment depending on which service instance you choose to use
  2. Modify your project's deployment configuration to use the environment variables from the previous step for establishing a connection with the service
    • The format of your configuration files depend on your tech stack
    • For example, for the PostgreSQL from the images below, you could define the following connection string: "Host=${POSTGRESQL_HOST};Port=${POSTGRESQL_PORT};Database=${POSTGRESQL_DATABASE_NAME};User Id=${POSTGRESQL_USERNAME};Password=${POSTGRESQL_PASSWORD}"

Select a specific service instance in preview or manually created deployment configuration and CodeNow will automatically set the environment variables, so that your component will be connected to the chosen service.