Skip to content

refactor(albwaf): address open issues - #1667

Open
SerseusWasTaken wants to merge 1 commit into
mainfrom
fix/address-open-waf-issues
Open

refactor(albwaf): address open issues#1667
SerseusWasTaken wants to merge 1 commit into
mainfrom
fix/address-open-waf-issues

Conversation

@SerseusWasTaken

@SerseusWasTaken SerseusWasTaken commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

  • Adds warning when name is planned for change for all 3 resources
  • Adds missing fields of example
  • Fixes missing destroy function for max and min acc tests
  • Fix resource test names

relates to STACKITTPR-792

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)

@SerseusWasTaken
SerseusWasTaken requested a review from a team as a code owner August 6, 2026 13:36
…hanges to other albwaf resources

Relates to STACKITTPR-792
@SerseusWasTaken
SerseusWasTaken force-pushed the fix/address-open-waf-issues branch from b54fa01 to e3d94e9 Compare August 6, 2026 13:37

@cgoetz-inovex cgoetz-inovex 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.

issue mentions:

  • Place Min over Max test
    probably missing from this PR

Comment on lines +353 to 364
if !req.State.Raw.IsNull() {
var stateModel Model
resp.Diagnostics.Append(req.State.Get(ctx, &stateModel)...)
if !resp.Diagnostics.HasError() {
utils.WarnIfNameChanges(stateModel.Name, planModel.Name, "Custom Rule Group", &resp.Diagnostics)
}
}

resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)
if resp.Diagnostics.HasError() {
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.

Not sure if it matters, just some oddity

There's no early return here if line 355 creates an error:

		resp.Diagnostics.Append(req.State.Get(ctx, &stateModel)...)

when this happes we'd still call:

	resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)

Also the last conditional is unnecessary, but it looks like we have this in multiple places.

@SerseusWasTaken SerseusWasTaken Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From my understanding we're appending a list of errors here, so there is no need to necessarily return early here. I'm not sure if that's how it really works but if we skip the early return here, we are able to report the warning and any issues from parsing the planModel in one terraform apply command. If we instead return early, multiple "round trips" might be needed for that, no?

)
}
if !resp.Diagnostics.HasError() {
utils.WarnIfNameChanges(stateModel.Name, planModel.Name, "Managed Rule Set", &resp.Diagnostics)

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 conditional logic as one file above

albwafUtils.WarnIfNameChanges(stateModel.Name, planModel.Name, "WAF Configuration", &resp.Diagnostics)
}
}

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 +765 to +771
resp, err := client.DefaultAPI.ListWAF(ctx, testutil.ProjectId, testutil.Region).Execute()
if err != nil {
return fmt.Errorf("getting resp: %w", err)
}

for _, item := range resp.Items {
if utils.Contains(wafConfigurationToDestroy, item.GetName()) {

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.

https://docs.api.stackit.cloud/documentation/alb-waf/version/v1#tag/WAF/operation/WAFService_ListWAF

Looks like ListWAF uses pagination, docs don't mention a default pageSize. Is it enough to return all WAFs created in our acceptance tests?

Comment on lines +760 to +761
// waf configuration transform id: "[projectId],[region],[name]"
name := strings.Split(rs.Primary.ID, core.Separator)[2]

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.

Sometimes I get an index out of bound panic on lines like these when running acceptance tests because rs.Primary.ID == "".
Id add an if here to prevent dangling resources.

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