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

chore(userconfig/converters): improve ip_filter safeguard #1641

Merged
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
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