Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update authentication documentation #8

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions AUTHENTICATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Authenticating to NewRelic API

## Table of Contents

- [Authenticating to NewRelic API](#authenticating-to-newrelic-api)
- [Table of Contents](#table-of-contents)
- [Overview](#overview)
- [Using `ProviderConfig`](#using-providerconfig)

## Overview

`crossplane-provider-newrelic` requires credentials to be provided in order to authenticate to the
NewRelic API. As this provider is upjet based, the authentication mechanism mirrors the terraform provider configuration.
This is described in detail in the
[provider_configuration guide](https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/guides/provider_configuration#configuration-via-the-provider-block).

## Using `ProviderConfig`

`crossplane-provider-newrelic` will be use credentials stored in a secret and referenced from a `ProviderConfig`.

The first thing that needs to be done is to create a `ProviderConfig`:

```console
$ cat <<EOF | kubectl apply -f -
apiVersion: provider-newrelic.upbound.io/v1beta1
kind: ProviderConfig
metadata:
name: default-us
spec:
credentials:
source: Secret
secretRef:
name: example-creds-us
namespace: crossplane-system
key: credentials
EOF
```

Next create a secret as referenced from the `ProviderConfig`:

```console
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: example-creds-us
namespace: crossplane-system
type: Opaque
stringData:
credentials: |
{
"account_id": "NEW_RELIC_ACCOUNT_ID", # required.
"api_key": "NEW_RELIC_API_KEY", # required. Usually prefixed with 'NRAK'
"region": "US" # optional. Valid regions are US and EU
}
EOF
```

You may now reference the `ProviderConfig` in your resources:
```console
$ cat <<EOF | kubectl apply -f -
---
apiVersion: alert.newrelic.upbound.io/v1alpha1
kind: Policy
metadata:
name: example-policy
spec:
forProvider:
incidentPreference: PER_POLICY
name: example-policy
providerConfigRef:
name: default-us
EOF
```

Multiple `ProviderConfigs` can be used to switch between credentials when more than
one target account or region is being reconciled by the provider.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Provider NewRelic

# https://github.com/newrelic/terraform-provider-newrelic/tree/main/newrelic
# https://github.com/upbound/upjet-provider-template
# https://github.com/crossplane/upjet/blob/v0.10.0/docs/add-new-resource-short.md

`crossplane-provider-newrelic` is a [Crossplane](https://crossplane.io/) provider that
is built using [Upjet](https://github.com/crossplane/upjet) code
generation tools and exposes XRM-conformant managed resources for the
Expand All @@ -12,7 +8,7 @@ NewRelic API.
## Getting Started

Install the provider by using the following command after changing the image tag
to the [latest release](https://marketplace.upbound.io/providers/upbound/provider-newrelic):
to the [latest release](https://marketplace.upbound.io/providers/crossplane-contrib/crossplane-provider-newrelic):
```
up ctp provider install crossplane-contrib/crossplane-provider-newrelic:v0.1.0
```
Expand All @@ -34,16 +30,22 @@ Notice that in this example Provider resource is referencing ControllerConfig wi
You can see the API reference [here](https://doc.crds.dev/github.com/upbound/provider-newrelic).

## Authentication
See - /examples/providerconfig/providerconfig.yaml
See - /examples/providerconfig/secret.yaml.tmpl
This is documented in [AUTHENTICATION.md](AUTHENTICATION.md).
* [examples/providerconfig/providerconfig.yaml](examples/providerconfig/providerconfig.yaml)
* [examples/providerconfig/secret.yaml.tmpl](examples/providerconfig/secret.yaml.tmpl)

# Currently Supported Resources
* `alert_policy` - /examples/alert/policy.yaml
* `nrql_alert_condition`
* `dashboardjson` - /examples/dashboard/dashboardjson.yaml
* `alert_destination`
* `alert_channel`
* `workflow` - /examples/workflow/workflow.yaml
* `alert_channel` - [examples-generated/alert/channel.yaml](examples-generated/alert/channel.yaml).
* `alert_destination` - [examples/alert/destination.yaml](examples/alert/destination.yaml).
* `alert_policy` - [examples/alert/policy.yaml](examples/alert/policy.yaml).
* `dashboardjson` - [examples/dashboard/dashboardjson.yaml](examples/dashboard/dashboardjson.yaml).
* `nrql_alert_condition` - [examples-generated/nrql/alertcondition.yaml](examples-generated/nrql/alertcondition.yaml).
* `workflow` - [examples/workflow/workflow.yaml](examples/workflow/workflow.yaml).

## Upstream Documentation
* https://github.com/newrelic/terraform-provider-newrelic/tree/main/newrelic
* https://github.com/upbound/upjet-provider-template
* https://github.com/crossplane/upjet/blob/v0.10.0/docs/add-new-resource-short.md

## Developing

Expand Down Expand Up @@ -73,4 +75,4 @@ make build
## Report a Bug

For filing bugs, suggesting improvements, or requesting new features, please
open an [issue](https://github.com/upbound/provider-newrelic/issues).
open an [issue](https://github.com/crossplane-contribb/crossplane-provider-newrelic/issues).
5 changes: 3 additions & 2 deletions examples/providerconfig/secret.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type: Opaque
stringData:
credentials: |
{
"username": "admin",
"password": "t0ps3cr3t11"
"account_id": "NEW_RELIC_ACCOUNT_ID", # required.
"api_key": "NEW_RELIC_API_KEY", # required. Usually prefixed with 'NRAK'
"region": "US" # optional. Valid regions are US and EU
}
Loading