Skip to content

Commit

Permalink
Update dfe_analytics docs
Browse files Browse the repository at this point in the history
  • Loading branch information
saliceti committed Oct 24, 2024
1 parent 97d26a6 commit ea56890
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
28 changes: 17 additions & 11 deletions aks/dfe_analytics/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# DfE Analytics
Create resources in Google cloud Bigquery and provides the required variables to applications so they can send events.

## Examples
## Usage
### Reuse existing dataset and events table

```hcl
provider "google" {
project = "apply-for-qts-in-england"
}
module "dfe_analytics" {
source = "./vendor/modules/dfe-terraform-modules//aks/dfe_analytics"
Expand All @@ -14,14 +18,17 @@ module "dfe_analytics" {
service_short = var.service_short
environment = var.environment
gcp_dataset = "events_${var.config}"
gcp_project_id = "apply-for-qts-in-england"
gcp_project_number = 385922361840
}
```

### Create new dataset and events table
Use for a new environment. To get the values for `gcp_taxonomy_id` and `gcp_policy_tag_id` see [Taxonomy and policy tag](#taxonomy-and-policy-tag).

```hcl
provider "google" {
project = "apply-for-qts-in-england"
}
module "dfe_analytics" {
source = "./vendor/modules/dfe-terraform-modules//aks/dfe_analytics"
Expand All @@ -32,35 +39,34 @@ module "dfe_analytics" {
environment = var.environment
gcp_keyring = "afqts-key-ring"
gcp_key = "afqts-key"
gcp_project_id = "apply-for-qts-in-england"
gcp_project_number = 385922361840
gcp_taxonomy_id = 5456044749211275650
gcp_policy_tag_id = 2399328962407973209
}
```

### Configure application
#### Enable in Ruby
## Configure application
### Enable in Ruby
```ruby
DfE::Analytics.configure do |config|
...
config.azure_federated_auth = ENV.include? "GOOGLE_CLOUD_CREDENTIALS"
end
```

#### Enable in .NET
### Enable in .NET
```cs
builder.Services.AddDfeAnalytics()
.UseFederatedAksBigQueryClientProvider();
```
Ensure the `ProjectNumber`, `WorkloadIdentityPoolName`, `WorkloadIdentityPoolProviderName` and `ServiceAccountEmail` configuration keys are populated within the `DfeAnalytics` configuration section.

#### Variables
Each variable is available as a separate output. For convenience, the `variables_map` output provides them all:
### Variables
The application requires these environment variables:
- BIGQUERY_PROJECT_ID
- BIGQUERY_TABLE_NAME
- BIGQUERY_DATASET
- GOOGLE_CLOUD_CREDENTIALS
Each variable is available as a separate [output](tfdocs#outputs). For convenience, the `variables_map` output provides them all:

```hcl
module "application_configuration" {
Expand All @@ -75,7 +81,7 @@ module "application_configuration" {
}
```

#### Enable on each app that requires it
### Enable on each app that requires it
```hcl
module "worker_application" {
source = "./vendor/modules/dfe-terraform-modules//aks/application"
Expand Down
3 changes: 1 addition & 2 deletions aks/dfe_analytics/tfdocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
| [azurerm_user_assigned_identity.gcp_wif](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/user_assigned_identity) | data source |
| [google_kms_crypto_key.main](https://registry.terraform.io/providers/hashicorp/google/6.6.0/docs/data-sources/kms_crypto_key) | data source |
| [google_kms_key_ring.main](https://registry.terraform.io/providers/hashicorp/google/6.6.0/docs/data-sources/kms_key_ring) | data source |
| [google_project.main](https://registry.terraform.io/providers/hashicorp/google/6.6.0/docs/data-sources/project) | data source |

## Inputs

Expand All @@ -44,8 +45,6 @@
| <a name="input_gcp_key"></a> [gcp\_key](#input\_gcp\_key) | Name of an existing customer-managed encryption key (CMEK). Required when creating the dataset | `string` | `null` | no |
| <a name="input_gcp_keyring"></a> [gcp\_keyring](#input\_gcp\_keyring) | Name of an existing keyring. Required when creating the dataset | `string` | `null` | no |
| <a name="input_gcp_policy_tag_id"></a> [gcp\_policy\_tag\_id](#input\_gcp\_policy\_tag\_id) | Policy tag ID. Required when creating the dataset | `number` | `null` | no |
| <a name="input_gcp_project_id"></a> [gcp\_project\_id](#input\_gcp\_project\_id) | ID of the Google cloud project e.g. 'rugged-abacus-218110', 'apply-for-qts-in-england'... Required | `string` | n/a | yes |
| <a name="input_gcp_project_number"></a> [gcp\_project\_number](#input\_gcp\_project\_number) | Google cloud project number. Required | `number` | n/a | yes |
| <a name="input_gcp_table_deletion_protection"></a> [gcp\_table\_deletion\_protection](#input\_gcp\_table\_deletion\_protection) | Prevents deletion of the event table. Default: true | `bool` | `true` | no |
| <a name="input_gcp_taxonomy_id"></a> [gcp\_taxonomy\_id](#input\_gcp\_taxonomy\_id) | Policy tags taxonomy ID. Required when creating the dataset | `number` | `null` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | AKS Namespace where the service is deployed to. Required | `string` | n/a | yes |
Expand Down

0 comments on commit ea56890

Please sign in to comment.