Skip to content

feat(waf): Onboard Managed Rule Set#1594

Open
Manuelvaas wants to merge 6 commits into
mainfrom
feature/waf-onboard-managed-rule-set
Open

feat(waf): Onboard Managed Rule Set#1594
Manuelvaas wants to merge 6 commits into
mainfrom
feature/waf-onboard-managed-rule-set

Conversation

@Manuelvaas

@Manuelvaas Manuelvaas commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Description

relates to STACKITTPR-716

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)

@Manuelvaas
Manuelvaas requested a review from a team as a code owner July 17, 2026 08:29
@Manuelvaas
Manuelvaas force-pushed the feature/waf-onboard-managed-rule-set branch from 754f80e to 2cb3a8e Compare July 17, 2026 08:39
@github-actions

Copy link
Copy Markdown

Merging this branch changes the coverage (1 decrease, 2 increase)

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/terraform-provider-stackit/stackit 1.17% (-0.01%) 👎
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core 21.62% (ø)
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/albwaf 0.00% (ø)
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/albwaf/managed_rule_set 9.31% (+9.31%) 👍
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/albwaf/utils 75.00% (+75.00%) 🌟
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil 39.83% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core/core.go 21.62% (ø) 37 8 29
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/albwaf/managed_rule_set/datasource.go 0.00% (ø) 42 (+42) 0 42 (+42)
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/albwaf/managed_rule_set/resource.go 11.73% (+11.73%) 162 (+162) 19 (+19) 143 (+143) 🎉
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/albwaf/utils/util.go 75.00% (+75.00%) 8 (+8) 6 (+6) 2 (+2) 🌟
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil/testutil.go 51.09% (ø) 92 47 45
github.com/stackitcloud/terraform-provider-stackit/stackit/provider.go 1.17% (-0.01%) 171 (+2) 2 169 (+2) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/albwaf/albwaf_acc_test.go
  • github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/albwaf/managed_rule_set/resource_test.go
  • github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/albwaf/utils/util_test.go

@SerseusWasTaken SerseusWasTaken left a comment

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.

The acc test fails for me with:

TF_ACC=1 go test -timeout=20m -v stackit/internal/services/albwaf/albwaf_acc_test.go 
=== RUN   TestAccManagedRuleSet
    albwaf_acc_test.go:43: Step 1/4 error: Check failed: Check 2/5 error: stackit_alb_waf_managed_rule_set.managed_rule_set: Attribute 'region' expected "EU01", got "eu01"
    panic.go:694: Error running post-test destroy, there may be dangling resources: getting resp: 400 Bad Request, status code 400, Body: {"code":3,"message":"one or more fields are invalid","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest.FieldViolation","field":"region","description":"Expected region t
o be \"eu01\", but got \"EU01\"."}]}
--- FAIL: TestAccManagedRuleSet (1.44s)
FAIL
FAIL    command-line-arguments  2.171s
FAIL

But i know some other tests don't run for me but which do for others, so maybe this is some weird issue with my machine again 🤔

Comment on lines +164 to +167
if errors.As(err, &oapiErr) && oapiErr.StatusCode == http.StatusNotFound {
resp.State.RemoveResource(ctx)
return
}

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.

We should add a explicit error message here that the resource was not found, otherwise we get a This is a bug in the provider, which should be reported in the provider's own issue tracker. message which is not the case

}

func (r *managedRuleSetResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{

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.

It looks like the datasource and resource have the same schema, so we could define a map which defines all descriptions of the field once and use it in both files, like the git instance does for example. What do you think?

Comment on lines +304 to +307
if createResp.Name == nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating ALB WAF Managed Rule Set", "Got empty Managed Rule Set name")
return
}

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.

Are we under the assumption here that no rule set was actually created when we get a empty name as a response? Since it might be that we actually do create a resource but return an error here nonetheless.

Comment thread stackit/internal/services/albwaf/managed_rule_set/resource.go
Comment thread stackit/internal/services/albwaf/managed_rule_set/resource.go
Comment thread go.mod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants