@hashicorp/plugin-hcp-consul-backend
v0.1.3
Published
A backend for HCP Consul, this plugin exposes a services with routes that are used by the `@hashicorp/plugin-hcp-consul` plugin to query HCP Consul overview and service instances using HCP Consul Central public APIs.
Downloads
29
Maintainers
Readme
@hashicorp/plugin-hcp-consul-backend
A backend for HCP Consul, this plugin exposes a services with routes that are used by the @hashicorp/plugin-hcp-consul
plugin to query HCP Consul overview and service instances using HCP Consul Central public APIs.
Set Up
- Install the plugin using:
# From your Backstage root directory
yarn add --cwd packages/backend @hashicorp/plugin-hcp-consul-backend
- Create a
hcp-consul-backend.ts
file insidepackages/backend/src/plugins/
:
import { createRouter } from '@hashicorp/plugin-hcp-consul-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter(env);
}
- Modify your
packages/backend/src/index.ts
to include:
...
import { Config } from '@backstage/config';
import app from './plugins/app';
+import consul from './plugins/hcp-consul-backend';
...
async function main() {
...
const authEnv = useHotMemoize(module, () => createEnv('auth'));
+ const consulBackendEnv = useHotMemoize(module, () => createEnv('consul'));
...
const apiRouter = Router();
apiRouter.use('/catalog', await catalog(catalogEnv));
+ apiRouter.use('/hcp-consul-backend', await consul(consulBackendEnv));
Note: for this backend to work, the consul
configuration described in the README of @hashicorp/plugin-hcp-consul
must be implemented.