Skip to content

feat: Support Federated Identity Providers for service accounts#1314

Open
JorTurFer wants to merge 5 commits intostackitcloud:mainfrom
JorTurFer:support-wif-resources
Open

feat: Support Federated Identity Providers for service accounts#1314
JorTurFer wants to merge 5 commits intostackitcloud:mainfrom
JorTurFer:support-wif-resources

Conversation

@JorTurFer
Copy link
Copy Markdown
Contributor

@JorTurFer JorTurFer commented Mar 19, 2026

Description

As STACKIT supports workload identity federation via public API, this PR supports it as part of terraform

Checklist

  • 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)

@JorTurFer JorTurFer requested a review from a team as a code owner March 19, 2026 19:27
@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 Mar 28, 2026
@JorTurFer
Copy link
Copy Markdown
Contributor Author

not stale

@github-actions github-actions Bot removed the Stale PR is marked as stale due to inactivity. label Mar 29, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

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 Apr 7, 2026
@github-actions
Copy link
Copy Markdown

This PR was closed automatically because it has been stalled for 7 days with no activity. Feel free to re-open it at any time.

@github-actions github-actions Bot closed this Apr 14, 2026
@marceljk marceljk reopened this Apr 20, 2026
@marceljk marceljk removed the Stale PR is marked as stale due to inactivity. label Apr 20, 2026
@JorTurFer JorTurFer force-pushed the support-wif-resources branch from 21cf3d1 to a6c7488 Compare April 21, 2026 15:52
Copy link
Copy Markdown
Contributor

@Fyusel Fyusel left a comment

Choose a reason for hiding this comment

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

Hi @JorTurFer,
had a first look 👍
What about a datasource?

Comment thread stackit/internal/services/serviceaccount/federated_identity_provider/resource.go Outdated
Comment thread stackit/internal/services/serviceaccount/federated_identity_provider/resource.go Outdated
Comment thread stackit/internal/services/serviceaccount/federated_identity_provider/resource.go Outdated
Comment thread stackit/internal/services/serviceaccount/federated_identity_provider/resource.go Outdated
Comment thread stackit/internal/services/serviceaccount/federated_identity_provider/resource.go Outdated
Comment thread stackit/internal/services/serviceaccount/federated_identity_provider/model.go Outdated
}

func (r *ServiceAccountFederatedIdentityProviderResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
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.

As far as I can see this function does not return a good error message what IDs(attributes) are needed.

E.g. looking at the other resources we have something like this:

idParts := strings.Split(req.ID, core.Separator)
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
	core.LogAndAddError(ctx, &resp.Diagnostics,
		"Error importing image",
		fmt.Sprintf("Expected import identifier with format: [project_id],[region],[image_id]  Got: %q", req.ID),
	)
	return
}

ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
	"project_id": idParts[0],
	"region":     idParts[1],
	"image_id":   idParts[2],
})

tflog.Info(ctx, "Image state imported")

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.

@JorTurFer This is still open

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.

I missed this, sorry. Now it's fixed

@JorTurFer JorTurFer force-pushed the support-wif-resources branch from fb599f0 to da42473 Compare April 28, 2026 14:50
Signed-off-by: Jorge Turrado <jorge.turrado@digits.schwarz>
@JorTurFer JorTurFer force-pushed the support-wif-resources branch from 9c7715f to be7d426 Compare April 28, 2026 19:05
Signed-off-by: Jorge Turrado <jorge.turrado@digits.schwarz>
@JorTurFer
Copy link
Copy Markdown
Contributor Author

What about a datasource?

As this is something that we are waiting for integrations, I'd prefer to not depend on the datasource. I'm willing to open a follow up PR adding the datasource but I'm not sure it makes sense as it's not unique, so a customer can just create another one and eventually delete the duplicated, but as I said, if you think that it's useful, it's fine for me and I'm willing to create it in another PR or as part of this if they must be added at same time

Comment thread stackit/internal/services/serviceaccount/federated_identity_provider/resource.go Outdated
},
},
},
Required: true,
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.

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.

it is required indeed, there is a validation on backend that rejects the request if there isn't any assertion and also if there isn't any assertion for aud in specific.

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.

Ok, can you update the API doc as well, please

Comment thread stackit/internal/services/serviceaccount/federated_identity_provider/resource.go Outdated
Signed-off-by: Jorge Turrado <jorge.turrado@digits.schwarz>
serviceAccountEmail := model.ServiceAccountEmail.ValueString()
federationId := model.FederationId.ValueString()

apiResp, err := r.client.DefaultAPI.ListFederatedIdentityProviders(ctx, projectId, serviceAccountEmail).
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 need a GET endpoint here. Then the filtering below can be removed.

Additionally a datasource for thsi GET endpoint can be implemented.
A datasource for the list endpoint is not needed right now since we need to check how a good approach looks like for pagination.

Jorge Turrado added 2 commits April 29, 2026 11:02
Signed-off-by: Jorge Turrado <jorge.turrado@digits.schwarz>
Signed-off-by: Jorge Turrado <jorge.turrado@digits.schwarz>
Copy link
Copy Markdown
Contributor

@Fyusel Fyusel left a comment

Choose a reason for hiding this comment

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

To summarize:

  • GET endpoint is needed (Read() in resource needs to be updated)
  • datasource for GET endpoint is needed
  • datasource for LIST is not needed

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.

3 participants