Skip to content

Allow to specify project_id at the provider{} levelΒ #885

@crisbal

Description

@crisbal

Problem description

At the moment it feels somewhat repetitive to always have to specify the project_id variable on each resource. Repetition can be decreased by using a variable, but still you have to remember to include the variable every time, it does not feel very DRY to me.

It would be nice to allow to specify a default project_id at the provider level, so that project_id is only specified once and will be applied for all resources using that provider, similar to default_region.

Proposed solution

provider "stackit" {
  default_region        = "eu01"
  default_project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  enable_beta_resources = true
}

To me it seems like a sort of straight forward implementation (not "complex" but "time consuming"), add DefaultProjectId here and here and in some other places. Add similar code to GetRegion and GetRegionWithOverride and use it in every resource which needs a project_id, similar to region. Also need to update every resource to handle this (which might be the most time consuming part I am afraid)

I have not checked the code in detail yet, so forgive me if I have under-estimated this.

Alternative solutions

Keep the situation the same as right now, for which project_id is repeated in each resource

resource "stackit_network" "example" {
  project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # repeated for every resource
  name       = "example"
}

Additional information

  • Is my suggestion an antipattern or a bad idea in general?
  • Is there any resource for which a project_id variable is not required so it should be handled differently?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions