Release 1.x.x is a breaking-change release. This means that some ways of working / names and conventions have changed and are not backwards compatible with 0.x.x releases.
Below is a summary of the key breaking changes with information on how you can update your Terraform HCL to work with 1.x.x releases.
Prior to 1.0.0 of this provider, the consumer of this provider had to manage both a proxy repository and a capability in order to configure the Sonatype Repository Firewall for that proxy repository. This was only possible when running Sonatype Nexus Repository 3.84.0 or newer.
This was not ideal for two reasons:
- You could configure Sonatype Repository Firewall for a proxy repository without Sonatype Nexus Repository being connected to a valid Sonatype IQ Server - hence it wouldn't actually function
- The delcarative configuration required for Terraform did not shield users from the internal requirements sufficiently
Since 1.0.0 - configuration of Sonatype Repository Firewall is now handled within the sonatyperepo_repository_*_proxy resources themselves and there is no requirement to manage a separate capability resource. The sonatyperepo_capability_firewall_audit_and_quarantine resource has been deprecated.
Additionally - it is now required that a valid Sonatype IQ Connection is configured PRIOR to managing repository resources with Sonatype Repository Firewall configuration - use the sonatyperepo_system_iq_connection resource to ensure this is configured.
Example Terraform prior to 1.0.0:
resource "sonatyperepo_repository_npm_proxy" "example" {
name = "npm-proxy"
online = true
storage = {
blob_store_name = "default"
strict_content_type_validation = true
}
proxy = {
remote_url = "https://npm.server.tld"
content_max_age = 1440
metadata_max_age = 1440
}
negative_cache = {
enabled = true
time_to_live = 1440
}
http_client = {
blocked = false
auto_block = true
}
# This config related to Repository Firewall too!
npm = {
remove_quarrantined = true
}
}
resource "sonatyperepo_capability_firewall_audit_and_quarantine" "example" {
notes = "These are notes from Terraform"
enabled = true
properties = {
repository = sonatyperepo_repository_npm_proxy.example.name
quarantine = true
}
}The equivalent in 1.0.0+ is now:
resource "sonatyperepo_repository_npm_proxy" "example" {
name = "npm-proxy"
online = true
storage = {
blob_store_name = "default"
strict_content_type_validation = true
}
proxy = {
remote_url = "https://npm.server.tld"
content_max_age = 1440
metadata_max_age = 1440
}
negative_cache = {
enabled = true
time_to_live = 1440
}
http_client = {
blocked = false
auto_block = true
}
repository_firewall = {
enabled = true
quarantine = true
pccs_enabled = true # This replaces the `remove_quarrantined` property
}
}Not all proxy repository formats support Sonatype Repository Firewall or Policy-Compliant Component Selection (PCCS) - see this provider's documentation for more details.
Sonatype Nexus Repository 3.84.0 or newer is still required.
The following resources have been renamed to improve consistency.
- Resource
sonatyperepo_repository_maven_grouphas been renamed tosonatyperepo_repository_maven2_group - Resource
sonatyperepo_repository_maven_hostedhas been renamed tosonatyperepo_repository_maven2_hosted - Resource
sonatyperepo_repository_maven_proxyhas been renamed tosonatyperepo_repository_maven2_proxy - Resource
sonatyperepo_repository_ruby_gems_grouphas been renamed tosonatyperepo_repository_rubygems_group - Resource
sonatyperepo_repository_ruby_gems_hostedhas been renamed tosonatyperepo_repository_rubygems_hosted - Resource
sonatyperepo_repository_ruby_gems_proxyhas been renamed tosonatyperepo_repository_rubygems_proxy
You have two options for handling these resource renames:
The old resource names are maintained as deprecated aliases for backward compatibility. Your existing Terraform configurations will continue to work without any changes. However, we recommend migrating to the new names (Option 2) as the deprecated names will be removed in a future major version.
To migrate your existing resources to the new names, use Terraform's moved blocks.
Prerequisites:
- Terraform 1.8 or later (required for
movedblocks) - Provider version v1.0.1 or later
Complete Resource Name Mapping:
| Old Name (Deprecated) | New Name |
|---|---|
sonatyperepo_repository_maven_group |
sonatyperepo_repository_maven2_group |
sonatyperepo_repository_maven_hosted |
sonatyperepo_repository_maven2_hosted |
sonatyperepo_repository_maven_proxy |
sonatyperepo_repository_maven2_proxy |
sonatyperepo_repository_ruby_gems_group |
sonatyperepo_repository_rubygems_group |
sonatyperepo_repository_ruby_gems_hosted |
sonatyperepo_repository_rubygems_hosted |
sonatyperepo_repository_ruby_gems_proxy |
sonatyperepo_repository_rubygems_proxy |
Step-by-Step Migration Process:
Example: Migrating a Maven Hosted Repository
-
Current Configuration (before migration):
resource "sonatyperepo_repository_maven_hosted" "my_repo" { name = "my-maven-repo" online = true storage = { blob_store_name = "default" strict_content_type_validation = true write_policy = "ALLOW" } }
-
Update Resource Type - Change the resource type to the new name:
resource "sonatyperepo_repository_maven2_hosted" "my_repo" { name = "my-maven-repo" online = true storage = { blob_store_name = "default" strict_content_type_validation = true write_policy = "ALLOW" } }
-
Add
movedBlock - Add this block to inform Terraform about the rename:moved { from = sonatyperepo_repository_maven_hosted.my_repo to = sonatyperepo_repository_maven2_hosted.my_repo }
-
Verify Migration - Run
terraform plan:terraform plan
You should see output similar to:
# sonatyperepo_repository_maven_hosted.my_repo has moved to sonatyperepo_repository_maven2_hosted.my_repo resource "sonatyperepo_repository_maven2_hosted" "my_repo" { name = "my-maven-repo" # ... (no changes) }Important: Terraform should indicate the resource will be moved, not destroyed and recreated. If you see destroy/create operations, do not proceed - review your configuration.
-
Apply Migration - Execute the state migration:
terraform apply
-
Cleanup - After successful migration, remove the
movedblock from your configuration. The block is no longer needed once the state has been migrated.
Example: Migrating Multiple Resources
If you have multiple repositories to migrate:
# Maven resources
resource "sonatyperepo_repository_maven2_hosted" "releases" {
name = "maven-releases"
# ... configuration ...
}
resource "sonatyperepo_repository_maven2_proxy" "central" {
name = "maven-central"
# ... configuration ...
}
# RubyGems resources
resource "sonatyperepo_repository_rubygems_hosted" "gems" {
name = "rubygems-hosted"
# ... configuration ...
}
# Add moved blocks for all renamed resources
moved {
from = sonatyperepo_repository_maven_hosted.releases
to = sonatyperepo_repository_maven2_hosted.releases
}
moved {
from = sonatyperepo_repository_maven_proxy.central
to = sonatyperepo_repository_maven2_proxy.central
}
moved {
from = sonatyperepo_repository_ruby_gems_hosted.gems
to = sonatyperepo_repository_rubygems_hosted.gems
}Troubleshooting:
- Error: "No resource schema found" - Ensure you're using provider version 1.0.0 or later
- Destroy/Create instead of Move - Verify your
movedblock syntax matches the examples above - Terraform version error - Upgrade to Terraform 1.8+ to use
movedblocks - State already migrated - If you see "moved to an address that doesn't exist", the migration may have already completed. Remove the
movedblock and runterraform planagain.
Important Notes:
- State migration is safe - no changes are made to your actual Nexus Repository resources
- The
movedblock only updates Terraform state, not the infrastructure - You can migrate resources incrementally (one at a time) or all at once
- The deprecated resource names will be removed in a future major version (v2.0.0 or later)
- We recommend completing the migration during your next maintenance window
sonatyperepo_capability_firewall_audit_and_quarantine
- Resource
sonatyperepo_repository_apt_hosted:- The
apt_signingblock is now required - The
apt_signing.passphrasefield is now optional
- The
- Resources
sonatyperepo_repository_*_proxy:proxy.content_max_ageis now optional and has a default value (1440)proxy.metadata_max_ageis now optional and has a default value (1440)negative_cache.enabledis now optional and has a default value (true)negative_cache.time_to_liveis now optional and has a default value (1440)
sonatyperepo_repository_cargo_hostedsonatyperepo_repository_cargo_proxysonatyperepo_repository_cocoapods_proxysonatyperepo_repository_conan_hostedsonatyperepo_repository_composer_proxysonatyperepo_repository_conan_proxysonatyperepo_repository_gitlfs_hostedsonatyperepo_repository_r_proxysonatyperepo_repository_r_hosted