From 81d4994e78047556a119201bfd621cafa10b599d Mon Sep 17 00:00:00 2001 From: Agustin Celentano <12614595+agustincelentano@users.noreply.github.com> Date: Mon, 30 Mar 2026 12:33:54 -0300 Subject: [PATCH 1/4] feature: add scope_configuration module for provider config resources --- nullplatform/scope_configuration/main.tf | 10 +++++++ nullplatform/scope_configuration/outputs.tf | 4 +++ nullplatform/scope_configuration/provider.tf | 12 +++++++++ nullplatform/scope_configuration/variables.tf | 26 +++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 nullplatform/scope_configuration/main.tf create mode 100644 nullplatform/scope_configuration/outputs.tf create mode 100644 nullplatform/scope_configuration/provider.tf create mode 100644 nullplatform/scope_configuration/variables.tf diff --git a/nullplatform/scope_configuration/main.tf b/nullplatform/scope_configuration/main.tf new file mode 100644 index 00000000..9b02ac43 --- /dev/null +++ b/nullplatform/scope_configuration/main.tf @@ -0,0 +1,10 @@ +resource "nullplatform_provider_config" "scope_configuration" { + nrn = var.nrn + type = var.provider_specification_id + dimensions = var.dimensions + attributes = jsonencode(var.attributes) + + lifecycle { + ignore_changes = [attributes] + } +} diff --git a/nullplatform/scope_configuration/outputs.tf b/nullplatform/scope_configuration/outputs.tf new file mode 100644 index 00000000..23db1eb9 --- /dev/null +++ b/nullplatform/scope_configuration/outputs.tf @@ -0,0 +1,4 @@ +output "provider_config_id" { + description = "ID of the created provider config." + value = nullplatform_provider_config.scope_configuration.id +} diff --git a/nullplatform/scope_configuration/provider.tf b/nullplatform/scope_configuration/provider.tf new file mode 100644 index 00000000..258047e2 --- /dev/null +++ b/nullplatform/scope_configuration/provider.tf @@ -0,0 +1,12 @@ +terraform { + required_providers { + nullplatform = { + source = "nullplatform/nullplatform" + version = "~> 0.0.67" + } + } +} +provider "nullplatform" { + + api_key = var.np_api_key +} diff --git a/nullplatform/scope_configuration/variables.tf b/nullplatform/scope_configuration/variables.tf new file mode 100644 index 00000000..6c2fafb0 --- /dev/null +++ b/nullplatform/scope_configuration/variables.tf @@ -0,0 +1,26 @@ +variable "np_api_key" { + description = "Nullplatform API key for authentication." + type = string + sensitive = true +} + +variable "nrn" { + description = "Nullplatform Resource Name (NRN) — unique identifier for the target resource." + type = string +} + +variable "provider_specification_id" { + description = "ID of the provider specification (scope configuration type) to associate with." + type = string +} + +variable "attributes" { + description = "Configuration attributes matching the provider specification schema." + type = any +} + +variable "dimensions" { + description = "Dimension values for this configuration." + type = map(string) + default = {} +} From 6c1e8389badd846c46ce096c1e30699f7b177539 Mon Sep 17 00:00:00 2001 From: Agustin Celentano <12614595+agustincelentano@users.noreply.github.com> Date: Mon, 30 Mar 2026 12:49:32 -0300 Subject: [PATCH 2/4] fix: use provider_specification_slug instead of id for type field --- nullplatform/scope_configuration/main.tf | 2 +- nullplatform/scope_configuration/variables.tf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nullplatform/scope_configuration/main.tf b/nullplatform/scope_configuration/main.tf index 9b02ac43..626cb2af 100644 --- a/nullplatform/scope_configuration/main.tf +++ b/nullplatform/scope_configuration/main.tf @@ -1,6 +1,6 @@ resource "nullplatform_provider_config" "scope_configuration" { nrn = var.nrn - type = var.provider_specification_id + type = var.provider_specification_slug dimensions = var.dimensions attributes = jsonencode(var.attributes) diff --git a/nullplatform/scope_configuration/variables.tf b/nullplatform/scope_configuration/variables.tf index 6c2fafb0..e9669208 100644 --- a/nullplatform/scope_configuration/variables.tf +++ b/nullplatform/scope_configuration/variables.tf @@ -9,8 +9,8 @@ variable "nrn" { type = string } -variable "provider_specification_id" { - description = "ID of the provider specification (scope configuration type) to associate with." +variable "provider_specification_slug" { + description = "Slug of the provider specification (scope configuration type) to associate with." type = string } From b5745a8f34cec2aed40bf3b8ecaac0af65feb031 Mon Sep 17 00:00:00 2001 From: Agustin Celentano <12614595+agustincelentano@users.noreply.github.com> Date: Mon, 30 Mar 2026 15:00:00 -0300 Subject: [PATCH 3/4] docs: add README for scope_configuration module --- nullplatform/scope_configuration/README.md | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 nullplatform/scope_configuration/README.md diff --git a/nullplatform/scope_configuration/README.md b/nullplatform/scope_configuration/README.md new file mode 100644 index 00000000..6bba398a --- /dev/null +++ b/nullplatform/scope_configuration/README.md @@ -0,0 +1,124 @@ +# Module: scope_configuration + +## Description + +Creates a Nullplatform provider configuration for a scope definition, linking a provider specification (identified by slug) with concrete attribute values such as cloud provider, region, state backend, distribution, and network settings. + +## Architecture + +The module creates a single `nullplatform_provider_config` resource that associates a provider specification (e.g., "static-files") with a target NRN. The `type` field receives the provider specification slug, and `attributes` contains the JSON-encoded configuration values that match the specification's schema. Dimensions can optionally be provided to scope the configuration to specific environments or other dimension values. + +## Features + +- Creates provider configurations for any scope definition that exposes a provider specification +- Supports arbitrary attribute schemas defined by the provider specification +- Optional dimension support for environment-specific configurations +- Uses `ignore_changes` on attributes to prevent drift after initial creation + +## Basic Usage + +```hcl +module "scope_configuration" { + source = "git::https://github.com/nullplatform/tofu-modules.git//nullplatform/scope_configuration?ref=v1.48.3" + + nrn = "organization=123:account=456" + np_api_key = var.np_api_key + provider_specification_slug = module.scope_definition.provider_specification_slug + attributes = { + cloud_provider = "aws" + } +} +``` + +### Usage with AWS Static Files + +```hcl +module "scope_configuration_static_scope" { + source = "git::https://github.com/nullplatform/tofu-modules.git//nullplatform/scope_configuration?ref=v1.48.3" + + nrn = var.nrn + np_api_key = var.np_api_key + provider_specification_slug = module.scope_definition_static_scope.provider_specification_slug + attributes = { + cloud_provider = "aws" + provider = { + aws_region = "us-east-1" + aws_state_bucket = "my-tfstate-bucket" + } + distribution = { + aws_distribution = "cloudfront" + } + network = { + aws_network = "route53" + aws_hosted_public_zone_id = "Z0123456789ABC" + } + } +} +``` + +### Usage with Dimensions + +```hcl +module "scope_configuration" { + source = "git::https://github.com/nullplatform/tofu-modules.git//nullplatform/scope_configuration?ref=v1.48.3" + + nrn = var.nrn + np_api_key = var.np_api_key + provider_specification_slug = module.scope_definition.provider_specification_slug + dimensions = { + environment = "production" + } + attributes = { + cloud_provider = "aws" + provider = { + aws_region = "eu-west-1" + aws_state_bucket = "prod-tfstate-bucket" + } + } +} +``` + +## Using Outputs + +```hcl +# Reference the provider config ID in other resources +resource "example_resource" "this" { + provider_config_id = module.scope_configuration.provider_config_id +} +``` + + +## Requirements + +| Name | Version | +|------|---------| +| [nullplatform](#requirement\_nullplatform) | ~> 0.0.67 | + +## Providers + +| Name | Version | +|------|---------| +| [nullplatform](#provider\_nullplatform) | ~> 0.0.67 | + +## Resources + +| Name | Type | +|------|------| +| [nullplatform_provider_config.scope_configuration](https://registry.terraform.io/providers/nullplatform/nullplatform/latest/docs/resources/provider_config) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [np\_api\_key](#input\_np\_api\_key) | Nullplatform API key for authentication. | `string` | n/a | yes | +| [nrn](#input\_nrn) | Nullplatform Resource Name (NRN) — unique identifier for the target resource. | `string` | n/a | yes | +| [provider\_specification\_slug](#input\_provider\_specification\_slug) | Slug of the provider specification (scope configuration type) to associate with. | `string` | n/a | yes | +| [attributes](#input\_attributes) | Configuration attributes matching the provider specification schema. | `any` | n/a | yes | +| [dimensions](#input\_dimensions) | Dimension values for this configuration. | `map(string)` | `{}` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [provider\_config\_id](#output\_provider\_config\_id) | ID of the created provider config. | + From 241ff4aa7cade971aad840588bb1f0ca2154e54d Mon Sep 17 00:00:00 2001 From: Agustin Celentano <12614595+agustincelentano@users.noreply.github.com> Date: Mon, 30 Mar 2026 15:12:34 -0300 Subject: [PATCH 4/4] refactor: remove explicit provider block, inherit from parent module --- nullplatform/scope_configuration/provider.tf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nullplatform/scope_configuration/provider.tf b/nullplatform/scope_configuration/provider.tf index 258047e2..fce96c34 100644 --- a/nullplatform/scope_configuration/provider.tf +++ b/nullplatform/scope_configuration/provider.tf @@ -6,7 +6,3 @@ terraform { } } } -provider "nullplatform" { - - api_key = var.np_api_key -}