Skip to content

Commit 0f1004d

Browse files
authored
[CDTOOL-1280] [Updated] Migrate an existing Delivery service using a classic domain to one using a versionless domain (#1202)
* docs(guides/domains): rewrote migration guide with new specifics * updated changelog * docs(guides/domains): corrected typos & incorrect domain name
1 parent 5dbb0f8 commit 0f1004d

File tree

3 files changed

+163
-45
lines changed

3 files changed

+163
-45
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
- docs(templates/guides): add a guide for adding a versionless domain to a service using a wildcard tls subscription ([#1194](https://github.com/fastly/terraform-provider-fastly/pull/1194))
1616
- docs(templates/guides): add a guide for using versionless domains with a Certainly subscription to a new devlivery service ([#1195](https://github.com/fastly/terraform-provider-fastly/pull/1195))
17-
- docs(templates/guides): add a guide for migrating delivery service classic domain to a versionless domain ([#1196](https://github.com/fastly/terraform-provider-fastly/pull/1196))
17+
- docs(templates/guides): add a guide for migrating delivery service classic domain to a versionless domain ([#1202](https://github.com/fastly/terraform-provider-fastly/pull/1202))
1818
- docs(templates/guides): add a guide for linking versionless domains to a service when the domains are not managed in Terraform ([#1199](https://github.com/fastly/terraform-provider-fastly/pull/1199))
1919
- docs(templates/guides): add a guide for migrating from the deprecated 'fastly_domain_v1' and 'fastly_domain_v1_service_link' resources and data sources ([#1200](https://github.com/fastly/terraform-provider-fastly/pull/1200))
2020
- docs(ngwaf/rules): updated list of supported values for the 'operator' field for NGWAF WAF rule conditions ([#1201](https://github.com/fastly/terraform-provider-fastly/pull/1201))

docs/guides/versionless_domain_migration.md

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,31 @@ subcategory: "Guides"
55

66
## Migrate a Delivery service with a classic domain to a versionless domain
77

8-
Before migrating, your HCL will look something like this, with a domain block inside of your service.
8+
Before migrating, your HCL will look something like this, with a domain block inside of your service and a TLS subscription.
99

1010
```
1111
resource "fastly_service_vcl" "vcl_example" {
1212
name = "versionlessdomainexample"
13+
backend {
14+
address = "127.0.0.1"
15+
name = "localhost"
16+
}
1317
domain {
1418
name = "demo.example.com"
1519
comment = "demo"
1620
}
17-
force_destroy = true
1821
}
19-
```
20-
21-
Once you [use the control panel to migrate this domain to a versionless domain](https://www.fastly.com/documentation/guides/getting-started/domains/working-with-domains/migrating-classic-domains/), you will need to update your HCL to match the pattern below.
22-
You can find the documentation on versionless domain patterns here: https://registry.terraform.io/providers/fastly/fastly/latest/docs/resources/domain. Do not apply your changes before running the import in the next step, as that will result in an error.
2322
24-
```
25-
resource "fastly_service_vcl" "vcl_example" {
26-
name = "versionlessdomainexample"
27-
force_destroy = true
28-
}
29-
30-
resource "fastly_domain" "domain_example" {
31-
fqdn = "demo.example.com"
23+
resource "fastly_tls_subscription" "migrate_example" {
24+
domains = ["demo.example.com"]
25+
certificate_authority = "lets-encrypt"
3226
}
3327
```
3428

35-
Before making other changes you will need to import domain using terraform. The Domain ID can using [the Fastly CLI](https://www.fastly.com/documentation/reference/tools/cli/) by running `fastly domain list --fqdn=foo.example.com` and using the Domain ID from the record.
29+
Before making other changes you will need to import your domain(s) using Terraform. We'll need to run the following import command for each domain:
30+
> `terraform import fastly_domain.domain_example <domain_id>`
3631
37-
```
38-
terraform import fastly_domain.domain_example YOUR_DOMAIN_ID
39-
```
32+
The Domain ID can be obtained by using [the Fastly CLI](https://www.fastly.com/documentation/reference/tools/cli/) by running `fastly domain list --fqdn=foo.example.com` and then using the Domain ID from the record.
4033

4134
Terraform should produce a message similar to the following.
4235

@@ -52,18 +45,84 @@ The resources that were imported are shown above. These resources are now in
5245
your Terraform state and will henceforth be managed by Terraform.
5346
```
5447

55-
After importing, running `terraform plan` should result in no changes.
48+
You'll then need to add a `fastly_domain` resource, associating your service, as seen below.
49+
_You can find the documentation on versionless domain patterns here: https://registry.terraform.io/providers/fastly/fastly/latest/docs/resources/domain._
50+
> **Do not apply your changes before running the import in the next step, as that will result in an error.**
51+
52+
```
53+
resource "fastly_service_vcl" "vcl_example" {
54+
name = "versionlessdomainexample"
55+
backend {
56+
address = "127.0.0.1"
57+
name = "localhost"
58+
}
59+
domain {
60+
name = "demo.example.com"
61+
comment = "demo"
62+
}
63+
}
64+
65+
resource "fastly_tls_subscription" "migrate_example" {
66+
domains = ["demo.example.com"]
67+
certificate_authority = "lets-encrypt"
68+
}
69+
70+
resource "fastly_domain" "domain_example" {
71+
fqdn = "demo.example.com"
72+
service_id = fastly_service_vcl.vcl_example.id
73+
}
74+
```
75+
76+
Once you have added the necessary `fastly_domain` blocks , you can proceed with a `terraform plan` / `terraform apply`.
5677

57-
Once the import has run successfully, you can assign the domain to a service using the `service_id` field of the domain and then plan and apply.
78+
You should excpect to see something like this from your `terraform plan` / `terraform apply` commands:
79+
```
80+
# fastly_domain.example will be updated in-place
81+
~ resource "fastly_domain" "example" {
82+
id = "3a2b3c4d5e"
83+
+ service_id = "1a2b4c5d6e"
84+
# (3 unchanged attributes hidden)
85+
}
86+
```
87+
88+
You now have associated the versionless domain with your service, but we'll still need to remove the classic domain from your HCL. The final step is to remove the `domain` attribute from your `fastly_service_vcl` block, as seen below.
5889

5990
```
6091
resource "fastly_service_vcl" "vcl_example" {
6192
name = "versionlessdomainexample"
62-
force_destroy = true
93+
backend {
94+
address = "127.0.0.1"
95+
name = "localhost"
96+
}
97+
}
98+
99+
resource "fastly_tls_subscription" "migrate_example" {
100+
domains = ["demo.example.com"]
101+
certificate_authority = "lets-encrypt"
63102
}
64103
65104
resource "fastly_domain" "domain_example" {
66105
fqdn = "demo.example.com"
67106
service_id = fastly_service_vcl.vcl_example.id
68107
}
69-
```
108+
```
109+
110+
You can now perform the `terraform plan` / `terraform apply` commands. You should expect to see a similar output from Terraform:
111+
112+
```
113+
# fastly_service_vcl.migrate_example will be updated in-place
114+
~ resource "fastly_service_vcl" "migrate_example" {
115+
~ active_version = 1 -> (known after apply)
116+
~ cloned_version = 1 -> (known after apply)
117+
id = "1a2b4c5d6e"
118+
name = "versionlessdomainexample"
119+
# (11 unchanged attributes hidden)
120+
121+
- domain {
122+
- name = "demo.example.com" -> null
123+
# (1 unchanged attribute hidden)
124+
}
125+
126+
# (1 unchanged block hidden)
127+
}
128+
```

templates/guides/versionless_domain_migration.md

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,31 @@ subcategory: "Guides"
55

66
## Migrate a Delivery service with a classic domain to a versionless domain
77

8-
Before migrating, your HCL will look something like this, with a domain block inside of your service.
8+
Before migrating, your HCL will look something like this, with a domain block inside of your service and a TLS subscription.
99

1010
```
1111
resource "fastly_service_vcl" "vcl_example" {
1212
name = "versionlessdomainexample"
13+
backend {
14+
address = "127.0.0.1"
15+
name = "localhost"
16+
}
1317
domain {
1418
name = "demo.example.com"
1519
comment = "demo"
1620
}
17-
force_destroy = true
1821
}
19-
```
20-
21-
Once you [use the control panel to migrate this domain to a versionless domain](https://www.fastly.com/documentation/guides/getting-started/domains/working-with-domains/migrating-classic-domains/), you will need to update your HCL to match the pattern below.
22-
You can find the documentation on versionless domain patterns here: https://registry.terraform.io/providers/fastly/fastly/latest/docs/resources/domain. Do not apply your changes before running the import in the next step, as that will result in an error.
2322
24-
```
25-
resource "fastly_service_vcl" "vcl_example" {
26-
name = "versionlessdomainexample"
27-
force_destroy = true
28-
}
29-
30-
resource "fastly_domain" "domain_example" {
31-
fqdn = "demo.example.com"
23+
resource "fastly_tls_subscription" "migrate_example" {
24+
domains = ["demo.example.com"]
25+
certificate_authority = "lets-encrypt"
3226
}
3327
```
3428

35-
Before making other changes you will need to import domain using terraform. The Domain ID can using [the Fastly CLI](https://www.fastly.com/documentation/reference/tools/cli/) by running `fastly domain list --fqdn=foo.example.com` and using the Domain ID from the record.
29+
Before making other changes you will need to import your domain(s) using Terraform. We'll need to run the following import command for each domain:
30+
> `terraform import fastly_domain.domain_example <domain_id>`
3631
37-
```
38-
terraform import fastly_domain.domain_example YOUR_DOMAIN_ID
39-
```
32+
The Domain ID can be obtained by using [the Fastly CLI](https://www.fastly.com/documentation/reference/tools/cli/) by running `fastly domain list --fqdn=foo.example.com` and then using the Domain ID from the record.
4033

4134
Terraform should produce a message similar to the following.
4235

@@ -52,18 +45,84 @@ The resources that were imported are shown above. These resources are now in
5245
your Terraform state and will henceforth be managed by Terraform.
5346
```
5447

55-
After importing, running `terraform plan` should result in no changes.
48+
You'll then need to add a `fastly_domain` resource, associating your service, as seen below.
49+
_You can find the documentation on versionless domain patterns here: https://registry.terraform.io/providers/fastly/fastly/latest/docs/resources/domain._
50+
> **Do not apply your changes before running the import in the next step, as that will result in an error.**
51+
52+
```
53+
resource "fastly_service_vcl" "vcl_example" {
54+
name = "versionlessdomainexample"
55+
backend {
56+
address = "127.0.0.1"
57+
name = "localhost"
58+
}
59+
domain {
60+
name = "demo.example.com"
61+
comment = "demo"
62+
}
63+
}
64+
65+
resource "fastly_tls_subscription" "migrate_example" {
66+
domains = ["demo.example.com"]
67+
certificate_authority = "lets-encrypt"
68+
}
69+
70+
resource "fastly_domain" "domain_example" {
71+
fqdn = "demo.example.com"
72+
service_id = fastly_service_vcl.vcl_example.id
73+
}
74+
```
75+
76+
Once you have added the necessary `fastly_domain` blocks , you can proceed with a `terraform plan` / `terraform apply`.
5677

57-
Once the import has run successfully, you can assign the domain to a service using the `service_id` field of the domain and then plan and apply.
78+
You should excpect to see something like this from your `terraform plan` / `terraform apply` commands:
79+
```
80+
# fastly_domain.example will be updated in-place
81+
~ resource "fastly_domain" "example" {
82+
id = "3a2b3c4d5e"
83+
+ service_id = "1a2b4c5d6e"
84+
# (3 unchanged attributes hidden)
85+
}
86+
```
87+
88+
You now have associated the versionless domain with your service, but we'll still need to remove the classic domain from your HCL. The final step is to remove the `domain` attribute from your `fastly_service_vcl` block, as seen below.
5889

5990
```
6091
resource "fastly_service_vcl" "vcl_example" {
6192
name = "versionlessdomainexample"
62-
force_destroy = true
93+
backend {
94+
address = "127.0.0.1"
95+
name = "localhost"
96+
}
97+
}
98+
99+
resource "fastly_tls_subscription" "migrate_example" {
100+
domains = ["demo.example.com"]
101+
certificate_authority = "lets-encrypt"
63102
}
64103
65104
resource "fastly_domain" "domain_example" {
66105
fqdn = "demo.example.com"
67106
service_id = fastly_service_vcl.vcl_example.id
68107
}
69-
```
108+
```
109+
110+
You can now perform the `terraform plan` / `terraform apply` commands. You should expect to see a similar output from Terraform:
111+
112+
```
113+
# fastly_service_vcl.migrate_example will be updated in-place
114+
~ resource "fastly_service_vcl" "migrate_example" {
115+
~ active_version = 1 -> (known after apply)
116+
~ cloned_version = 1 -> (known after apply)
117+
id = "1a2b4c5d6e"
118+
name = "versionlessdomainexample"
119+
# (11 unchanged attributes hidden)
120+
121+
- domain {
122+
- name = "demo.example.com" -> null
123+
# (1 unchanged attribute hidden)
124+
}
125+
126+
# (1 unchanged block hidden)
127+
}
128+
```

0 commit comments

Comments
 (0)