diff --git a/lambda/specs/install/backend.tf b/lambda/specs/install/backend.tf new file mode 100644 index 0000000..7330a13 --- /dev/null +++ b/lambda/specs/install/backend.tf @@ -0,0 +1,5 @@ +terraform { + backend "s3" { + key = "lambda/install/terraform.tfstate" + } +} diff --git a/lambda/specs/install/main.tf b/lambda/specs/install/main.tf new file mode 100644 index 0000000..fa37e92 --- /dev/null +++ b/lambda/specs/install/main.tf @@ -0,0 +1,77 @@ +################################################################################ +# Scope Definition +# Registers the service specification, scope type, and action specs in nullplatform. +################################################################################ + +module "scope_definition" { + source = "git::https://github.com/nullplatform/tofu-modules.git//nullplatform/scope_definition?ref=v6.19.1" + + nrn = var.nrn + np_api_key = var.np_api_key + + service_path = var.service_path + + repository_service_spec = var.github_raw_url + repository_service_spec_branch = var.github_branch + repository_scope_template = var.github_raw_url + repository_scope_template_branch = var.github_branch + repository_action_templates = var.github_raw_url + repository_action_templates_branch = var.github_branch + + repo_path = var.repo_path + + service_spec_name = var.service_spec_name + service_spec_description = var.service_spec_description + + action_spec_names = [ + "adjust-provisioned-concurrency", + "adjust-reserved-concurrency", + "create-scope", + "delete-deployment", + "delete-scope", + "diagnose-deployment", + "diagnose-scope", + "finalize-blue-green", + "invoke", + "rollback-deployment", + "start-blue-green", + "start-initial", + "switch-traffic", + "update-scope", + ] + + external_metrics_provider = var.external_metrics_provider + external_logging_provider = var.external_logging_provider + + create_scope_configuration = true +} + +################################################################################ +# Scope Definition Agent Association +# Creates the notification channel that connects nullplatform events to the agent. +################################################################################ + +module "scope_definition_agent_association" { + source = "git::https://github.com/nullplatform/tofu-modules.git//nullplatform/scope_definition_agent_association?ref=v6.19.1" + + nrn = var.nrn + api_key = var.np_api_key + + # description = "Notification channel for AWS Lambda scope definition" + + scope_specification_id = module.scope_definition.service_specification_id + scope_specification_slug = module.scope_definition.service_slug + + service_path = var.service_path + + repository_notification_channel = var.github_raw_url + repository_notification_channel_branch = var.github_branch + + repo_path = var.repo_path + + tags_selectors = var.tags_selectors + + enabled_override = var.overrides_enabled + override_repo_path = var.overrides_repo_path + overrides_service_path = var.overrides_service_path +} diff --git a/lambda/specs/install/provider.tf b/lambda/specs/install/provider.tf new file mode 100644 index 0000000..ef613db --- /dev/null +++ b/lambda/specs/install/provider.tf @@ -0,0 +1,24 @@ +terraform { + required_providers { + nullplatform = { + source = "nullplatform/nullplatform" + version = "0.0.87, < 0.1.0" + } + http = { + source = "hashicorp/http" + version = "~> 3.0" + } + external = { + source = "hashicorp/external" + version = "~> 2.3" + } + null = { + source = "hashicorp/null" + version = "~> 3.2" + } + } +} + +provider "nullplatform" { + api_key = var.np_api_key +} diff --git a/lambda/specs/install/terraform.tfvars.example b/lambda/specs/install/terraform.tfvars.example new file mode 100644 index 0000000..b5951da --- /dev/null +++ b/lambda/specs/install/terraform.tfvars.example @@ -0,0 +1,42 @@ +# Copy this file to terraform.tfvars and fill in the values. +# terraform.tfvars is gitignored — never commit secrets. + +################################################################################ +# Required +################################################################################ + +nrn = "organization:account" +np_api_key = "your-nullplatform-api-key" + +tags_selectors = { + environment = "production" +} + +################################################################################ +# Repository (override if using a fork or private mirror) +################################################################################ + +# github_raw_url = "https://raw.githubusercontent.com/nullplatform/scopes-lambda/refs/heads" +# github_branch = "main" + +################################################################################ +# Agent +################################################################################ + +# repo_path = "/root/.np/nullplatform/scopes-lambda" + +################################################################################ +# Scope Definition (override to customize the display name) +################################################################################ + +# service_spec_name = "AWS Lambda" +# service_spec_description = "AWS Lambda functions managed by nullplatform" +# service_path = "lambda" + +################################################################################ +# Overrides (optional — appends --overrides-path to the agent cmdline) +################################################################################ + +# overrides_enabled = true +# overrides_repo_path = "/root/.np/nullplatform/scopes-networking" +# overrides_service_path = "/lambda" diff --git a/lambda/specs/install/variables.tf b/lambda/specs/install/variables.tf new file mode 100644 index 0000000..0a1c9ba --- /dev/null +++ b/lambda/specs/install/variables.tf @@ -0,0 +1,97 @@ +################################################################################ +# Required +################################################################################ + +variable "nrn" { + description = "Nullplatform Resource Name (organization:account format)" + type = string +} + +variable "np_api_key" { + description = "Nullplatform API key for authentication" + type = string + sensitive = true +} + +variable "tags_selectors" { + description = "Map of tags used to select the agent that will handle this scope's notification channel" + type = map(string) +} + +################################################################################ +# Repository +################################################################################ + +variable "github_raw_url" { + description = "Base URL for fetching raw files from GitHub (without trailing slash)" + type = string + default = "https://raw.githubusercontent.com/nullplatform/scopes-lambda/refs/heads" +} + +variable "github_branch" { + description = "Git branch to use when fetching spec templates" + type = string + default = "main" +} + +variable "repo_path" { + description = "Local path where the scopes-lambda repository is cloned on the agent" + type = string + default = "/root/.np/nullplatform/scopes-lambda" +} + +################################################################################ +# Scope Definition +################################################################################ + +variable "service_spec_name" { + description = "Display name for the scope type in nullplatform" + type = string + default = "AWS Lambda" +} + +variable "service_spec_description" { + description = "Description of the scope type" + type = string + default = "AWS Lambda functions managed by nullplatform" +} + +variable "external_metrics_provider" { + description = "Name of the external metrics provider" + type = string + default = "externalmetrics" +} + +variable "external_logging_provider" { + description = "Name of the external logging provider" + type = string + default = "external" +} + +variable "service_path" { + description = "Path to the spec definition" + type = string + default = "lambda" +} + +################################################################################ +# Overrides +################################################################################ + +variable "overrides_enabled" { + description = "Append --overrides-path to the agent cmdline for local config overrides" + type = bool + default = false +} + +variable "overrides_repo_path" { + description = "Base path of the overrides repository on the agent (e.g. /root/.np/nullplatform/scopes-networking)" + type = string + default = null +} + +variable "overrides_service_path" { + description = "Service subfolder within the overrides repository (e.g. /lambda)" + type = string + default = null +}