Skip to content

Conversation

h3adex
Copy link
Contributor

@h3adex h3adex commented Sep 1, 2025

Description

Implements full support for resource and data source for folders (STACKITTPR-213). Both are marked as beta.

Acceptance tests/Docs updated for:

stackit_resourcemanager_project  
stackit_resourcemanager_folder

stackit_resourcemanager_project improvements:

  • Added attributes: created_at, updated_at
  • Removed incorrect service_account_email documentation

Example configuration:

locals {
  org_id = "xxxx"
}

resource "stackit_resourcemanager_folder" "folder01" {
  name                = "test"
  owner_email         = "<your-mail>@stackit.cloud"
  parent_container_id = local.org_id
  labels = {
    "env" = "dev"
  }
}

data "stackit_resourcemanager_folder" "folder01" {
  container_id = stackit_resourcemanager_folder.folder01.container_id
}

# Projects can be added under folders. When deleting a project,
# it may remain invisible for up to 7 days.
# Folder deletion may fail during this period.
/*resource "stackit_resourcemanager_project" "project01" {
  name                = "proj-01-updated"
  owner_email         = "<your-mail>@stackit.cloud"
  parent_container_id = stackit_resourcemanager_folder.folder01.container_id
}*/

E2E test results in the comments.

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)

@h3adex h3adex requested a review from a team as a code owner September 1, 2025 14:01
@h3adex h3adex marked this pull request as draft September 1, 2025 14:01
@h3adex h3adex force-pushed the feat/add-folder-to-resourcemanager branch 6 times, most recently from d3752dd to 8c8b3a8 Compare September 2, 2025 09:52
@h3adex
Copy link
Contributor Author

h3adex commented Sep 2, 2025

E2E Run

STACKIT_SERVICE_ACCOUNT_TOKEN=eyJ
TF_ACC=1
TF_ACC_PROJECT_ID=xxxx-xxxx-xxxx-xxxx
TF_ACC_REGION=eu01
TF_ACC_TEST_PROJECT_PARENT_UUID=xxxx-xxxx-xxxx-xxxx
TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID=test-company
[email protected]
Screenshot 2025-09-02 at 11 49 10

@h3adex h3adex force-pushed the feat/add-folder-to-resourcemanager branch 3 times, most recently from 218b2d7 to 6f7a5bf Compare September 2, 2025 10:17
@h3adex h3adex marked this pull request as ready for review September 2, 2025 10:21
@h3adex h3adex force-pushed the feat/add-folder-to-resourcemanager branch from 6f7a5bf to 4ce777f Compare September 2, 2025 10:33
@h3adex h3adex force-pushed the feat/add-folder-to-resourcemanager branch from 4ce777f to 6d3c81f Compare September 3, 2025 09:04
@h3adex h3adex force-pushed the feat/add-folder-to-resourcemanager branch from 6d3c81f to 00b74ca Compare September 4, 2025 11:39
@h3adex h3adex requested a review from rubenhoenle September 4, 2025 11:40
@h3adex h3adex force-pushed the feat/add-folder-to-resourcemanager branch from 00b74ca to 0def103 Compare September 11, 2025 08:20
@h3adex h3adex force-pushed the feat/add-folder-to-resourcemanager branch from 3393dc8 to fe258cf Compare September 12, 2025 09:23
name = "example-project"
owner_email = "[email protected]"
parent_container_id = stackit_resourcemanager_folder.example.container_id
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add an example, how to import a folder like we have it for other resources:

# Only use the import statement, if you want to import an existing resourcemanager project
# Note: There will be a conflict which needs to be resolved manually.
# Must set a configuration value for the owner_email attribute as the provider has marked it as required.
import {
to = stackit_resourcemanager_project.import-example
id = var.container_id
}

Comment on lines +26 to +27
var (
_ datasource.DataSource = &folderDataSource{}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick. to ensure the Configure method is always implemented and not changed accidentally

Suggested change
var (
_ datasource.DataSource = &folderDataSource{}
var (
_ datasource.DataSource = &folderDataSource{}
_ datasource.DataSourceWithConfigure = &folderDataSource{}

Copy link
Contributor

Choose a reason for hiding this comment

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

ctx,
&resp.Diagnostics,
"Error deleting folder. Deletion may fail because associated projects remain hidden for up to 7 days after user deletion due to technical requirements.",
fmt.Sprintf("API call failed: %v", err),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fmt.Sprintf("API call failed: %v", err),
fmt.Sprintf("Calling API: %v", err),

Comment on lines +429 to +437
// mapFolderCreateFields maps the Create Folder API response to the Terraform model and update the Terraform state
func mapFolderCreateFields(ctx context.Context, resp *resourcemanager.FolderResponse, model *Model, state *tfsdk.State) error {
return mapFolderFields(ctx, resp.ContainerId, resp.Name, resp.FolderId, resp.Labels, resp.Parent, resp.CreationTime, resp.UpdateTime, model, state)
}

// mapFolderDetailsFields maps the GetDetails API response to the Terraform model and update the Terraform state
func mapFolderDetailsFields(ctx context.Context, resp *resourcemanager.GetFolderDetailsResponse, model *Model, state *tfsdk.State) error {
return mapFolderFields(ctx, resp.ContainerId, resp.Name, resp.FolderId, resp.Labels, resp.Parent, resp.CreationTime, resp.UpdateTime, model, state)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be probably better readable when using just one map function. For this you just need to add an additional GET call in the Create method and use the response of it for the map function instead of passing each attribute separate

`, testutil.ResourceManagerProviderConfig(), resourceProject),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.stackit_resourcemanager_project.example", "name", testutil.ConvertConfigVariable(testConfigResourceProjectParentContainerId["name"])),
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_project.example", "parent_container_id"),
Copy link
Contributor

Choose a reason for hiding this comment

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

You can check here, if the parent_container_id has the correct value

Suggested change
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_project.example", "parent_container_id"),
resource.TestCheckResourceAttr("data.stackit_resourcemanager_project.example", "parent_container_id", testutil.ConvertConfigVariable(testConfigResourceProjectParentContainerId["parent_container_id"])),

Comment on lines +145 to +146
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_project.example", "container_id"),
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_project.example", "project_id"),
Copy link
Contributor

Choose a reason for hiding this comment

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

And here, if it has the same values like the resource

Suggested change
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_project.example", "container_id"),
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_project.example", "project_id"),
resource.TestCheckResourceAttrPair(
"data.stackit_resourcemanager_project.example", "container_id",
"stackit_resourcemanager_project.example", "container_id",
),
resource.TestCheckResourceAttrPair(
"data.stackit_resourcemanager_project.example", "project_id",
"stackit_resourcemanager_project.example", "project_id",
),

Comment on lines +226 to +228
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_project.example", "parent_container_id"),
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_project.example", "container_id"),
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_project.example", "project_id"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Comment on lines +305 to +307
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_folder.example", "parent_container_id"),
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_folder.example", "folder_id"),
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_folder.example", "container_id"),
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Comment on lines +384 to +386
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_folder.example", "parent_container_id"),
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_folder.example", "folder_id"),
resource.TestCheckResourceAttrSet("data.stackit_resourcemanager_folder.example", "container_id"),
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

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