Skip to content

Commit ad6c593

Browse files
akinrosslhercot
authored andcommitted
[ignore] documentation updates
1 parent 6f893e0 commit ad6c593

File tree

1 file changed

+63
-57
lines changed

1 file changed

+63
-57
lines changed

docs/guides/migration.md

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ description: |-
77

88
## Introduction
99

10-
Since its first release in September 2020, the Terraform ACI provider has significantly progressed, adding new resources and data sources to streamline the management of Cisco ACI environments. Over the years, we've transitioned from SDKv1 to [SDKv2](https://developer.hashicorp.com/terraform/plugin/sdkv2), and now to the latest [Terraform Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework). This new Plugin Framework is the recommended way for developing Terraform plugins and offers several advantages over SDKv2.
10+
Since its first release in July 2019, the Terraform ACI provider has significantly progressed, adding new resources and data sources to streamline the management of Cisco ACI environments. Over the years, we've transitioned from SDKv1 to [SDKv2](https://developer.hashicorp.com/terraform/plugin/sdkv2), and now to the latest [Terraform Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework). This new Plugin Framework is the recommended way for developing Terraform plugins and offers several advantages over SDKv2.
1111

12-
In order to fully leverage the new features of the Terraform Plugin Framework, we undertook a complete rewrite of the Terraform ACI provider's resources and data sources. Although this was a significant effort, it presented an opportunity to review and enhance the existing ACI provider. This guide provides detailed steps for migrating from previous versions, outlines key optimization steps to enhance performance, and aims to facilitate a smoother transition for users adapting to these updates. Additionally, it outlines the new features introduced by the Terraform Plugin Framework, along with the modifications we implemented in the ACI provider and the rationale behind these changes.
12+
In order to fully leverage the new features of the Terraform Plugin Framework, we decided to undertake a complete rewrite of the Terraform ACI provider's resources and data sources. Although this is a significant effort, it presented an opportunity to review and enhance the existing ACI provider and how the provider is developed.
13+
14+
This complete rewrite will stretch a series of releases starting with [v2.16.0](https://github.com/CiscoDevNet/terraform-provider-aci/releases/tag/v2.16.0) where all new resources and data sources will be implemented using the new Terraform Plugin Framework and pre-existing resources and data sources will be slowly migrated into the Terraform Plugin Framework. Migrated resources and data sources contain a note that specifies it has been migrated at the top of their documentation. Once all pre-existing resources are migrated to the Terraform Provider Framework, a major release of the provider will be created to remove legacy attributes.
15+
16+
This guide provides detailed steps for migrating from previous versions, outlines key optimization steps to enhance performance, and aims to facilitate a smoother transition for users adapting to these updates. Additionally, it outlines how the migrated resources use the new features introduced by the Terraform Plugin Framework, along with the modifications we implemented in the ACI provider and the rationale behind these changes.
1317

1418
## Upgrading the ACI Terraform Provider
1519

@@ -20,57 +24,59 @@ Upgrading the ACI Terraform provider to a new version requires careful planning
2024
Before making any changes, it's crucial to back up your current Terraform state. This precaution ensures that you can revert your environment to its previous state if any issues arise during the upgrade process.
2125

2226
1. **Local Backend:** Open a terminal and navigate to the directory where your ACI Terraform configuration files with the state are located. Copy the current state file (terraform.tfstate) to a backup location.
23-
24-
```bash
25-
cd /path/to/your/terraform/project
26-
cp terraform.tfstate terraform.tfstate.backup
27-
```
27+
28+
```bash
29+
cd /path/to/your/terraform/project
30+
cp terraform.tfstate /path/to/your/backup/terraform.tfstate.backup
31+
```
2832

2933
2. **Remote Backend:** If you are using a remote backend (e.g., S3, Azure Blob Storage), ensure you have a backup of the state file from the remote location.
3034

3135
### Step 2: Update the Provider Version
3236

33-
1. **Open the Terraform Configuration File:** Open the `main.tf` or the relevant Terraform configuration file where the ACI provider is defined.
37+
The version meta-argument specifies the version constraint for a provider. The version constraint can be specified in the [provider configuration](https://developer.hashicorp.com/terraform/language/providers/configuration) or in the [required_providers block](https://developer.hashicorp.com/terraform/language/providers/requirements). The [version](https://developer.hashicorp.com/terraform/language/providers/configuration#version-deprecated) argument in the provider configuration is deprecated, and will be removed in future Terraform versions.
3438

35-
2. **Update the Provider Version:** We recommend setting [version constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints) for the provider. Modify the provider block to specify the new version constraint for the ACI provider.
39+
1. **Open the Terraform Configuration File:** Open the `main.tf` or the relevant Terraform configuration file where the ACI provider version constraint is defined.
3640

37-
***Version constraint format***
38-
```hcl
39-
terraform {
40-
required_providers {
41-
aci = {
42-
source = "ciscodevnet/aci"
43-
version = "x.y.z" # Replace with the new version number
44-
}
45-
}
46-
}
47-
```
41+
2. **Update the Provider Version:** Terraform recommends setting [version constraints](https://developer.hashicorp.com/terraform/language/expressions/version-constraints) for providers. Modify the terraform.required_providers or provider block to specify the new version constraint for the ACI provider.
4842

49-
***Deprecated Terraform version constraint format***
50-
```hcl
51-
provider "aci" {
52-
version = "x.y.z" # Replace with the new version number
53-
# Other provider configuration options
54-
}
55-
```
43+
***Version constraint format***
44+
```hcl
45+
terraform {
46+
required_providers {
47+
aci = {
48+
source = "ciscodevnet/aci"
49+
version = "~> x.y.z" # Replace with the new version number
50+
}
51+
}
52+
}
53+
```
54+
55+
***Deprecated Terraform version constraint format***
56+
```hcl
57+
provider "aci" {
58+
version = "~> x.y.z" # Replace with the new version number
59+
# Other provider configuration options
60+
}
61+
```
5662

57-
3. **Initialize the Configuration:** Run `terraform init` to reinitialize your configuration with the updated provider version.
63+
3. **Initialize the Configuration:** Run `terraform init -upgrade` to reinitialize your configuration with the updated provider version.
5864

59-
```bash
60-
terraform init
61-
```
65+
```bash
66+
terraform init -upgrade
67+
```
6268

6369
### Step 3: Review the Changes
6470

6571
1. **Plan the Changes:** Run `terraform plan` without modifying the configuration to preview the changes that will be applied with the new provider version.
6672

67-
```bash
68-
terraform plan
69-
```
73+
```bash
74+
terraform plan
75+
```
7076

7177
2. **Review the Plan:** Carefully review the output of the `terraform plan` command to ensure that there are no changes.
7278

73-
~> Warnings are expected to be displayed in the plan output for legacy attributes, this topic will be addressed in ***Step 4: Migrate deprecated configuration***.
79+
~> Warnings are expected to be displayed in the plan output for legacy attributes, this topic will be addressed in [Step 4: Migrate deprecated configuration](#step-4-migrate-deprecated-configuration).
7480

7581
```bash
7682
No changes. Your infrastructure matches the configuration.
@@ -119,20 +125,20 @@ The state file does not reflect the changes yet, because a refresh has not taken
119125
***Old Configuration***
120126
```hcl
121127
resource "aci_bridge_domain" "terraform_bd" {
122-
tenant_dn = aci_tenant.terraform_tenant.id
123-
name = "terraform_bd"
124-
ll_addr = "::"
125-
unk_mcast_act = "flood"
128+
tenant_dn = aci_tenant.terraform_tenant.id
129+
name = "terraform_bd"
130+
ll_addr = "::"
131+
unk_mcast_act = "flood"
126132
}
127133
```
128134

129135
***New Configuration***
130136
```hcl
131137
resource "aci_bridge_domain" "terraform_bd" {
132-
parent_dn = aci_tenant.terraform_tenant.id
133-
name = "terraform_bd"
134-
link_local_ipv6_address = "::"
135-
l3_unknown_multicast_flooding = "flood"
138+
parent_dn = aci_tenant.terraform_tenant.id
139+
name = "terraform_bd"
140+
link_local_ipv6_address = "::"
141+
l3_unknown_multicast_flooding = "flood"
136142
}
137143
```
138144

@@ -148,26 +154,26 @@ The state file does not reflect the changes yet, because a refresh has not taken
148154

149155
1. **Remove Backup (Optional):** If everything is working correctly, you can remove the backup state file.
150156

151-
```bash
152-
rm terraform.tfstate.backup
153-
```
157+
```bash
158+
rm terraform.tfstate.backup
159+
```
154160

155161
By following these steps, you can safely upgrade the ACI Terraform provider to a new version while ensuring that you have a backup of your current state in case anything goes wrong.
156162

157163
## Optimization
158164

159-
1. **Add relationships to parent resource:** Reduces the amount of resources in the configuration by including children inside their parent resources. This will decrease the execution time by decreasing the size of the terraform graph and reducing the amount of REST API calls made towards APIC.
165+
1. **Add relationships to parent resource:** Reduces the amount of resources in the configuration by including children inside their parent resources. This will decrease the execution time by decreasing the size of the terraform graph and reducing the amount of REST API calls made towards APIC. See section [Changed Child Objects in Payloads](#changed-child-objects-in-payloads) for more details.
160166

161167
***Old Configuration***
162168
```hcl
163169
resource "aci_application_epg" "terraform_epg" {
164-
parent_dn = aci_application_profile.terraform_ap.id
165-
name = "terraform_epg"
170+
parent_dn = aci_application_profile.terraform_ap.id
171+
name = "terraform_epg"
166172
}
167173
168174
resource "aci_epg_to_domain" "terraform_epg_to_domain" {
169-
application_epg_dn = aci_application_epg.terraform_epg.id
170-
tdn = "uni/phys-phys"
175+
application_epg_dn = aci_application_epg.terraform_epg.id
176+
tdn = "uni/phys-phys"
171177
}
172178
```
173179

@@ -177,9 +183,9 @@ By following these steps, you can safely upgrade the ACI Terraform provider to a
177183
parent_dn = aci_application_profile.terraform_ap.id
178184
name = "terraform_epg"
179185
relation_to_domains = [
180-
{
181-
target_dn = "uni/phys-phys"
182-
}
186+
{
187+
target_dn = "uni/phys-phys"
188+
}
183189
]
184190
}
185191
```
@@ -284,7 +290,7 @@ In non-migrated resources, child objects (including relationship objects) were m
284290
285291
## Changed Annotation Behavior
286292
287-
The annotation attribute can be set for each MO that exposes the attribute, including children inside a resource. By default, the annotation is set to `orchestrator:terraform`, but this default can be overwritten at the provider level.
293+
The annotation attribute can be set for each MO that exposes the attribute, including children inside a resource. By default, the annotation is set to `orchestrator:terraform`, but this default can be overwritten at different levels (provider, resource, child attribute).
288294
289295
```hcl
290296
provider "aci" {
@@ -311,11 +317,11 @@ For non-migrated resources, the ID of the resource appears as "known after apply
311317
312318
## Error for Existing MO on Create
313319
314-
Migrated resources support the (`allow_existing_on_create`) provider-level option to check during the plan if an object already exists. By default, existing MOs will be automatically managed on apply, as (`allow_existing_on_create`) is set to `true` by default. This option can be set to `false`, providing a mechanism to prevent the management of the same MO by separate configurations. The drawback of this mechanism is that it requires an additional API call per resource during the plan to verify that the object does not already exist.
320+
Migrated resources support the [allow_existing_on_create](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs#schema) provider-level option to check during the plan if an object already exists. By default, existing MOs will be automatically managed on apply, as `allow_existing_on_create` is set to `true` by default. This option can be set to `false`, providing a mechanism to prevent the management of the same MO by separate configurations. The drawback of this mechanism is that it requires an additional API call per resource during the plan to verify that the object does not already exist.
315321
316322
## Allowing Empty Input for Attributes
317323
318-
Migrated resources in the Terraform ACI provider support null, unknown, and known states. Terraform supports three states for any value: null (missing), unknown ("known after apply"), and known. Previous SDKs did not support null and unknown states, which prevented differentiating between an empty value and a non-provided value. Because of this limitation, updating a string value to an empty string was not possible before the Plugin Framework.
324+
The attributes of migrated resources in the Terraform ACI provider now support null, unknown, and known states which can be used to reset values to empty or to enforce that children objects are not present. Terraform supports three states for any value: null (missing), unknown ("known after apply"), and known. Previous SDKs did not support null and unknown states, which prevented differentiating between an empty value and a non-provided value. Because of this limitation, updating a string value to an empty string, updating a map to an empty map or a list of maps to an empty list was not possible before the Plugin Framework but is now supported in the migrated resources.
319325
320326
## Include Annotations and Tags
321327

0 commit comments

Comments
 (0)