Skip to content

Commit

Permalink
chore(userconfig/converters): improve ip_filter safeguard
Browse files Browse the repository at this point in the history
  • Loading branch information
Serpentiel committed Mar 7, 2024
1 parent ee5c852 commit 7532175
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ nav_order: 1
- Add `external_aws_cloudwatch_logs`, `external_elasticsearch_logs_user_config`, `external_opensearch_logs_user_config`,
`prometheus_user_config` service integration configs
- Fix `aiven_kafka_schema` Protobuf normalization
- Add `AIVEN_ALLOW_IP_FILTER_PURGE` environment variable to allow purging of IP filters. This is a safety feature to
prevent accidental purging of IP filters, which can lead to loss of access to services. To enable purging, set the
environment variable to any value before running Terraform commands.

## [4.14.0] - 2024-02-20

Expand Down
12 changes: 8 additions & 4 deletions internal/sdkprovider/userconfig/converters/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ func Expand(kind string, s *schema.Schema, d *schema.ResourceData) (map[string]a

renameAliases(dto)

if v, ok := dto["ip_filter"]; ok {
list, ok := v.([]any)
if ok && len(list) == 0 && os.Getenv("AIVEN_FORCE_IP_FILTER_PURGE") != "1" {
return nil, fmt.Errorf("ip_filter list will be purged. If this is not expected, then please create an issue on GitHub. Otherwise provide AIVEN_FORCE_IP_FILTER_PURGE=1")
// TODO: Move to a validation part of the schema.
if v, ok := dto["ip_filter"].([]any); ok && len(v) == 0 {
if _, ok := os.LookupEnv("AIVEN_ALLOW_IP_FILTER_PURGE"); ok {
return nil, fmt.Errorf(
"ip_filter list is empty, but AIVEN_ALLOW_IP_FILTER_PURGE is not set. Please set " +
"AIVEN_ALLOW_IP_FILTER_PURGE to confirm that you want to remove all IP filters, which is going " +
"to block all traffic to the service",
)
}
}
return dto, nil
Expand Down

0 comments on commit 7532175

Please sign in to comment.