Skip to content

Commit 2253ea8

Browse files
committed
Allow resource importing
1 parent 3ab6d76 commit 2253ea8

File tree

15 files changed

+487
-54
lines changed

15 files changed

+487
-54
lines changed

docs/resources/cdn.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,15 @@ Optional:
156156
- `port` (Number)
157157
- `protocol` (String)
158158
- `query_key` (String)
159+
160+
## Import
161+
162+
Import is supported using the following syntax:
163+
164+
```shell
165+
$ terraform import cdn77_cdn.example <id>
166+
167+
# <id> must be the ID (unsigned integer) of the CDN
168+
# Example:
169+
$ terraform import cdn77_cdn.example 1837865409
170+
```

docs/resources/origin.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,36 @@ resource "cdn77_origin" "example" {
4848
- `access_key_id` (String) Access key to your Object Storage bucket
4949
- `access_key_secret` (String, Sensitive) Access secret to your Object Storage bucket
5050
- `id` (String) Origin ID (UUID)
51+
52+
## Import
53+
54+
Import is supported using the following syntax:
55+
56+
```shell
57+
$ terraform import cdn77_origin.example <id>,<type>[,type-specific parameters,...]
58+
59+
# <id> must be the ID (UUID) of the Origin
60+
# <type> must be a type of the Origin (one of: "aws", "object-storage", "url")
61+
# Depending on the type of the origin there may be other required parameters:
62+
63+
# URL type doesn't need other parameters
64+
$ terraform import cdn77_origin.example <id>,url
65+
66+
# AWS type requires access key secret
67+
# <aws_access_key_secret> must be the secret of the AWS access key that you provided when creating the Origin
68+
$ terraform import cdn77_origin.example <id>,aws,<aws_access_key_secret>
69+
70+
# Object Storage type requires ACL, cluster ID, access key ID and access key secret
71+
# <acl> must be ACL type (one of: "authenticated-read", "private", "public-read", "public-read-write")
72+
# <cluster_id> must be an ID (UUID) of the Object Storage cluster
73+
# <access_key_id> must be the ID of the access key that was returned when creating the Origin
74+
# <access_key_secret> must be the secret of the access key that was returned when creating the Origin
75+
$ terraform import cdn77_origin.example <id>,object-storage,<acl>,<cluster_id>,<access_key_id>,<access_key_secret>
76+
77+
# Examples:
78+
$ terraform import cdn77_origin.example_url 4cd2378b-dec8-49e2-aa17-bf7561452998,url
79+
$ terraform import cdn77_origin.example_aws 4cd2378b-dec8-49e2-aa17-bf7561452998,aws,\
80+
VWK92izmd7zpY8Khs/Dllv4yLYc4sFWNyg2XtuNF
81+
$ terraform import cdn77_origin.example_object_storage 4cd2378b-dec8-49e2-aa17-bf7561452998,object-storage,\
82+
private,842b5641-b641-4723-ac81-f8cc286e288f,I17DXFE00GNJZVQUTQPW,7UG7WbcIz4VhZnVxV4XQcDR2X0APApuvthyATf2v
83+
```

docs/resources/ssl.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,24 @@ resource "cdn77_ssl" "example" {
3232
- `expires_at` (String) Date and time of the SNI certificate expiration
3333
- `id` (String) ID (UUID) of the SSL certificate
3434
- `subjects` (Set of String) Subjects (domain names) of the certificate
35+
36+
## Import
37+
38+
Import is supported using the following syntax:
39+
40+
```shell
41+
$ terraform import cdn77_ssl.example <id>,<private_key>
42+
43+
# <id> must be the ID (UUID) of the SSL certificate
44+
# <privateKey> must be an entire private key (including PEM headers) encoded via base64.
45+
# Example:
46+
$ key=$(base64 --wrap=0 key.pem <<EOL
47+
-----BEGIN EC PRIVATE KEY-----
48+
MHcCAQEEIHqBB2YZkISl1T5TmmZciLN4cJfJPZ6CDpkLgwTiDVyEoAoGCCqGSM49
49+
AwEHoUQDQgAE+lmT51fh5oPIAvtPOEvDw4Ct2sKCt1kYhASlD5b62pT2UyXPrRWp
50+
ekd7UQCYC8K86F1OFeupn2DCOnyGCyK8mw==
51+
-----END EC PRIVATE KEY-----
52+
EOL
53+
)
54+
$ terraform import cdn77_ssl.example "4cd2378b-dec8-49e2-aa17-bf7561452998,$key"
55+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$ terraform import cdn77_cdn.example <id>
2+
3+
# <id> must be the ID (unsigned integer) of the CDN
4+
# Example:
5+
$ terraform import cdn77_cdn.example 1837865409
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$ terraform import cdn77_origin.example <id>,<type>[,type-specific parameters,...]
2+
3+
# <id> must be the ID (UUID) of the Origin
4+
# <type> must be a type of the Origin (one of: "aws", "object-storage", "url")
5+
# Depending on the type of the origin there may be other required parameters:
6+
7+
# URL type doesn't need other parameters
8+
$ terraform import cdn77_origin.example <id>,url
9+
10+
# AWS type requires access key secret
11+
# <aws_access_key_secret> must be the secret of the AWS access key that you provided when creating the Origin
12+
$ terraform import cdn77_origin.example <id>,aws,<aws_access_key_secret>
13+
14+
# Object Storage type requires ACL, cluster ID, access key ID and access key secret
15+
# <acl> must be ACL type (one of: "authenticated-read", "private", "public-read", "public-read-write")
16+
# <cluster_id> must be an ID (UUID) of the Object Storage cluster
17+
# <access_key_id> must be the ID of the access key that was returned when creating the Origin
18+
# <access_key_secret> must be the secret of the access key that was returned when creating the Origin
19+
$ terraform import cdn77_origin.example <id>,object-storage,<acl>,<cluster_id>,<access_key_id>,<access_key_secret>
20+
21+
# Examples:
22+
$ terraform import cdn77_origin.example_url 4cd2378b-dec8-49e2-aa17-bf7561452998,url
23+
$ terraform import cdn77_origin.example_aws 4cd2378b-dec8-49e2-aa17-bf7561452998,aws,\
24+
VWK92izmd7zpY8Khs/Dllv4yLYc4sFWNyg2XtuNF
25+
$ terraform import cdn77_origin.example_object_storage 4cd2378b-dec8-49e2-aa17-bf7561452998,object-storage,\
26+
private,842b5641-b641-4723-ac81-f8cc286e288f,I17DXFE00GNJZVQUTQPW,7UG7WbcIz4VhZnVxV4XQcDR2X0APApuvthyATf2v
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$ terraform import cdn77_ssl.example <id>,<private_key>
2+
3+
# <id> must be the ID (UUID) of the SSL certificate
4+
# <privateKey> must be an entire private key (including PEM headers) encoded via base64.
5+
# Example:
6+
$ key=$(base64 --wrap=0 key.pem <<EOL
7+
-----BEGIN EC PRIVATE KEY-----
8+
MHcCAQEEIHqBB2YZkISl1T5TmmZciLN4cJfJPZ6CDpkLgwTiDVyEoAoGCCqGSM49
9+
AwEHoUQDQgAE+lmT51fh5oPIAvtPOEvDw4Ct2sKCt1kYhASlD5b62pT2UyXPrRWp
10+
ekd7UQCYC8K86F1OFeupn2DCOnyGCyK8mw==
11+
-----END EC PRIVATE KEY-----
12+
EOL
13+
)
14+
$ terraform import cdn77_ssl.example "4cd2378b-dec8-49e2-aa17-bf7561452998,$key"

go.mod

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ require (
66
github.com/cdn77/cdn77-client-go v1.0.0
77
github.com/google/uuid v1.6.0
88
github.com/hashicorp/terraform-plugin-docs v0.19.4
9-
github.com/hashicorp/terraform-plugin-framework v1.9.0
10-
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
9+
github.com/hashicorp/terraform-plugin-framework v1.10.0
10+
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0
1111
github.com/hashicorp/terraform-plugin-go v0.23.0
1212
github.com/hashicorp/terraform-plugin-log v0.9.0
13-
github.com/hashicorp/terraform-plugin-testing v1.8.0
13+
github.com/hashicorp/terraform-plugin-testing v1.9.0
1414
github.com/oapi-codegen/nullable v1.1.0
15-
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
15+
golang.org/x/exp v0.0.0-20240707233637-46b078467d37
1616
)
1717

1818
require (
@@ -31,7 +31,7 @@ require (
3131
github.com/cloudflare/circl v1.3.7 // indirect
3232
github.com/deepmap/oapi-codegen/v2 v2.2.0 // indirect
3333
github.com/fatih/color v1.16.0 // indirect
34-
github.com/getkin/kin-openapi v0.125.0 // indirect
34+
github.com/getkin/kin-openapi v0.126.0 // indirect
3535
github.com/go-openapi/jsonpointer v0.21.0 // indirect
3636
github.com/go-openapi/swag v0.23.0 // indirect
3737
github.com/golang/protobuf v1.5.4 // indirect
@@ -47,11 +47,11 @@ require (
4747
github.com/hashicorp/go-uuid v1.0.3 // indirect
4848
github.com/hashicorp/go-version v1.7.0 // indirect
4949
github.com/hashicorp/hc-install v0.7.0 // indirect
50-
github.com/hashicorp/hcl/v2 v2.20.1 // indirect
50+
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
5151
github.com/hashicorp/logutils v1.0.0 // indirect
5252
github.com/hashicorp/terraform-exec v0.21.0 // indirect
5353
github.com/hashicorp/terraform-json v0.22.1 // indirect
54-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 // indirect
54+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 // indirect
5555
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
5656
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
5757
github.com/hashicorp/yamux v0.1.1 // indirect
@@ -82,13 +82,13 @@ require (
8282
github.com/yuin/goldmark-meta v1.1.0 // indirect
8383
github.com/zclconf/go-cty v1.14.4 // indirect
8484
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
85-
golang.org/x/crypto v0.24.0 // indirect
86-
golang.org/x/mod v0.18.0 // indirect
87-
golang.org/x/net v0.26.0 // indirect
85+
golang.org/x/crypto v0.25.0 // indirect
86+
golang.org/x/mod v0.19.0 // indirect
87+
golang.org/x/net v0.27.0 // indirect
8888
golang.org/x/sync v0.7.0 // indirect
89-
golang.org/x/sys v0.21.0 // indirect
89+
golang.org/x/sys v0.22.0 // indirect
9090
golang.org/x/text v0.16.0 // indirect
91-
golang.org/x/tools v0.22.0 // indirect
91+
golang.org/x/tools v0.23.0 // indirect
9292
google.golang.org/appengine v1.6.8 // indirect
9393
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
9494
google.golang.org/grpc v1.63.2 // indirect

go.sum

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
4949
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
5050
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
5151
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
52-
github.com/getkin/kin-openapi v0.125.0 h1:jyQCyf2qXS1qvs2U00xQzkGCqYPhEhZDmSmVt65fXno=
53-
github.com/getkin/kin-openapi v0.125.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM=
52+
github.com/getkin/kin-openapi v0.126.0 h1:c2cSgLnAsS0xYfKsgt5oBV6MYRM/giU8/RtwUY4wyfY=
53+
github.com/getkin/kin-openapi v0.126.0/go.mod h1:7mONz8IwmSRg6RttPu6v8U/OJ+gr+J99qSFNjPGSQqw=
5454
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
5555
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
5656
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
@@ -103,8 +103,8 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe
103103
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
104104
github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk=
105105
github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA=
106-
github.com/hashicorp/hcl/v2 v2.20.1 h1:M6hgdyz7HYt1UN9e61j+qKJBqR3orTWbI1HKBJEdxtc=
107-
github.com/hashicorp/hcl/v2 v2.20.1/go.mod h1:TZDqQ4kNKCbh1iJp99FdPiUaVDDUPivbqxZulxDYqL4=
106+
github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14=
107+
github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
108108
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
109109
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
110110
github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ=
@@ -113,18 +113,18 @@ github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7
113113
github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A=
114114
github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c=
115115
github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA=
116-
github.com/hashicorp/terraform-plugin-framework v1.9.0 h1:caLcDoxiRucNi2hk8+j3kJwkKfvHznubyFsJMWfZqKU=
117-
github.com/hashicorp/terraform-plugin-framework v1.9.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM=
118-
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc=
119-
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg=
116+
github.com/hashicorp/terraform-plugin-framework v1.10.0 h1:xXhICE2Fns1RYZxEQebwkB2+kXouLC932Li9qelozrc=
117+
github.com/hashicorp/terraform-plugin-framework v1.10.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM=
118+
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E=
119+
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo=
120120
github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co=
121121
github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ=
122122
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
123123
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
124-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8=
125-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A=
126-
github.com/hashicorp/terraform-plugin-testing v1.8.0 h1:wdYIgwDk4iO933gC4S8KbKdnMQShu6BXuZQPScmHvpk=
127-
github.com/hashicorp/terraform-plugin-testing v1.8.0/go.mod h1:o2kOgf18ADUaZGhtOl0YCkfIxg01MAiMATT2EtIHlZk=
124+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 h1:kJiWGx2kiQVo97Y5IOGR4EMcZ8DtMswHhUuFibsCQQE=
125+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0/go.mod h1:sl/UoabMc37HA6ICVMmGO+/0wofkVIRxf+BMb/dnoIg=
126+
github.com/hashicorp/terraform-plugin-testing v1.9.0 h1:xOsQRqqlHKXpFq6etTxih3ubdK3HVDtfE1IY7Rpd37o=
127+
github.com/hashicorp/terraform-plugin-testing v1.9.0/go.mod h1:fhhVx/8+XNJZTD5o3b4stfZ6+q7z9+lIWigIYdT6/44=
128128
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
129129
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
130130
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
@@ -234,27 +234,27 @@ github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUei
234234
github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0=
235235
github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8=
236236
github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
237-
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI=
238-
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
237+
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo=
238+
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
239239
go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw=
240240
go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU=
241241
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
242242
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
243243
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
244-
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
245-
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
246-
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
247-
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
244+
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
245+
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
246+
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w=
247+
golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
248248
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
249-
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
250-
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
249+
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
250+
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
251251
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
252252
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
253253
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
254254
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
255255
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
256-
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
257-
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
256+
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
257+
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
258258
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
259259
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
260260
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -273,8 +273,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
273273
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
274274
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
275275
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
276-
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
277-
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
276+
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
277+
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
278278
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
279279
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
280280
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
@@ -289,8 +289,8 @@ golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
289289
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
290290
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
291291
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
292-
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
293-
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
292+
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
293+
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
294294
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
295295
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
296296
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=

internal/provider/cdn_resource.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package provider
22

33
import (
44
"context"
5+
"fmt"
6+
"strconv"
57
"time"
68

79
"github.com/cdn77/cdn77-client-go"
@@ -16,6 +18,7 @@ import (
1618
var (
1719
_ resource.ResourceWithConfigure = &CdnResource{}
1820
_ resource.ResourceWithConfigValidators = &CdnResource{}
21+
_ resource.ResourceWithImportState = &CdnResource{}
1922
)
2023

2124
func NewCdnResource() resource.Resource {
@@ -185,6 +188,24 @@ func (r *CdnResource) Delete(ctx context.Context, req resource.DeleteRequest, re
185188
util.CheckResponse(&resp.Diagnostics, errMessage, response, response.JSON404, response.JSONDefault)
186189
}
187190

191+
func (*CdnResource) ImportState(
192+
ctx context.Context,
193+
req resource.ImportStateRequest,
194+
resp *resource.ImportStateResponse,
195+
) {
196+
id, err := strconv.ParseUint(req.ID, 10, 64)
197+
if err != nil {
198+
resp.Diagnostics.AddError(
199+
"Invalid Import Identifier",
200+
fmt.Sprintf("Expected unsigned integer, got: %q", req.ID),
201+
)
202+
203+
return
204+
}
205+
206+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), id)...)
207+
}
208+
188209
func (*CdnResource) createDefaultEditRequest() cdn77.CdnEditJSONRequestBody {
189210
return cdn77.CdnEditJSONRequestBody{
190211
Cache: &cdn77.Cache{

0 commit comments

Comments
 (0)