Skip to content

Commit

Permalink
feat(elasticache/serverless): Add endpoint and reader_endpoint connec…
Browse files Browse the repository at this point in the history
…tionDetails
  • Loading branch information
portswigger-tim committed Nov 25, 2024
1 parent cc7b958 commit 2320013
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions config/elasticache/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,41 @@ func Configure(p *config.Provider) { //nolint:gocyclo
r.References["kms_key_id"] = config.Reference{
TerraformName: "aws_kms_key",
}

r.Sensitive.AdditionalConnectionDetailsFn = func(attr map[string]any) (map[string][]byte, error) {
conn := map[string][]byte{}

if endpoints, ok := attr["endpoint"].([]any); ok {
for i, ep := range endpoints {
if endpoint, ok := ep.(map[string]any); ok && len(endpoint) > 0 {
if address, ok := endpoint["address"].(string); ok {
key := fmt.Sprintf("endpoint_%d_address", i)
conn[key] = []byte(address)
}
if port, ok := endpoint["port"].(float64); ok {
key := fmt.Sprintf("endpoint_%d_port", i)
conn[key] = []byte(fmt.Sprintf("%g", port))
}
}
}
}
if readerendpoints, ok := attr["reader_endpoint"].([]any); ok {
for i, rp := range readerendpoints {
if readerendpoint, ok := rp.(map[string]any); ok && len(readerendpoint) > 0 {
if address, ok := readerendpoint["address"].(string); ok {
key := fmt.Sprintf("cluster_endpoint_%d_address", i)
conn[key] = []byte(address)
}
if port, ok := readerendpoint["port"].(float64); ok {
key := fmt.Sprintf("cluster_endpoint_%d_port", i)
conn[key] = []byte(fmt.Sprintf("%g", port))
}
}
}
}

return conn, nil
}
})

p.AddResourceConfigurator("aws_elasticache_user_group", func(r *config.Resource) {
Expand Down

0 comments on commit 2320013

Please sign in to comment.