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

feat(api-key) support keepers for time rotating api keys #515

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ terraform {
required_providers {
confluent = {
source = "confluentinc/confluent"
version = "2.12.0"
version = "2.13.0"
}
time = {
source = "hashicorp/time"
version = "0.12.1"
}
}
}
Expand Down Expand Up @@ -49,6 +53,12 @@ resource "confluent_api_key" "app-manager-kafka-api-key" {
environment {
id = var.environment_id
}

# BEWARE: this will rotate your api key, make sure to update your configuration accordingly and
# restart your clients, if needed.
keepers = {
rotation_time = time_rotating.mykey_rotation.rotation_rfc3339
}
}

# The goal is to ensure that confluent_role_binding.app-manager-kafka-cluster-admin is created before
Expand All @@ -63,6 +73,11 @@ resource "confluent_api_key" "app-manager-kafka-api-key" {
]
}

# note this requires the terraform to be run regularly
resource "time_rotating" "mykey_rotation" {
rotation_days = 30
}

resource "confluent_service_account" "app-consumer" {
display_name = "app-${var.topic_name}-consumer"
description = "Service account to consume from '${var.topic_name}' topic of ${var.kafka_id} Kafka cluster"
Expand Down
7 changes: 7 additions & 0 deletions internal/provider/resource_api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
paramOwner = "owner"
paramResource = "managed_resource"
paramDisableWaitForReady = "disable_wait_for_ready"
paramKeepers = "keepers"

serviceAccountKind = "ServiceAccount"
userKind = "User"
Expand Down Expand Up @@ -94,6 +95,12 @@ func apiKeyResource() *schema.Resource {
Default: false,
ForceNew: true,
},
paramKeepers: {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Description: "Arbitrary map of values that, when changed, will trigger recreation of resource.",
},
},
}
}
Expand Down