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

Vault: enabled metrics_config and audit_log_config for HCP Vault #319

Merged
merged 4 commits into from
Jun 7, 2022

Conversation

andrey-donelli
Copy link
Contributor

@andrey-donelli andrey-donelli commented Jun 6, 2022

πŸ› οΈ Description

Add support to metrics and audit log to the HCP Vault resource

🚒 Release Note

Release note for CHANGELOG:

* Vault: enable metrics_config and audit_log_config  [GH-319]

πŸ—οΈ Acceptance tests

  • Are there any feature flags that are required to use this functionality?
  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

https://user-images.githubusercontent.com/97476714/170169244-73934537-7f0c-4ec6-a8d4-15e5a792955d.png
https://user-images.githubusercontent.com/97476714/170177128-9f341b0b-6bd9-4efd-90ac-568d0bd14dd8.png

$ make testacc TESTARGS='-run=TestAccXXX'
=== RUN   TestGetValidObservabilityConfig
--- PASS: TestGetValidObservabilityConfig (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-hcp/internal/provider	0.297s

--- PASS: TestAccVaultCluster (2601.85s)
PASS
ok  	github.com/hashicorp/terraform-provider-hcp/internal/provider	2602.156s
...

@hashicorp-cla
Copy link

hashicorp-cla commented Jun 6, 2022

CLA assistant check
All committers have signed the CLA.

@andrey-donelli andrey-donelli marked this pull request as ready for review June 6, 2022 11:34
@andrey-donelli andrey-donelli requested review from a team, codergs, markgacoka and bcmdarroch June 6, 2022 11:34
Copy link
Contributor

@codergs codergs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a port of already approved PR

Copy link
Contributor

@bcmdarroch bcmdarroch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just had two comments to address.

I did some local testing to see the impact on existing resources, and everything checks out.

  1. Existing Vault cluster
# config
resource "hcp_hvn" "hvn_1" {
  hvn_id         = "hvn-1"
  cloud_provider = "aws"
  region         = "us-west-2"
  cidr_block     = "172.25.16.0/20"
}

resource "hcp_vault_cluster" "c1" {
  cluster_id      = "test-primary"
  hvn_id          = hcp_hvn.hvn_1.hvn_id
  tier            = "plus_small"
  public_endpoint = true

  # metrics_config {
  #   datadog_api_key = "test_datadog"
  #   datadog_region =       "us1"
  # }
  # audit_log_config {
  #   datadog_api_key = "test_datadog"
  #   datadog_region  = "us1"
  # }
}

$ terraform apply
...
hcp_vault_cluster.c1: Creation complete after 5m32s [id=/project/project1/hashicorp.vault.cluster/test-primary]

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
  1. Add metrics config
# updated config
resource "hcp_vault_cluster" "c1" {
  cluster_id      = "test-primary"
  hvn_id          = hcp_hvn.hvn_1.hvn_id
  tier            = "plus_small"
  public_endpoint = true

   metrics_config {
     datadog_api_key = "test_datadog"
     datadog_region =       "us1"
   }
   audit_log_config {
     datadog_api_key = "test_datadog"
     datadog_region  = "us1"
   }
}

$ terraform apply
...
hcp_vault_cluster.c1: Modifications complete after 11m25s [id=/project/project1/hashicorp.vault.cluster/test-primary]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Removing the config works too 😎

@@ -381,7 +469,7 @@ func TestAccPerformanceReplication_Validations(t *testing.T) {
resource "hcp_vault_cluster" "c2" {
cluster_id = "test-secondary"
hvn_id = hcp_hvn.hvn1.hvn_id
tier = hcp_vault_cluster.c1.tier
tier = "plus_medium"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These references are here intentionally as best practice reference. Can you revert the tier changes?

@@ -277,6 +293,78 @@ resource "hcp_hvn" "hvn2" {
`, vaultCluster)
}

func TestGetValidObservabilityConfig(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to go in its own file, like peering_test.go, since I don't think unit tests and acceptance tests will run in the same file.

@andrey-donelli andrey-donelli merged commit b304b3f into main Jun 7, 2022
@andrey-donelli andrey-donelli deleted the hcp-vault-add-metrics-audit-log-support branch June 7, 2022 10:21
aidan-mundy pushed a commit that referenced this pull request Sep 8, 2023
* Added metrics and audit log config for HCP Vault

* Add the docs

* Rollback changes from legacy cold on internal

* put test in another file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants