Migrating from v1.x to v2.x
This guide will help you migrate your NTC modules from version 1.x to 2.x. The v2 release includes significant improvements and breaking changes that require careful planning.
What's New in v2β
π Major Featuresβ
-
AWS Terraform Provider v6 Support
- Optional
regionattribute on the root module (falls back to provider default) - Single provider configuration for multiple regions
- Simplified provider aliasing
- Optional
-
AWS European Sovereign Cloud (ESC) Compatibility
- Full support for sovereign cloud partitions
- Region-aware resource deployment
- Partition-specific configurations
-
Simplified Module Architecture
- Consolidated module calls (fewer separate modules)
- Reduced complexity in multi-region deployments
- Easier maintenance
π₯ Breaking Changesβ
v2.x includes breaking changes that require updates to your Terraform configurations. You cannot simply change the version number - migration steps are required.
| Change | Impact | Action Required |
|---|---|---|
| AWS Provider v6 | Provider configuration changes | Update required_providers block |
New region attribute | Module configuration | Add region parameter to modules (optional but recommended) |
| Consolidated modules | Module structure changes | Refactor module calls (see module-specific guides) |
| State resource paths | Terraform state | Apply state migrations using moved blocks |
Migration Strategyβ
Option 1: All at Once (Recommended for Small Deployments)β
Upgrade all NTC modules in a single migration window.
Pros:
- β Single migration effort
- β Consistent versioning across all modules
Cons:
- β οΈ Requires more testing upfront
- β οΈ Larger blast radius if issues occur
Option 2: Gradual Migration (Recommended for Large Deployments)β
Upgrade modules one by one over time.
Pros:
- β Lower risk per migration
- β Easier rollback if needed
- β Flexible timeline
Cons:
- β οΈ Mixed v1/v2 environment during transition
- β οΈ May require multiple AWS Provider versions across repositories
Migration Order Recommendationβ
For gradual migration, follow this order to minimize dependencies:
- NTC Parameters
- NTC Organizations + NTC Guardrail Templates
- NTC Account Factory + NTC Account Baseline Templates, NTC Account Lifecycle Templates
- NTC Identity Center
- Security modules (NTC Log Archive, NTC Security Tooling)
- Connectivity modules (NTC VPC, NTC Core Network, NTC IPAM, NTC Route53)
Prerequisitesβ
Before starting the migration:
1. Terraform Version Requirementsβ
terraform {
required_version = "1.11.1" #Β replace with your Terraform/OpenTofu version
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"
}
}
}
2. Backup Your Terraform Stateβ
# For remote state (S3)
aws s3 cp s3://your-bucket/path/to/terraform.tfstate ./terraform.tfstate.backup
# For remote state (Spacelift etc.)
# Create a state version snapshot via UI or API
3. Test Environmentβ
Never migrate production directly. Always test in a non-production environment first.Β
Always read the plan stage carefully and check if any unexpected changes appear.
Recommended testing approach:
- Perform the migration in a test environment or on non-productive accounts.
- Document any issues
- Apply learnings to production migration
Migration Stepsβ
Step 1: Update Provider Configurationβ
- v1.x (Before)
- v2.x (After)
terraform {
required_version = "1.11.1" # replace with your Terraform/OpenTofu version
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "eu-central-1"
}
provider "aws" {
alias = "euc2"
region = "eu-central-2"
}
provider "aws" {
alias = "euc2"
region = "eu-west-1"
}
provider "aws" {
alias = "use1"
region = "us-east-1"
}
terraform {
required_version = "1.11.1" # replace with your Terraform/OpenTofu version
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"
}
}
}
# Default provider region is used as fall back if region input is omitted
provider "aws" {
region = "eu-central-1"
}
# Regional providers still needed for some exceptions
# but modules now handle regions internally
provider "aws" {
alias = "use1"
region = "us-east-1"
}
Step 2: Update Module Versionsβ
Change module source references from v1.x to v2.x:
# Before
module "ntc_organizations" {
source = "github.com/nuvibit-terraform-collection/terraform-aws-ntc-organizations?ref=1.6.0"
# ...
}
# After
module "ntc_organizations" {
source = "github.com/nuvibit-terraform-collection/terraform-aws-ntc-organizations?ref=2.0.0"
# ...
}
Step 3: Add Region Parameter (Optional)β
Most v2 modules accept an optional region parameter. If omitted, the module falls back to the provider's default region:
module "ntc_organizations" {
source = "github.com/nuvibit-terraform-collection/terraform-aws-ntc-organizations?ref=2.0.0"
region = "eu-central-1" # Optional: Explicitly set region (recommended for clarity)
# Existing configuration...
service_access_principals = [...]
organizational_unit_paths = [...]
}
Step 4: Refactor Module Calls (Module-Specific)β
Some modules have structural changes. See module-specific guides:
- NTC Organizations Migration - Significant changes
- More module guides coming soon...
Step 5: Apply State Migrationsβ
Use Terraform's moved blocks to migrate state without recreating resources:
# Example: ntc-organizations state migration
moved {
from = module.ntc_delegated_admins_euc1.aws_organizations_delegated_administrator.example["config.amazonaws.com"]
to = module.ntc_organizations.module.admin_delegations.aws_organizations_delegated_administrator.example["config.amazonaws.com"]
}
See module-specific guides for complete state migration blocks.
Step 6: Plan and Reviewβ
terraform init -upgrade
terraform plan
Review the plan carefully:
- β Expected: Resource moves, in-place updates
- β οΈ Partially Expected: For some refactoring cases resources will get recreated (investigate before applying)
- β Unexpected: Resource deletions (investigate before applying)
Step 7: Apply Changesβ
terraform apply
Monitor the apply output for any errors.
Step 8: Validateβ
After migration:
- β Verify resources are functioning
- β Check AWS Console for resource state
- β Run integration tests (if available)
- β Verify logging and monitoring
Module-Specific Migration Guidesβ
Each module may have unique migration requirements. Select your module:
- NTC Organizations - Consolidated admin delegations & service quotas
- More modules coming soon...
Need Help?β
If you encounter issues during migration:
- π Check the Troubleshooting Guide
- π Review module-specific migration guides
- π¬ Contact NTC Support via your usual channels
- π Search existing issues in module repositories
Next Steps:
- Review Prerequisites in detail
- Start with the NTC Organizations migration guide