Skip to content

feat(iam): datasource to query service-accounts#1256

Merged
cgoetz-inovex merged 3 commits intostackitcloud:mainfrom
h3adex:feat/add-service-accounts-datasource
Mar 2, 2026
Merged

feat(iam): datasource to query service-accounts#1256
cgoetz-inovex merged 3 commits intostackitcloud:mainfrom
h3adex:feat/add-service-accounts-datasource

Conversation

@h3adex
Copy link
Copy Markdown
Contributor

@h3adex h3adex commented Feb 24, 2026

Description

This PR adds a datasource which is able to query service accounts based on email_regex and email_suffix. I also added the option to sort the result ascending, following the implementation of this datasource: https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs/data-sources/image_v2#sort_ascending-1

While adding this datasource I've also adjusted our acceptance tests to the latest format.

Tested with the following code:

data "stackit_service_accounts" "sas" {
  project_id = "xxx"
}

data "stackit_service_accounts" "sas_suffix" {
  project_id   = "xxx"
  email_suffix = "@sa.stackit.cloud"
}

data "stackit_service_accounts" "sas_suffix_asc" {
  project_id     = "xxx"
  email_suffix   = "@sa.stackit.cloud"
  sort_ascending = true
}

data "stackit_service_accounts" "sas_regex" {
  project_id  = "xxx"
  email_regex = ".*@ske\\.sa\\.stackit\\.cloud$"
}

data "stackit_service_accounts" "ske_sa_suffix" {
  project_id   = "xxx"
  email_suffix = "@ske.sa.stackit.cloud"
}

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)
Screenshot 2026-02-24 at 11 03 29
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@h3adex h3adex requested a review from a team as a code owner February 24, 2026 10:12
@h3adex h3adex force-pushed the feat/add-service-accounts-datasource branch from 39ed660 to fe005b0 Compare February 24, 2026 10:15
cgoetz-inovex
cgoetz-inovex previously approved these changes Mar 2, 2026
@h3adex
Copy link
Copy Markdown
Contributor Author

h3adex commented Mar 2, 2026

@cgoetz-inovex I've added a new commit. The commit adds the attribute service-account id to the service account resource/datasources. This is a new id which was not there when we introduced this resource.

I also removed service_account token resource. It was already marked as deprecated. They disabled the API this week.

@h3adex h3adex force-pushed the feat/add-service-accounts-datasource branch from cefbc84 to fe2652e Compare March 2, 2026 14:50
h3adex added 2 commits March 2, 2026 15:51
Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud>
…ount token resource

Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud>
@h3adex h3adex force-pushed the feat/add-service-accounts-datasource branch from fe2652e to cbd217b Compare March 2, 2026 14:51
@cgoetz-inovex cgoetz-inovex merged commit 0cfc05b into stackitcloud:main Mar 2, 2026
3 checks passed
@cgoetz-inovex
Copy link
Copy Markdown
Contributor

@h3adex , merged, thanks for your contribution

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.

3 participants