confluentinc / terraform-provider-confluent

Terraform Provider for Confluent
Apache License 2.0
31 stars 64 forks source link

Is it possible create an API key to consume audit logs? #292

Open javiervelamindcurv opened 1 year ago

javiervelamindcurv commented 1 year ago

Hello!

Is it possible create an API key to consume audit logs?

thanks!

ppolster commented 5 months ago

Yes, you can.

Use the information of your specific Audit Log Cluster to create the specific "confluent_service_account" resource. Keep in mind that only two API Keys may be created in parallel for the Audit Log Cluster.

You can get the information for the service account , the cluster and the environment from https://confluent.cloud/settings/audit_log/cli Or execute via CLI:

confluent login --save
confluent audit-log describe

Code snippet for HCL:

data "confluent_service_account" "this" {
  id = {id of your audit log service account}
}
resource "confluent_api_key" "audit-log-keys" {
  count        = 2
  display_name = "Name-${count.index}"
  description  = "Your Description"

  owner {
    id          = data.confluent_service_account.this.id
    api_version = data.confluent_service_account.this.api_version
    kind        = data.confluent_service_account.this.kind
  }

  managed_resource {
    content {
      id          = {id of your audit log cluster}
      api_version = "cmk/v2"
      kind        = "Cluster"

      environment {
        id = {id of your audit log environment}
      }
    }
 }

From my POV ticket may be closed.