Skip to main content

Configure the Go agent

To configure the agent, you specify settings in a YAML file called contrast_security.yaml. The simplest way to get started is to download a configuration file from the Contrast web interface. This file is pre-populated with the required settings for your organization.

The required settings are:

  api_key: <key>
  service_key: <key>
  user_name: <key>

You can also find the keys under Organization settings > Agent in the Contrast web interface.


You can also set any configuration value with environment variables instead of in a YAML file. Using environment variables is useful if you are using Contrast in containers or CI/CD pipelines.

If you set values in both the YAML file and with environment variables, the agent uses the environment variables, as described in order of precedence.

Location of the Go configuration file

The Contrast Go agent looks for the contrast_security.yaml file in the following directories until it finds one:

  • Current directory

  • /etc/contrast/go/

  • /etc/contrast/

  • Darwin:$HOME/Library/Preferences/contrast/

  • Darwin:$HOME/Library/Preferences/contrast/go/

  • Linux:$XDG_CONFIG_DIR/contrast/

  • Linux:$XDG_CONFIG_DIR/contrast/go/

Go YAML template

This template includes all available settings for the Go agent. (Learn more about YAML configuration.)

You can also find the settings and generate a custom configuration file with the Contrast agent configuration editor.