Skip to content

feat(cdn) - Feature parity - #1601

Open
matheuspolitano wants to merge 9 commits into
stackitcloud:mainfrom
matheuspolitano:mp/cdn/feature-parity
Open

feat(cdn) - Feature parity#1601
matheuspolitano wants to merge 9 commits into
stackitcloud:mainfrom
matheuspolitano:mp/cdn/feature-parity

Conversation

@matheuspolitano

@matheuspolitano matheuspolitano commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

(https://jira.schwarz/browse/STACKITCDN-1451)

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Acceptance tests got implemented or updated (see e.g. here)
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@matheuspolitano
matheuspolitano requested a review from a team as a code owner July 21, 2026 13:48
@cgoetz-inovex

Copy link
Copy Markdown
Contributor

Hi @matheuspolitano,
thanks for your contribution, I've created an internal issue to review and test this PR.

@github-actions

Copy link
Copy Markdown

This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it.

@github-actions github-actions Bot added the Stale PR is marked as stale due to inactivity. label Jul 30, 2026
@rubenhoenle rubenhoenle removed the Stale PR is marked as stale due to inactivity. label Jul 30, 2026
Comment thread stackit/internal/services/cdn/distribution/datasource_test.go
Comment thread stackit/internal/services/cdn/distribution/resource_test.go
Comment thread stackit/internal/services/cdn/distribution/resource.go Outdated
Comment thread stackit/internal/services/cdn/distribution/resource.go
Comment thread stackit/internal/services/cdn/distribution/resource.go
Comment thread stackit/internal/services/cdn/distribution/resource.go
Matheus Politano added 4 commits August 10, 2026 15:37
The blocked_ips attribute is Optional+Computed without a default, so it
can be unknown at plan time. Decoding it into a *[]string field failed
with 'Received unknown value, however the target type cannot handle
unknown values'.

Change the BlockedIps field in distributionConfig from *[]string to
types.List and guard reads with utils.IsUndefined before converting
elements via ElementsAs.
Comment on lines +1034 to +1037
configPatch.DefaultCacheDuration = *cdnSdk.NewNullableString(conversion.StringValueToPointer(configModel.DefaultCacheDuration))
}
if !utils.IsUndefined(configModel.MonthlyLimitBytes) {
configPatch.MonthlyLimitBytes = *cdnSdk.NewNullableInt64(conversion.Int64ValueToPointer(configModel.MonthlyLimitBytes))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example config:

   resource "stackit_cdn_distribution" "example-distribution" {
     project_id = var.project_id

     config = {
       backend = {
         type       = "http"
         origin_url = "https://example.com"
       }

       regions = ["EU"]

       default_cache_duration = "PT2H"
       monthly_limit_bytes    = 104857600
     }
   }

run terraform apply then remove default_cache_duration and monthly_limit_bytes.
Then run apply again.

snippet from state:

        default_cache_duration = "PT2H"
        forward_host_header    = false
        monthly_limit_bytes    = 104857600

I'd expect that the state contains the same values as when a distribution is created without these two values in the config:

default_cache_duration = "P1D"

and monthly_limit_bytes missing completely from state.

Comment on lines +1505 to +1510
var defaultCacheDuration types.String
if distribution.Config.DefaultCacheDuration.IsSet() {
defaultCacheDuration = types.StringPointerValue(distribution.Config.DefaultCacheDuration.Get())
} else {
defaultCacheDuration = types.StringNull()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: could be simplified

Suggested change
var defaultCacheDuration types.String
if distribution.Config.DefaultCacheDuration.IsSet() {
defaultCacheDuration = types.StringPointerValue(distribution.Config.DefaultCacheDuration.Get())
} else {
defaultCacheDuration = types.StringNull()
}
defaultCacheDuration := types.StringPointerValue(distribution.Config.DefultCacheDuration.Get())

These NullableStringTypes are a bit unintuitive, Get() is always save to call, it will just return nil. When passed to types.StringPointerValue() this would result in a StringNull:

func TestNullableStringToTerraformString(t *testing.T) {
	uninitialized := cdnSdk.NullableString{}

	setNil := cdnSdk.NullableString{}
	setNil.Set(nil)

	uninitializedValue := types.StringPointerValue(uninitialized.Get())
	setNilValue := types.StringPointerValue(setNil.Get())

	if diff := cmp.Diff(types.StringNull(), uninitializedValue); diff != "" {
		t.Fatalf("uninitialized NullableString converted unexpectedly (-want +got):\n%s", diff)
	}
	if diff := cmp.Diff(uninitializedValue, setNilValue); diff != "" {
		t.Fatalf("uninitialized and nil NullableString conversions differ (-uninitialized +nil):\n%s", diff)
	}
}

Comment on lines +1512 to +1517
var monthlyLimitBytes types.Int64
if distribution.Config.MonthlyLimitBytes.IsSet() {
monthlyLimitBytes = types.Int64PointerValue(distribution.Config.MonthlyLimitBytes.Get())
} else {
monthlyLimitBytes = types.Int64Null()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Comment on lines +710 to +722
var defaultCacheDuration types.String
if distribution.Config.DefaultCacheDuration.IsSet() {
defaultCacheDuration = types.StringPointerValue(distribution.Config.DefaultCacheDuration.Get())
} else {
defaultCacheDuration = types.StringNull()
}

var monthlyLimitBytes types.Int64
if distribution.Config.MonthlyLimitBytes.IsSet() {
monthlyLimitBytes = types.Int64PointerValue(distribution.Config.MonthlyLimitBytes.Get())
} else {
monthlyLimitBytes = types.Int64Null()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see resource for nitpick suggestion, but these aren't a merge blocker from my side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants