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

Add use_doppler_suffix option to AWS SM sync #102

Merged
merged 2 commits into from
Sep 19, 2024
Merged
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
1 change: 1 addition & 0 deletions docs/resources/secrets_sync_aws_secrets_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ resource "doppler_secrets_sync_aws_secrets_manager" "backend_prod" {

- `delete_behavior` (String) The behavior to be performed on the secrets in the sync target when this resource is deleted or recreated. Either `leave_in_target` (default) or `delete_from_target`.
- `kms_key_id` (String) The AWS KMS key used to encrypt the secret (ID, Alias, or ARN)
- `path_behavior` (String) The behavior to modify the provided path. Either `add_doppler_suffix` (default) which appends `doppler` to the provided path or `none` which leaves the path unchanged.
- `tags` (Map of String) AWS tags to attach to the secrets
- `update_metadata` (Boolean) If enabled, Doppler will update the AWS secret metadata (e.g. KMS key) during every sync. If disabled, Doppler will only set secret metadata for new AWS secrets. Note that Doppler never updates tags for existing AWS secrets.

Expand Down
25 changes: 24 additions & 1 deletion doppler/resource_sync_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ func resourceSyncAWSSecretsManager() *schema.Resource {
Optional: true,
ForceNew: true,
},
"path_behavior": {
Description: "The behavior to modify the provided path. Either `add_doppler_suffix` (default) which appends `doppler` to the provided path or `none` which leaves the path unchanged.",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
// Implicitly defaults to "add_doppler_suffix" but not defined here to avoid state migration
ValidateFunc: validation.StringInSlice([]string{"add_doppler_suffix", "none"}, false),
DiffSuppressFunc: func(k, oldValue, newValue string, d *schema.ResourceData) bool {
if oldValue == "" && newValue == "add_doppler_suffix" {
// Adding the default value explicitly
return true
} else if oldValue == "add_doppler_suffix" && newValue == "" {
// Removing the explicit default value
return true
} else {
return false
}
},
},
},
DataBuilder: func(d *schema.ResourceData) IntegrationData {
payload := map[string]interface{}{
Expand All @@ -51,10 +70,14 @@ func resourceSyncAWSSecretsManager() *schema.Resource {
if kmsKeyId, ok := d.GetOk("kms_key_id"); ok {
payload["kms_key_id"] = kmsKeyId
}

if updateMetadata, ok := d.GetOk("update_metadata"); ok {
payload["update_metadata"] = updateMetadata
}
if pathBehavior, ok := d.GetOk("path_behavior"); ok {
payload["use_doppler_suffix"] = pathBehavior == "add_doppler_suffix"
} else {
payload["use_doppler_suffix"] = true
}
return payload
},
}
Expand Down