Skip to content

Commit

Permalink
feat: beacon analytics schema (#544)
Browse files Browse the repository at this point in the history
* feat: beacon analytics schema

* fix: model fix

* fix: removed unneccessary cluster type from schema

* refactor: package constant for client timeout

* fix: typo

* fix: schema change requests

* feat: beacon analytics create (#549)

* fix: model fix

* feat: beacon analytics cluster create

* fix: examples

* fix: rebase fixes

* fix: comments

* feat: beacon analytics update and import (#550)

* fix: examples

* feat: beacon analytics cluster update

* feat: beacon analytics cluster update and import

* fix: examples beacon analytics cluster

* fix: beacon analytics delete (#551)

* fix: beacon analytics delete cluster

* refactor: removed beacon naming (#552)

* refactor: removed beacon naming

* fix: removed unused struct

* fix: typo

* fix: cidr optional

* fix: examples and beacon naming

* fix: wip datasource

* fix: bug in analytics cluster resource

* fix: datasource fix

* fix: import
  • Loading branch information
wai-wong-edb authored Jun 17, 2024
1 parent 1905afd commit 88c8951
Show file tree
Hide file tree
Showing 15 changed files with 1,079 additions and 16 deletions.
78 changes: 78 additions & 0 deletions examples/data-sources/biganimal_analytics_cluster/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
variable "cluster_id" {
type = string
description = "The id of the cluster"
}

variable "project_id" {
type = string
description = "BigAnimal Project ID"
}

data "biganimal_analytics_cluster" "this" {
cluster_id = var.cluster_id
project_id = var.project_id
}

output "backup_retention_period" {
value = data.biganimal_analytics_cluster.this.backup_retention_period
}

output "cluster_name" {
value = data.biganimal_analytics_cluster.this.cluster_name
}

output "created_at" {
value = data.biganimal_analytics_cluster.this.created_at
}

output "csp_auth" {
value = coalesce(data.biganimal_analytics_cluster.this.csp_auth, false)
}

output "instance_type" {
value = data.biganimal_analytics_cluster.this.instance_type
}

output "metrics_url" {
value = data.biganimal_analytics_cluster.this.metrics_url
}

output "logs_url" {
value = data.biganimal_analytics_cluster.this.logs_url
}

output "pg_type" {
value = data.biganimal_analytics_cluster.this.pg_type
}

output "pg_version" {
value = data.biganimal_analytics_cluster.this.pg_version
}

output "phase" {
value = data.biganimal_analytics_cluster.this.phase
}

output "private_networking" {
value = coalesce(data.biganimal_analytics_cluster.this.private_networking, false)
}

output "cloud_provider" {
value = data.biganimal_analytics_cluster.this.cloud_provider
}

output "region" {
value = data.biganimal_analytics_cluster.this.region
}

output "resizing_pvc" {
value = data.biganimal_analytics_cluster.this.resizing_pvc
}

output "pe_allowed_principal_ids" {
value = data.biganimal_analytics_cluster.this.pe_allowed_principal_ids
}

output "service_account_ids" {
value = data.biganimal_analytics_cluster.this.service_account_ids
}
8 changes: 8 additions & 0 deletions examples/data-sources/biganimal_analytics_cluster/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
biganimal = {
source = "EnterpriseDB/biganimal"
version = "0.10.0"
}
}
}
2 changes: 2 additions & 0 deletions examples/resources/biganimal_analytics_cluster/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# terraform import biganimal_analytics_cluster.<resource_name> <project_id>/<cluster_id>
terraform import biganimal_analytics_cluster.analytics_cluster prj_deadbeef01234567/p-abcd123456
74 changes: 74 additions & 0 deletions examples/resources/biganimal_analytics_cluster/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
terraform {
required_providers {
biganimal = {
source = "EnterpriseDB/biganimal"
version = "0.10.0"
}
random = {
source = "hashicorp/random"
version = "3.6.0"
}
}
}

resource "random_password" "password" {
length = 16
special = true
override_special = "!#$%&*()-_=+[]{}<>:?"
}

variable "cluster_name" {
type = string
description = "The name of the cluster."
}

variable "project_id" {
type = string
description = "BigAnimal Project ID"
}

resource "biganimal_analytics_cluster" "analytics_cluster" {
cluster_name = var.cluster_name
project_id = var.project_id
pause = false

allowed_ip_ranges = [
{
cidr_block = "127.0.0.1/32"
description = "localhost"
},
{
cidr_block = "192.168.0.1/32"
description = "description!"
},
]

backup_retention_period = "30d"
csp_auth = false

instance_type = "aws:m6id.12xlarge"
password = resource.random_password.password.result

maintenance_window = {
is_enabled = false
start_day = 0
start_time = "00:00"
}

pg_type = "epas"
pg_version = "16"
private_networking = false
cloud_provider = "bah:aws"
region = "ap-south-1"
# pe_allowed_principal_ids = [
# <example_value> # AWS example: "123456789012", Azure example: "9334e5e6-7f47-aE61-5A4F-ee067daeEf4A", GCP example: "development-data-123456"
# ]
# service_account_ids = [
# <only_needed_for_bah:gcp_clusters> # ex: "[email protected]"
# ]
}

output "password" {
sensitive = true
value = resource.biganimal_analytics_cluster.analytics_cluster.password
}
2 changes: 2 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"time"
)

const clientTimeoutSeconds = 60

type API struct {
BaseURL string
Token string
Expand Down
21 changes: 21 additions & 0 deletions pkg/api/beacon_analytics_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package api

import (
"net/http"
"time"
)

type BeaconAnalyticsClient struct {
API
}

func NewBeaconAnalyticsClient(api API) *BeaconAnalyticsClient {
httpClient := http.Client{
Timeout: clientTimeoutSeconds * time.Second,
}

api.HTTPClient = httpClient
c := BeaconAnalyticsClient{API: api}

return &c
}
2 changes: 1 addition & 1 deletion pkg/api/cloud_provider_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type CloudProviderClient struct{ API }

func NewCloudProviderClient(api API) *CloudProviderClient {
httpClient := http.Client{
Timeout: 60 * time.Second,
Timeout: clientTimeoutSeconds * time.Second,
}

api.HTTPClient = httpClient
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/cluster_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ClusterClient struct {

func NewClusterClient(api API) *ClusterClient {
httpClient := http.Client{
Timeout: 60 * time.Second,
Timeout: clientTimeoutSeconds * time.Second,
}

api.HTTPClient = httpClient
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/pgd_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var clusterClient = ClusterClient{}

func NewPGDClient(api API) *PGDClient {
httpClient := http.Client{
Timeout: 60 * time.Second,
Timeout: clientTimeoutSeconds * time.Second,
}

api.HTTPClient = httpClient
Expand Down
3 changes: 1 addition & 2 deletions pkg/api/project_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ProjectClient struct{ API }

func NewProjectClient(api API) *ProjectClient {
httpClient := http.Client{
Timeout: 60 * time.Second,
Timeout: clientTimeoutSeconds * time.Second,
}

api.HTTPClient = httpClient
Expand Down Expand Up @@ -81,7 +81,6 @@ func (c ProjectClient) List(ctx context.Context, query string) ([]*models.Projec
err = json.Unmarshal(body, &response)

return response.Data, err

}

func (c ProjectClient) Update(ctx context.Context, projectId, projectName string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/region_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type RegionClient struct{ API }

func NewRegionClient(api API) *RegionClient {
httpClient := http.Client{
Timeout: 60 * time.Second,
Timeout: clientTimeoutSeconds * time.Second,
}

api.HTTPClient = httpClient
Expand Down
Loading

0 comments on commit 88c8951

Please sign in to comment.