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. | + diff --git a/nullplatform/scope_configuration/main.tf b/nullplatform/scope_configuration/main.tf new file mode 100644 index 00000000..626cb2af --- /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_slug + 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..fce96c34 --- /dev/null +++ b/nullplatform/scope_configuration/provider.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + nullplatform = { + source = "nullplatform/nullplatform" + version = "~> 0.0.67" + } + } +} diff --git a/nullplatform/scope_configuration/variables.tf b/nullplatform/scope_configuration/variables.tf new file mode 100644 index 00000000..e9669208 --- /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_slug" { + description = "Slug 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 = {} +}