From 397b01e02288529f008138903ee4fd78df8bfa02 Mon Sep 17 00:00:00 2001 From: Toni Kangas Date: Tue, 7 May 2024 17:32:11 +0300 Subject: [PATCH] refactor: setup muxing to allow migrating to plugin-framework (#531) This also re-implements one resource, `upcloud_network`, and one data-source, `upcloud_managed_object_storage_regions`, using the plugin framework. --- .ci/tools/go.mod | 52 +- .ci/tools/go.sum | 263 ++++----- docs/data-sources/hosts.md | 6 +- docs/data-sources/ip_addresses.md | 2 - docs/data-sources/kubernetes_cluster.md | 4 +- .../managed_database_mysql_sessions.md | 6 +- .../managed_database_opensearch_indices.md | 4 +- .../managed_database_postgresql_sessions.md | 11 +- .../managed_database_redis_sessions.md | 6 +- .../managed_object_storage_policies.md | 4 +- .../managed_object_storage_regions.md | 12 +- docs/data-sources/networks.md | 4 +- docs/data-sources/storage.md | 6 +- docs/data-sources/tags.md | 2 - docs/data-sources/zone.md | 4 +- docs/data-sources/zones.md | 4 +- docs/index.md | 2 +- docs/resources/firewall_rules.md | 19 +- docs/resources/floating_ip_address.md | 2 +- docs/resources/gateway.md | 31 +- docs/resources/gateway_connection.md | 19 +- docs/resources/gateway_connection_tunnel.md | 12 +- docs/resources/kubernetes_cluster.md | 6 +- docs/resources/kubernetes_node_group.md | 17 +- docs/resources/loadbalancer.md | 13 +- docs/resources/loadbalancer_backend.md | 13 +- .../loadbalancer_backend_tls_config.md | 4 +- .../loadbalancer_dynamic_backend_member.md | 6 +- ...loadbalancer_dynamic_certificate_bundle.md | 4 +- docs/resources/loadbalancer_frontend.md | 10 +- docs/resources/loadbalancer_frontend_rule.md | 76 ++- .../loadbalancer_frontend_tls_config.md | 4 +- .../loadbalancer_manual_certificate_bundle.md | 6 +- docs/resources/loadbalancer_resolver.md | 4 +- .../loadbalancer_static_backend_member.md | 6 +- .../managed_database_logical_database.md | 6 +- docs/resources/managed_database_mysql.md | 22 +- docs/resources/managed_database_opensearch.md | 42 +- docs/resources/managed_database_postgresql.md | 38 +- docs/resources/managed_database_redis.md | 22 +- docs/resources/managed_database_user.md | 19 +- docs/resources/managed_object_storage.md | 13 +- .../managed_object_storage_policy.md | 6 +- docs/resources/managed_object_storage_user.md | 4 +- .../managed_object_storage_user_access_key.md | 4 +- .../managed_object_storage_user_policy.md | 4 +- docs/resources/network.md | 23 +- docs/resources/object_storage.md | 11 +- docs/resources/router.md | 12 +- docs/resources/server.md | 85 +-- docs/resources/server_group.md | 4 +- docs/resources/storage.md | 29 +- docs/resources/tag.md | 6 +- go.mod | 45 +- go.sum | 133 +++-- ...ata_sources.go => policies_data_source.go} | 71 --- .../regions_data_source.go | 126 +++++ internal/service/network/network.go | 502 +++++++++++------- internal/utils/error.go | 8 + internal/utils/types.go | 53 ++ internal/validator/framework.go | 45 ++ main.go | 36 +- upcloud/datasource_upcloud_hosts_test.go | 7 +- .../datasource_upcloud_ip_addresses_test.go | 7 +- ...ud_managed_database_mysql_sessions_test.go | 6 +- ...anaged_database_opensearch_indices_test.go | 6 +- ...naged_database_postgresql_sessions_test.go | 6 +- ...ud_managed_database_redis_sessions_test.go | 6 +- ...ud_managed_object_storage_policies_test.go | 6 +- ...oud_managed_object_storage_regions_test.go | 10 +- upcloud/datasource_upcloud_networks_test.go | 19 +- upcloud/datasource_upcloud_storage_test.go | 7 +- upcloud/datasource_upcloud_tags_test.go | 7 +- upcloud/datasource_upcloud_zone_test.go | 7 +- upcloud/datasource_upcloud_zones_test.go | 25 +- upcloud/muxserver.go | 24 + upcloud/provider.go | 207 +++----- upcloud/provider_test.go | 24 +- .../resource_upcloud_firewall_rules_test.go | 24 +- ...source_upcloud_floating_ip_address_test.go | 26 +- upcloud/resource_upcloud_gateway_test.go | 14 +- upcloud/resource_upcloud_kubernetes_test.go | 11 +- upcloud/resource_upcloud_loadbalancer_test.go | 12 +- ...rce_upcloud_managed_database_mysql_test.go | 6 +- ...pcloud_managed_database_opensearch_test.go | 6 +- ...pcloud_managed_database_postgresql_test.go | 6 +- ...rce_upcloud_managed_database_redis_test.go | 6 +- .../resource_upcloud_managed_database_test.go | 6 +- ...rce_upcloud_managed_object_storage_test.go | 14 +- ...pcloud_managed_object_storage_user_test.go | 6 +- upcloud/resource_upcloud_network_test.go | 77 +-- .../resource_upcloud_objectstorage_test.go | 39 +- upcloud/resource_upcloud_router_test.go | 39 +- upcloud/resource_upcloud_server_group_test.go | 19 +- .../resource_upcloud_server_network_test.go | 6 +- upcloud/resource_upcloud_server_test.go | 61 +-- upcloud/resource_upcloud_storage_test.go | 51 +- upcloud/resource_upcloud_tag_test.go | 15 +- upcloud/sdkv2_provider.go | 175 ++++++ 99 files changed, 1628 insertions(+), 1378 deletions(-) rename internal/service/managedobjectstorage/{data_sources.go => policies_data_source.go} (54%) create mode 100644 internal/service/managedobjectstorage/regions_data_source.go create mode 100644 internal/utils/types.go create mode 100644 internal/validator/framework.go create mode 100644 upcloud/muxserver.go create mode 100644 upcloud/sdkv2_provider.go diff --git a/.ci/tools/go.mod b/.ci/tools/go.mod index eb6b901dd..73588ec86 100644 --- a/.ci/tools/go.mod +++ b/.ci/tools/go.mod @@ -1,39 +1,57 @@ module github.com/UpCloudLtd/terraform-provider-upcloud/tools -go 1.20 +go 1.21 -require github.com/hashicorp/terraform-plugin-docs v0.13.0 +toolchain go1.22.1 + +require github.com/hashicorp/terraform-plugin-docs v0.19.1 + +// Use patched version of terraform-plugin-docs until https://github.com/hashicorp/terraform-plugin-docs/issues/363 is resolved. +replace github.com/hashicorp/terraform-plugin-docs v0.19.1 => github.com/UpCloudLtd/terraform-plugin-docs v0.0.0-20240429132234-3a67351e4359 require ( + github.com/BurntSushi/toml v1.2.1 // indirect + github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.1.1 // indirect - github.com/Masterminds/sprig/v3 v3.2.2 // indirect + github.com/Masterminds/semver/v3 v3.2.0 // indirect + github.com/Masterminds/sprig/v3 v3.2.3 // indirect + github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/fatih/color v1.13.0 // indirect + github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect + github.com/cloudflare/circl v1.3.7 // indirect + github.com/fatih/color v1.16.0 // indirect github.com/google/uuid v1.3.0 // indirect + github.com/hashicorp/cli v1.1.6 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.4.0 // indirect - github.com/hashicorp/terraform-exec v0.17.2 // indirect - github.com/hashicorp/terraform-json v0.14.0 // indirect - github.com/huandu/xstrings v1.3.2 // indirect - github.com/imdario/mergo v0.3.13 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/mitchellh/cli v1.1.4 // indirect + github.com/hashicorp/hc-install v0.6.4 // indirect + github.com/hashicorp/terraform-exec v0.20.0 // indirect + github.com/hashicorp/terraform-json v0.21.0 // indirect + github.com/huandu/xstrings v1.3.3 // indirect + github.com/imdario/mergo v0.3.15 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/posener/complete v1.2.3 // indirect - github.com/russross/blackfriday v1.6.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect - github.com/zclconf/go-cty v1.10.0 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/sys v0.15.0 // indirect + github.com/yuin/goldmark v1.7.1 // indirect + github.com/yuin/goldmark-meta v1.1.0 // indirect + github.com/zclconf/go-cty v1.14.4 // indirect + go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect + golang.org/x/mod v0.16.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/.ci/tools/go.sum b/.ci/tools/go.sum index 17045abc0..908595d59 100644 --- a/.ci/tools/go.sum +++ b/.ci/tools/go.sum @@ -1,58 +1,57 @@ -github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0= +github.com/Kunde21/markdownfmt/v3 v3.1.0/go.mod h1:tPXN1RTyOzJwhfHoon9wUr4HGYmWgVxSQN6VBJDkrVc= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig/v3 v3.2.0/go.mod h1:tWhwTbUTndesPNeF0C900vKoq283u6zp4APT9vaF3SI= -github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= -github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= -github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= -github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= +github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= +github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= +github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/UpCloudLtd/terraform-plugin-docs v0.0.0-20240429132234-3a67351e4359 h1:wyC0KzxX8Urue7Fuxj2E4XeVe5YvMiNWsoyHA8lo/Lw= +github.com/UpCloudLtd/terraform-plugin-docs v0.0.0-20240429132234-3a67351e4359/go.mod h1:gad2aP6uObFKhgNE8DR9nsEuEQnibp7il0jZYYOunWY= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I= +github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= -github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= -github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= -github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= -github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= -github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= -github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= -github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/cli v1.1.6 h1:CMOV+/LJfL1tXCOKrgAX0uRKnzjj/mpmqNXloRSy2K8= +github.com/hashicorp/cli v1.1.6/go.mod h1:MPon5QYlgjjo0BSoAiN0ESeT5fRzDjVRp+uioJ0piz4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -67,150 +66,124 @@ github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9 github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH92oYYk= -github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI= -github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad8zszYZ73Go= -github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8= -github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= -github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= -github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY= -github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ= -github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= -github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/hashicorp/hc-install v0.6.4 h1:QLqlM56/+SIIGvGcfFiwMY3z5WGXT066suo/v9Km8e0= +github.com/hashicorp/hc-install v0.6.4/go.mod h1:05LWLy8TD842OtgcfBbOT0WMoInBMUSHjmDx10zuBIA= +github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo= +github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw= +github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U= +github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= +github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= +github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mitchellh/cli v1.1.4 h1:qj8czE26AU4PbiaPXK5uVmMSM+V5BYsFBiM9HhGRLUA= -github.com/mitchellh/cli v1.1.4/go.mod h1:vTLESy5mRhKOs9KDp0/RATawxP1UqBmdrpVRMnpcvKQ= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= -github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= -github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= -github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= -github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= -github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= +github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= +github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= +github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= +github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw= +go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/docs/data-sources/hosts.md b/docs/data-sources/hosts.md index 93eea9582..13aa8c287 100644 --- a/docs/data-sources/hosts.md +++ b/docs/data-sources/hosts.md @@ -4,8 +4,8 @@ page_title: "upcloud_hosts Data Source - terraform-provider-upcloud" subcategory: Cloud description: |- Returns a list of available UpCloud hosts. - A host identifies the host server that virtual machines are run on. - Only hosts on private cloud to which the calling account has access to are available through this resource. + A host identifies the host server that virtual machines are run on. + Only hosts on private cloud to which the calling account has access to are available through this resource. --- # upcloud_hosts (Data Source) @@ -36,5 +36,3 @@ Read-Only: - `description` (String) - `host_id` (Number) - `zone` (String) - - diff --git a/docs/data-sources/ip_addresses.md b/docs/data-sources/ip_addresses.md index 10320c896..99ab74609 100644 --- a/docs/data-sources/ip_addresses.md +++ b/docs/data-sources/ip_addresses.md @@ -38,5 +38,3 @@ Read-Only: - `ptr_record` (String) - `server` (String) - `zone` (String) - - diff --git a/docs/data-sources/kubernetes_cluster.md b/docs/data-sources/kubernetes_cluster.md index 1bd210d4c..f3fef429f 100644 --- a/docs/data-sources/kubernetes_cluster.md +++ b/docs/data-sources/kubernetes_cluster.md @@ -88,7 +88,7 @@ resource "local_file" "example" { ## Schema -### Required +### Required Attributes - `id` (String) Cluster ID. @@ -100,5 +100,3 @@ resource "local_file" "example" { - `host` (String) Hostname of the cluster API. Defined as URI. - `kubeconfig` (String) Kubernetes config file contents for the cluster. - `name` (String) Cluster name. Needs to be unique within the account. - - diff --git a/docs/data-sources/managed_database_mysql_sessions.md b/docs/data-sources/managed_database_mysql_sessions.md index aa12d4121..55f6efdeb 100644 --- a/docs/data-sources/managed_database_mysql_sessions.md +++ b/docs/data-sources/managed_database_mysql_sessions.md @@ -32,11 +32,11 @@ data "upcloud_managed_database_mysql_sessions" "example" { ## Schema -### Required +### Required Attributes - `service` (String) Service's UUID for which these sessions belongs to -### Optional +### Optional Attributes - `limit` (Number) Number of entries to receive at most. - `offset` (Number) Offset for retrieved results based on sort order. @@ -60,5 +60,3 @@ Read-Only: - `query_duration` (String) The active query current duration. - `state` (String) Current overall state of this service: active: The service is executing a query, idle: The service is waiting for a new client command. - `usename` (String) Name of the user logged into this service. - - diff --git a/docs/data-sources/managed_database_opensearch_indices.md b/docs/data-sources/managed_database_opensearch_indices.md index 6fcb7e631..5be0b2cae 100644 --- a/docs/data-sources/managed_database_opensearch_indices.md +++ b/docs/data-sources/managed_database_opensearch_indices.md @@ -36,7 +36,7 @@ data "upcloud_managed_database_opensearch_indices" "example" { ## Schema -### Required +### Required Attributes - `service` (String) Service's UUID for which these indices belongs to @@ -59,5 +59,3 @@ Read-Only: - `read_only_allow_delete` (Boolean) Indicates whether the index is in a read-only state that permits deletion of the entire index. This attribute can be automatically set to true in certain scenarios where the node disk space exceeds the flood stage. - `size` (Number) Size of the index in bytes. - `status` (String) Status of the index e.g. `open` or `closed`. - - diff --git a/docs/data-sources/managed_database_postgresql_sessions.md b/docs/data-sources/managed_database_postgresql_sessions.md index 184e8090e..68a6bfda0 100644 --- a/docs/data-sources/managed_database_postgresql_sessions.md +++ b/docs/data-sources/managed_database_postgresql_sessions.md @@ -32,15 +32,18 @@ data "upcloud_managed_database_postgresql_sessions" "example" { ## Schema -### Required +### Required Attributes - `service` (String) Service's UUID for which these sessions belongs to -### Optional +### Optional Attributes - `limit` (Number) Number of entries to receive at most. - `offset` (Number) Offset for retrieved results based on sort order. - `order` (String) Order by session field and sort retrieved results. Limited variables can be used for ordering. + +### Blocks + - `sessions` (Block Set) Current sessions (see [below for nested schema](#nestedblock--sessions)) ### Read-Only @@ -50,7 +53,7 @@ data "upcloud_managed_database_postgresql_sessions" "example" { ### Nested Schema for `sessions` -Optional: +Optional Attributes: - `backend_xid` (Number) Top-level transaction identifier of this service, if any. - `backend_xmin` (Number) The current service's xmin horizon. @@ -76,5 +79,3 @@ Read-Only: - `usesysid` (Number) OID of the user logged into this service. - `wait_event` (String) Wait event name if service is currently waiting. - `wait_event_type` (String) The type of event for which the service is waiting, if any; otherwise NULL. - - diff --git a/docs/data-sources/managed_database_redis_sessions.md b/docs/data-sources/managed_database_redis_sessions.md index 95ec354ea..984321079 100644 --- a/docs/data-sources/managed_database_redis_sessions.md +++ b/docs/data-sources/managed_database_redis_sessions.md @@ -32,11 +32,11 @@ data "upcloud_managed_database_redis_sessions" "example" { ## Schema -### Required +### Required Attributes - `service` (String) Service's UUID for which these sessions belongs to -### Optional +### Optional Attributes - `limit` (Number) Number of entries to receive at most. - `offset` (Number) Offset for retrieved results based on sort order. @@ -69,5 +69,3 @@ Read-Only: - `query` (String) The last executed command. - `query_buffer` (Number) Query buffer length (0 means no query pending). - `query_buffer_free` (Number) Free space of the query buffer (0 means the buffer is full). - - diff --git a/docs/data-sources/managed_object_storage_policies.md b/docs/data-sources/managed_object_storage_policies.md index 9b8408eb9..5f9b4e72f 100644 --- a/docs/data-sources/managed_object_storage_policies.md +++ b/docs/data-sources/managed_object_storage_policies.md @@ -27,7 +27,7 @@ data "upcloud_Managed_object_storage_policies" "this" { ## Schema -### Required +### Required Attributes - `service_uuid` (String) Service UUID. @@ -51,5 +51,3 @@ Read-Only: - `service_uuid` (String) - `system` (Boolean) - `updated_at` (String) - - diff --git a/docs/data-sources/managed_object_storage_regions.md b/docs/data-sources/managed_object_storage_regions.md index 8af7e949d..939e77a52 100644 --- a/docs/data-sources/managed_object_storage_regions.md +++ b/docs/data-sources/managed_object_storage_regions.md @@ -22,15 +22,13 @@ data "upcloud_Managed_object_storage_regions" "this" {} ### Read-Only - `id` (String) The ID of this resource. -- `regions` (Set of Object) (see [below for nested schema](#nestedatt--regions)) +- `regions` (Block Set) (see [below for nested schema](#nestedblock--regions)) - + ### Nested Schema for `regions` Read-Only: -- `name` (String) -- `primary_zone` (String) -- `zones` (Set of String) - - +- `name` (String) Name of the region. +- `primary_zone` (String) Primary zone of the region. +- `zones` (Set of String) List of zones in the region. diff --git a/docs/data-sources/networks.md b/docs/data-sources/networks.md index 1794f8a0c..3ad76da82 100644 --- a/docs/data-sources/networks.md +++ b/docs/data-sources/networks.md @@ -30,7 +30,7 @@ data "upcloud_networks" "upcloud_by_zone" { ## Schema -### Optional +### Optional Attributes - `filter_name` (String) If specified, results will be filtered to match name using a regular expression - `zone` (String) If specified, this data source will return only networks from this zone @@ -73,5 +73,3 @@ Read-Only: - `id` (String) - `title` (String) - - diff --git a/docs/data-sources/storage.md b/docs/data-sources/storage.md index d33ab1001..9e7385714 100644 --- a/docs/data-sources/storage.md +++ b/docs/data-sources/storage.md @@ -65,11 +65,11 @@ resource "upcloud_server" "example2" { ## Schema -### Required +### Required Attributes - `type` (String) Storage type (normal, backup, cdrom, template). Use 'favorite' as type to filter storages on the list of favorites. -### Optional +### Optional Attributes - `access_type` (String) Storage access type (public, private) - `most_recent` (Boolean) If more than one result is returned, use the most recent storage. This is only useful with private storages. Public storages might give unpredictable results. @@ -84,5 +84,3 @@ resource "upcloud_server" "example2" { - `state` (String) Current state of the storage - `tier` (String) Storage tier in use - `title` (String) Title of the storage - - diff --git a/docs/data-sources/tags.md b/docs/data-sources/tags.md index f1208755e..104225214 100644 --- a/docs/data-sources/tags.md +++ b/docs/data-sources/tags.md @@ -28,5 +28,3 @@ Read-Only: - `description` (String) - `name` (String) - `servers` (Set of String) - - diff --git a/docs/data-sources/zone.md b/docs/data-sources/zone.md index 95d4946cc..96e77888b 100644 --- a/docs/data-sources/zone.md +++ b/docs/data-sources/zone.md @@ -15,7 +15,7 @@ Data-source is deprecated. ## Schema -### Required +### Required Attributes - `name` (String) Unique lablel for the zone @@ -24,5 +24,3 @@ Data-source is deprecated. - `description` (String) Meaningful text describing the zone - `id` (String) The ID of this resource. - `public` (Boolean) Indicates whether the zone is public - - diff --git a/docs/data-sources/zones.md b/docs/data-sources/zones.md index fa7dac8a5..c6c5b8498 100644 --- a/docs/data-sources/zones.md +++ b/docs/data-sources/zones.md @@ -15,7 +15,7 @@ Data-source is deprecated. ## Schema -### Optional +### Optional Attributes - `filter_type` (String) @@ -23,5 +23,3 @@ Data-source is deprecated. - `id` (String) The ID of this resource. - `zone_ids` (Set of String) - - diff --git a/docs/index.md b/docs/index.md index cf8795df1..c17e25bad 100644 --- a/docs/index.md +++ b/docs/index.md @@ -52,7 +52,7 @@ provider "upcloud" { ## Schema -### Optional +### Optional Attributes - `password` (String) Password for UpCloud API user. Can also be configured using the `UPCLOUD_PASSWORD` environment variable. - `request_timeout_sec` (Number) The duration (in seconds) that the provider waits for an HTTP request towards UpCloud API to complete. Defaults to 120 seconds diff --git a/docs/resources/firewall_rules.md b/docs/resources/firewall_rules.md index 2e0e13821..1e9200b22 100644 --- a/docs/resources/firewall_rules.md +++ b/docs/resources/firewall_rules.md @@ -4,10 +4,10 @@ page_title: "upcloud_firewall_rules Resource - terraform-provider-upcloud" subcategory: Servers description: |- This resource represents a generated list of UpCloud firewall rules. - Firewall rules are used in conjunction with UpCloud servers. - Each server has its own firewall rules. - The firewall is enabled on all network interfaces except ones attached to private virtual networks. - The maximum number of firewall rules per server is 1000. + Firewall rules are used in conjunction with UpCloud servers. + Each server has its own firewall rules. + The firewall is enabled on all network interfaces except ones attached to private virtual networks. + The maximum number of firewall rules per server is 1000. --- # upcloud_firewall_rules (Resource) @@ -61,7 +61,11 @@ resource "upcloud_firewall_rules" "example" { ## Schema -### Required +### Required Attributes + +- `server_id` (String) The unique id of the server to be protected the firewall rules + +### Blocks - `firewall_rule` (Block List, Min: 1, Max: 1000) A single firewall rule. If used, IP address and port ranges must have both start and end values specified. These can be the same value if only one IP address or port number is specified. @@ -69,7 +73,6 @@ resource "upcloud_firewall_rules" "example" { The ICMP type may only be set if the protocol is ICMP. Typical firewall rule should have "action", "direction", "protocol", "family" and at least one destination/source-address/port range. The default rule can be created by providing only "action" and "direction" attributes. Default rule should be defined last. (see [below for nested schema](#nestedblock--firewall_rule)) -- `server_id` (String) The unique id of the server to be protected the firewall rules ### Read-Only @@ -78,12 +81,12 @@ resource "upcloud_firewall_rules" "example" { ### Nested Schema for `firewall_rule` -Required: +Required Attributes: - `action` (String) Action to take if the rule conditions are met - `direction` (String) The direction of network traffic this rule will be applied to -Optional: +Optional Attributes: - `comment` (String) Freeform comment string for the rule - `destination_address_end` (String) The destination address range ends from this address diff --git a/docs/resources/floating_ip_address.md b/docs/resources/floating_ip_address.md index 2427cca86..7c6d07705 100644 --- a/docs/resources/floating_ip_address.md +++ b/docs/resources/floating_ip_address.md @@ -43,7 +43,7 @@ resource "upcloud_floating_ip_address" "my_new_floating_address" { ## Schema -### Optional +### Optional Attributes - `access` (String) Network access for the floating IP address. Supported value: `public` - `family` (String) The address family of new IP address diff --git a/docs/resources/gateway.md b/docs/resources/gateway.md index cbf20e2a9..9bddeabc4 100644 --- a/docs/resources/gateway.md +++ b/docs/resources/gateway.md @@ -56,20 +56,23 @@ resource "upcloud_gateway" "this" { ## Schema -### Required +### Required Attributes - `features` (Set of String) Features enabled for the gateway. Note that VPN feature is currently in beta, for more details see https://upcloud.com/resources/docs/networking#nat-and-vpn-gateways. - `name` (String) Gateway name. Needs to be unique within the account. -- `router` (Block List, Min: 1, Max: 1) Attached Router from where traffic is routed towards the network gateway service. (see [below for nested schema](#nestedblock--router)) - `zone` (String) Zone in which the gateway will be hosted, e.g. `de-fra1`. -### Optional +### Optional Attributes -- `address` (Block Set, Max: 1) IP addresses assigned to the gateway. (see [below for nested schema](#nestedblock--address)) - `configured_status` (String) The service configured status indicates the service's current intended status. Managed by the customer. - `labels` (Map of String) Key-value pairs to classify the network gateway. - `plan` (String) Gateway pricing plan. +### Blocks + +- `address` (Block Set, Max: 1) IP addresses assigned to the gateway. (see [below for nested schema](#nestedblock--address)) +- `router` (Block List, Min: 1, Max: 1) Attached Router from where traffic is routed towards the network gateway service. (see [below for nested schema](#nestedblock--router)) + ### Read-Only - `addresses` (Set of Object, Deprecated) IP addresses assigned to the gateway. (see [below for nested schema](#nestedatt--addresses)) @@ -77,18 +80,10 @@ resource "upcloud_gateway" "this" { - `id` (String) The ID of this resource. - `operational_state` (String) The service operational state indicates the service's current operational, effective state. Managed by the system. - -### Nested Schema for `router` - -Required: - -- `id` (String) ID of the router attached to the gateway. - - ### Nested Schema for `address` -Optional: +Optional Attributes: - `name` (String) Name of the IP address @@ -97,6 +92,14 @@ Read-Only: - `address` (String) IP addresss + +### Nested Schema for `router` + +Required Attributes: + +- `id` (String) ID of the router attached to the gateway. + + ### Nested Schema for `addresses` @@ -104,5 +107,3 @@ Read-Only: - `address` (String) - `name` (String) - - diff --git a/docs/resources/gateway_connection.md b/docs/resources/gateway_connection.md index e96d60221..52b31bb8a 100644 --- a/docs/resources/gateway_connection.md +++ b/docs/resources/gateway_connection.md @@ -73,16 +73,19 @@ resource "upcloud_gateway_connection" "this" { ## Schema -### Required +### Required Attributes - `gateway` (String) The ID of the upcloud_gateway resource to which the connection belongs. - `name` (String) The name of the connection, should be unique within the gateway. -### Optional +### Optional Attributes + +- `type` (String) The type of the connection; currently the only supported type is 'ipsec'. + +### Blocks - `local_route` (Block Set) Route for the UpCloud side of the network. (see [below for nested schema](#nestedblock--local_route)) - `remote_route` (Block Set) Route for the remote side of the network. (see [below for nested schema](#nestedblock--remote_route)) -- `type` (String) The type of the connection; currently the only supported type is 'ipsec'. ### Read-Only @@ -92,12 +95,12 @@ resource "upcloud_gateway_connection" "this" { ### Nested Schema for `local_route` -Required: +Required Attributes: - `name` (String) Name of the route - `static_network` (String) Destination prefix of the route; needs to be a valid IPv4 prefix -Optional: +Optional Attributes: - `type` (String) Type of route; currently the only supported type is 'static' @@ -105,13 +108,11 @@ Optional: ### Nested Schema for `remote_route` -Required: +Required Attributes: - `name` (String) Name of the route - `static_network` (String) Destination prefix of the route; needs to be a valid IPv4 prefix -Optional: +Optional Attributes: - `type` (String) Type of route; currently the only supported type is 'static' - - diff --git a/docs/resources/gateway_connection_tunnel.md b/docs/resources/gateway_connection_tunnel.md index 98272f607..de3eb4bc6 100644 --- a/docs/resources/gateway_connection_tunnel.md +++ b/docs/resources/gateway_connection_tunnel.md @@ -84,16 +84,16 @@ resource "upcloud_gateway_connection_tunnel" "this" { ## Schema -### Required +### Required Attributes - `connection_id` (String) ID of the upcloud_gateway_connection resource to which the tunnel belongs -- `ipsec_auth_psk` (Block List, Min: 1, Max: 1) Configuration for authenticating with pre-shared key (see [below for nested schema](#nestedblock--ipsec_auth_psk)) - `local_address_name` (String) Public (UpCloud) endpoint address of this tunnel - `name` (String) The name of the tunnel, should be unique within the connection - `remote_address` (String) Remote public IP address of the tunnel -### Optional +### Blocks +- `ipsec_auth_psk` (Block List, Min: 1, Max: 1) Configuration for authenticating with pre-shared key (see [below for nested schema](#nestedblock--ipsec_auth_psk)) - `ipsec_properties` (Block List, Max: 1) IPsec configuration for the tunnel (see [below for nested schema](#nestedblock--ipsec_properties)) ### Read-Only @@ -104,7 +104,7 @@ resource "upcloud_gateway_connection_tunnel" "this" { ### Nested Schema for `ipsec_auth_psk` -Required: +Required Attributes: - `psk` (String, Sensitive) The pre-shared key. This value is only used during resource creation and is not returned in the state. It is not possible to update this value. If you need to update it, delete the connection and create a new one. @@ -112,7 +112,7 @@ Required: ### Nested Schema for `ipsec_properties` -Optional: +Optional Attributes: - `child_rekey_time` (Number) IKE child SA rekey time in seconds. - `dpd_delay` (Number) Delay before sending Dead Peer Detection packets if no traffic is detected, in seconds. @@ -125,5 +125,3 @@ Optional: - `phase2_dh_group_numbers` (Set of Number) List of Phase 2 Diffie-Hellman group numbers. - `phase2_integrity_algorithms` (Set of String) List of Phase 2 integrity algorithms. - `rekey_time` (Number) IKE SA rekey time in seconds. - - diff --git a/docs/resources/kubernetes_cluster.md b/docs/resources/kubernetes_cluster.md index c9918d56c..034940ece 100644 --- a/docs/resources/kubernetes_cluster.md +++ b/docs/resources/kubernetes_cluster.md @@ -78,14 +78,14 @@ resource "upcloud_kubernetes_cluster" "example2" { ## Schema -### Required +### Required Attributes - `control_plane_ip_filter` (Set of String) IP addresses or IP ranges in CIDR format which are allowed to access the cluster control plane. To allow access from any source, use `["0.0.0.0/0"]`. To deny access from all sources, use `[]`. Values set here do not restrict access to node groups or exposed Kubernetes services. - `name` (String) Cluster name. Needs to be unique within the account. - `network` (String) Network ID for the cluster to run in. - `zone` (String) Zone in which the Kubernetes cluster will be hosted, e.g. `de-fra1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes - `labels` (Map of String) Key-value pairs to classify the cluster. - `plan` (String) The pricing plan used for the cluster. Default plan is `development`. You can list available plans with `upctl kubernetes plans`. @@ -98,5 +98,3 @@ resource "upcloud_kubernetes_cluster" "example2" { - `network_cidr` (String) Network CIDR for the given network. Computed automatically. - `node_groups` (List of String) Names of the node groups configured to cluster - `state` (String) Operational state of the cluster. - - diff --git a/docs/resources/kubernetes_node_group.md b/docs/resources/kubernetes_node_group.md index 8c82ab943..6a0ed4768 100644 --- a/docs/resources/kubernetes_node_group.md +++ b/docs/resources/kubernetes_node_group.md @@ -61,23 +61,26 @@ resource "upcloud_kubernetes_node_group" "group" { ## Schema -### Required +### Required Attributes - `cluster` (String) Cluster ID. - `name` (String) The name of the node group. Needs to be unique within a cluster. - `node_count` (Number) Amount of nodes to provision in the node group. - `plan` (String) The server plan used for the node group. You can list available plans with `upctl server plans` -### Optional +### Optional Attributes - `anti_affinity` (Boolean) If set to true, nodes in this group will be placed on separate compute hosts. Please note that anti-affinity policy is considered "best effort" and enabling it does not fully guarantee that the nodes will end up on different hardware. -- `kubelet_args` (Block Set) Additional arguments for kubelet for the nodes in this group. WARNING - those arguments will be passed directly to kubelet CLI on each worker node without any validation. Passing invalid arguments can break your whole cluster. Be extra careful when adding kubelet args. (see [below for nested schema](#nestedblock--kubelet_args)) - `labels` (Map of String) Key-value pairs to classify the node group. - `ssh_keys` (Set of String) You can optionally select SSH keys to be added as authorized keys to the nodes in this node group. This allows you to connect to the nodes via SSH once they are running. -- `taint` (Block Set) Taints for the nodes in this group. (see [below for nested schema](#nestedblock--taint)) - `utility_network_access` (Boolean) If set to false, nodes in this group will not have access to utility network. +### Blocks + +- `kubelet_args` (Block Set) Additional arguments for kubelet for the nodes in this group. WARNING - those arguments will be passed directly to kubelet CLI on each worker node without any validation. Passing invalid arguments can break your whole cluster. Be extra careful when adding kubelet args. (see [below for nested schema](#nestedblock--kubelet_args)) +- `taint` (Block Set) Taints for the nodes in this group. (see [below for nested schema](#nestedblock--taint)) + ### Read-Only - `id` (String) The ID of this resource. @@ -85,7 +88,7 @@ resource "upcloud_kubernetes_node_group" "group" { ### Nested Schema for `kubelet_args` -Required: +Required Attributes: - `key` (String) Kubelet argument key. - `value` (String) Kubelet argument value. @@ -94,10 +97,8 @@ Required: ### Nested Schema for `taint` -Required: +Required Attributes: - `effect` (String) Taint effect. - `key` (String) Taint key. - `value` (String) Taint value. - - diff --git a/docs/resources/loadbalancer.md b/docs/resources/loadbalancer.md index 8061e02a1..1f6878a71 100644 --- a/docs/resources/loadbalancer.md +++ b/docs/resources/loadbalancer.md @@ -50,19 +50,22 @@ resource "upcloud_loadbalancer" "lb" { ## Schema -### Required +### Required Attributes - `name` (String) The name of the service must be unique within customer account. - `plan` (String) Plan which the service will have. You can list available load balancer plans with `upctl loadbalancer plans` - `zone` (String) Zone in which the service will be hosted, e.g. `fi-hel1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes - `configured_status` (String) The service configured status indicates the service's current intended status. Managed by the customer. - `labels` (Map of String) Key-value pairs to classify the load balancer. - `maintenance_dow` (String) The day of the week on which maintenance will be performed. If not provided, we will randomly select a weekend day. Valid values `monday|tuesday|wednesday|thursday|friday|saturday|sunday`. - `maintenance_time` (String) The time at which the maintenance will begin in UTC. A 2-hour timeframe has been allocated for maintenance. During this period, the multi-node production plans will not experience any downtime, while the one-node plans will have a downtime of 1-2 minutes. If not provided, we will randomly select an off-peak time. Needs to be a valid time format in UTC HH:MM:SSZ, for example `20:01:01Z`. - `network` (String, Deprecated) Private network UUID where traffic will be routed. Must reside in load balancer zone. + +### Blocks + - `networks` (Block List, Max: 8) Attached Networks from where traffic consumed and routed. Private networks must reside in loadbalancer zone. (see [below for nested schema](#nestedblock--networks)) ### Read-Only @@ -78,13 +81,13 @@ resource "upcloud_loadbalancer" "lb" { ### Nested Schema for `networks` -Required: +Required Attributes: - `family` (String) Network family. Currently only `IPv4` is supported. - `name` (String) The name of the network must be unique within the service. - `type` (String) The type of the network. Only one public network can be attached and at least one private network must be attached. -Optional: +Optional Attributes: - `network` (String) Private network UUID. Required for private networks and must reside in loadbalancer zone. For public network the field should be omitted. @@ -118,5 +121,3 @@ Read-Only: - `address` (String) - `listen` (Boolean) - - diff --git a/docs/resources/loadbalancer_backend.md b/docs/resources/loadbalancer_backend.md index 9d560de0e..d38f47ca6 100644 --- a/docs/resources/loadbalancer_backend.md +++ b/docs/resources/loadbalancer_backend.md @@ -45,16 +45,19 @@ resource "upcloud_loadbalancer_backend" "lb_be_1" { ## Schema -### Required +### Required Attributes - `loadbalancer` (String) ID of the load balancer to which the backend is connected. - `name` (String) The name of the backend must be unique within the load balancer service. -### Optional +### Optional Attributes -- `properties` (Block List, Max: 1) Backend properties. Properties can set back to defaults by defining empty `properties {}` block. (see [below for nested schema](#nestedblock--properties)) - `resolver_name` (String) Domain Name Resolver used with dynamic type members. +### Blocks + +- `properties` (Block List, Max: 1) Backend properties. Properties can set back to defaults by defining empty `properties {}` block. (see [below for nested schema](#nestedblock--properties)) + ### Read-Only - `id` (String) The ID of this resource. @@ -64,7 +67,7 @@ resource "upcloud_loadbalancer_backend" "lb_be_1" { ### Nested Schema for `properties` -Optional: +Optional Attributes: - `health_check_expected_status` (Number) Expected HTTP status code returned by the customer application to mark server as healthy. Ignored for tcp type. - `health_check_fall` (Number) Sets how many failed health checks are allowed until the backend member is taken off from the rotation. @@ -85,5 +88,3 @@ Optional: Read-Only: - `tls_configs` (List of String) Set of TLS config names - - diff --git a/docs/resources/loadbalancer_backend_tls_config.md b/docs/resources/loadbalancer_backend_tls_config.md index 925c942c8..e8315125f 100644 --- a/docs/resources/loadbalancer_backend_tls_config.md +++ b/docs/resources/loadbalancer_backend_tls_config.md @@ -15,7 +15,7 @@ This resource represents backend TLS config ## Schema -### Required +### Required Attributes - `backend` (String) ID of the load balancer backend to which the TLS config is connected. - `certificate_bundle` (String) Reference to certificate bundle ID. @@ -24,5 +24,3 @@ This resource represents backend TLS config ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/docs/resources/loadbalancer_dynamic_backend_member.md b/docs/resources/loadbalancer_dynamic_backend_member.md index dc000d76e..0de8b890d 100644 --- a/docs/resources/loadbalancer_dynamic_backend_member.md +++ b/docs/resources/loadbalancer_dynamic_backend_member.md @@ -65,7 +65,7 @@ resource "upcloud_loadbalancer_dynamic_backend_member" "lb_be_1_dm_1" { ## Schema -### Required +### Required Attributes - `backend` (String) ID of the load balancer backend to which the member is connected. - `max_sessions` (Number) Maximum number of sessions before queueing. @@ -74,7 +74,7 @@ resource "upcloud_loadbalancer_dynamic_backend_member" "lb_be_1_dm_1" { All servers will receive a load proportional to their weight relative to the sum of all weights, so the higher the weight, the higher the load. A value of 0 means the server will not participate in load balancing but will still accept persistent connections. -### Optional +### Optional Attributes - `enabled` (Boolean) Indicates if the member is enabled. Disabled members are excluded from load balancing. - `ip` (String) Optional fallback IP address in case of failure on DNS resolving. @@ -83,5 +83,3 @@ resource "upcloud_loadbalancer_dynamic_backend_member" "lb_be_1_dm_1" { ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/docs/resources/loadbalancer_dynamic_certificate_bundle.md b/docs/resources/loadbalancer_dynamic_certificate_bundle.md index fa5561730..095aea444 100644 --- a/docs/resources/loadbalancer_dynamic_certificate_bundle.md +++ b/docs/resources/loadbalancer_dynamic_certificate_bundle.md @@ -26,7 +26,7 @@ resource "upcloud_loadbalancer_dynamic_certificate_bundle" "lb_cb_d1" { ## Schema -### Required +### Required Attributes - `hostnames` (List of String) Certificate hostnames. - `key_type` (String) Private key type (`rsa` / `ecdsa`). @@ -38,5 +38,3 @@ resource "upcloud_loadbalancer_dynamic_certificate_bundle" "lb_cb_d1" { - `not_after` (String) The time after which a certificate is no longer valid. - `not_before` (String) The time on which a certificate becomes valid. - `operational_state` (String) The service operational state indicates the service's current operational, effective state. Managed by the system. - - diff --git a/docs/resources/loadbalancer_frontend.md b/docs/resources/loadbalancer_frontend.md index a8adf187d..25801bc29 100644 --- a/docs/resources/loadbalancer_frontend.md +++ b/docs/resources/loadbalancer_frontend.md @@ -66,7 +66,7 @@ resource "upcloud_loadbalancer_backend" "lb_be_1" { ## Schema -### Required +### Required Attributes - `default_backend_name` (String) The name of the default backend where traffic will be routed. Note, default backend can be overwritten in frontend rules. - `loadbalancer` (String) ID of the load balancer to which the frontend is connected. @@ -74,7 +74,7 @@ resource "upcloud_loadbalancer_backend" "lb_be_1" { - `name` (String) The name of the frontend must be unique within the load balancer service. - `port` (Number) Port to listen incoming requests -### Optional +### Blocks - `networks` (Block List) Networks that frontend will be listening. Networks are required if load balancer has `networks` defined. This field will be required when deprecated field `network` is removed from load balancer resource. (see [below for nested schema](#nestedblock--networks)) - `properties` (Block List, Max: 1) Frontend properties. Properties can set back to defaults by defining empty `properties {}` block. (see [below for nested schema](#nestedblock--properties)) @@ -88,7 +88,7 @@ resource "upcloud_loadbalancer_backend" "lb_be_1" { ### Nested Schema for `networks` -Required: +Required Attributes: - `name` (String) Name of the load balancer network @@ -96,10 +96,8 @@ Required: ### Nested Schema for `properties` -Optional: +Optional Attributes: - `http2_enabled` (Boolean) Enable or disable HTTP/2 support. - `inbound_proxy_protocol` (Boolean) Enable or disable inbound proxy protocol support. - `timeout_client` (Number) Client request timeout in seconds. - - diff --git a/docs/resources/loadbalancer_frontend_rule.md b/docs/resources/loadbalancer_frontend_rule.md index ef980f429..c631d894e 100644 --- a/docs/resources/loadbalancer_frontend_rule.md +++ b/docs/resources/loadbalancer_frontend_rule.md @@ -71,13 +71,13 @@ resource "upcloud_loadbalancer_backend" "lb_be_1" { ## Schema -### Required +### Required Attributes - `frontend` (String) ID of the load balancer frontend to which the rule is connected. - `name` (String) The name of the frontend rule must be unique within the load balancer service. - `priority` (Number) Rule with the higher priority goes first. Rules with the same priority processed in alphabetical order. -### Optional +### Blocks - `actions` (Block List, Max: 1) Set of rule actions. (see [below for nested schema](#nestedblock--actions)) - `matchers` (Block List, Max: 1) Set of rule matchers. if rule doesn't have matchers, then action applies to all incoming requests. (see [below for nested schema](#nestedblock--matchers)) @@ -89,7 +89,7 @@ resource "upcloud_loadbalancer_backend" "lb_be_1" { ### Nested Schema for `actions` -Optional: +Blocks: - `http_redirect` (Block List, Max: 100) Redirects HTTP requests to specified location or URL scheme. Only either location or scheme can be defined at a time. (see [below for nested schema](#nestedblock--actions--http_redirect)) - `http_return` (Block List, Max: 100) Returns HTTP response with specified HTTP status. (see [below for nested schema](#nestedblock--actions--http_return)) @@ -100,7 +100,7 @@ Optional: ### Nested Schema for `actions.http_redirect` -Optional: +Optional Attributes: - `location` (String) Target location. - `scheme` (String) Target scheme. @@ -109,7 +109,7 @@ Optional: ### Nested Schema for `actions.http_return` -Required: +Required Attributes: - `content_type` (String) Content type. - `payload` (String) The payload. @@ -119,7 +119,7 @@ Required: ### Nested Schema for `actions.set_forwarded_headers` -Optional: +Optional Attributes: - `active` (Boolean) @@ -127,7 +127,7 @@ Optional: ### Nested Schema for `actions.tcp_reject` -Optional: +Optional Attributes: - `active` (Boolean) @@ -135,7 +135,7 @@ Optional: ### Nested Schema for `actions.use_backend` -Required: +Required Attributes: - `backend_name` (String) The name of the backend where traffic will be routed. @@ -144,7 +144,7 @@ Required: ### Nested Schema for `matchers` -Optional: +Blocks: - `body_size` (Block List, Max: 100) Matches by HTTP request body size. (see [below for nested schema](#nestedblock--matchers--body_size)) - `body_size_range` (Block List, Max: 100) Matches by range of HTTP request body sizes (see [below for nested schema](#nestedblock--matchers--body_size_range)) @@ -164,12 +164,12 @@ Optional: ### Nested Schema for `matchers.body_size` -Required: +Required Attributes: - `method` (String) Match method (`equal`, `greater`, `greater_or_equal`, `less`, `less_or_equal`). - `value` (Number) Integer value. -Optional: +Optional Attributes: - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -177,12 +177,12 @@ Optional: ### Nested Schema for `matchers.body_size_range` -Required: +Required Attributes: - `range_end` (Number) Integer value. - `range_start` (Number) Integer value. -Optional: +Optional Attributes: - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -190,12 +190,12 @@ Optional: ### Nested Schema for `matchers.cookie` -Required: +Required Attributes: - `method` (String) Match method (`exact`, `substring`, `regexp`, `starts`, `ends`, `domain`, `ip`, `exists`). Matcher with `exists` and `ip` methods must be used without `value` and `ignore_case` fields. - `name` (String) Name of the argument. -Optional: +Optional Attributes: - `ignore_case` (Boolean) Ignore case, default `false`. - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -205,12 +205,12 @@ Optional: ### Nested Schema for `matchers.header` -Required: +Required Attributes: - `method` (String) Match method (`exact`, `substring`, `regexp`, `starts`, `ends`, `domain`, `ip`, `exists`). Matcher with `exists` and `ip` methods must be used without `value` and `ignore_case` fields. - `name` (String) Name of the argument. -Optional: +Optional Attributes: - `ignore_case` (Boolean) Ignore case, default `false`. - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -220,11 +220,11 @@ Optional: ### Nested Schema for `matchers.host` -Required: +Required Attributes: - `value` (String) String value. -Optional: +Optional Attributes: - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -232,11 +232,11 @@ Optional: ### Nested Schema for `matchers.http_method` -Required: +Required Attributes: - `value` (String) String value (`GET`, `HEAD`, `POST`, `PUT`, `PATCH`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`). -Optional: +Optional Attributes: - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -244,13 +244,13 @@ Optional: ### Nested Schema for `matchers.num_members_up` -Required: +Required Attributes: - `backend_name` (String) The name of the `backend` which members will be monitored. - `method` (String) Match method (`equal`, `greater`, `greater_or_equal`, `less`, `less_or_equal`). - `value` (Number) Integer value. -Optional: +Optional Attributes: - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -258,11 +258,11 @@ Optional: ### Nested Schema for `matchers.path` -Required: +Required Attributes: - `method` (String) Match method (`exact`, `substring`, `regexp`, `starts`, `ends`, `domain`, `ip`, `exists`). Matcher with `exists` and `ip` methods must be used without `value` and `ignore_case` fields. -Optional: +Optional Attributes: - `ignore_case` (Boolean) Ignore case, default `false`. - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -272,11 +272,11 @@ Optional: ### Nested Schema for `matchers.src_ip` -Required: +Required Attributes: - `value` (String) IP address. CIDR masks are supported, e.g. `192.168.0.0/24`. -Optional: +Optional Attributes: - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -284,12 +284,12 @@ Optional: ### Nested Schema for `matchers.src_port` -Required: +Required Attributes: - `method` (String) Match method (`equal`, `greater`, `greater_or_equal`, `less`, `less_or_equal`). - `value` (Number) Integer value. -Optional: +Optional Attributes: - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -297,12 +297,12 @@ Optional: ### Nested Schema for `matchers.src_port_range` -Required: +Required Attributes: - `range_end` (Number) Integer value. - `range_start` (Number) Integer value. -Optional: +Optional Attributes: - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -310,11 +310,11 @@ Optional: ### Nested Schema for `matchers.url` -Required: +Required Attributes: - `method` (String) Match method (`exact`, `substring`, `regexp`, `starts`, `ends`, `domain`, `ip`, `exists`). Matcher with `exists` and `ip` methods must be used without `value` and `ignore_case` fields. -Optional: +Optional Attributes: - `ignore_case` (Boolean) Ignore case, default `false`. - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -324,12 +324,12 @@ Optional: ### Nested Schema for `matchers.url_param` -Required: +Required Attributes: - `method` (String) Match method (`exact`, `substring`, `regexp`, `starts`, `ends`, `domain`, `ip`, `exists`). Matcher with `exists` and `ip` methods must be used without `value` and `ignore_case` fields. - `name` (String) Name of the argument. -Optional: +Optional Attributes: - `ignore_case` (Boolean) Ignore case, default `false`. - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. @@ -339,14 +339,12 @@ Optional: ### Nested Schema for `matchers.url_query` -Required: +Required Attributes: - `method` (String) Match method (`exact`, `substring`, `regexp`, `starts`, `ends`, `domain`, `ip`, `exists`). Matcher with `exists` and `ip` methods must be used without `value` and `ignore_case` fields. -Optional: +Optional Attributes: - `ignore_case` (Boolean) Ignore case, default `false`. - `inverse` (Boolean) Sets if the condition should be inverted. Works similar to logical NOT operator. - `value` (String) String value. - - diff --git a/docs/resources/loadbalancer_frontend_tls_config.md b/docs/resources/loadbalancer_frontend_tls_config.md index 130db31e6..8f6f282c2 100644 --- a/docs/resources/loadbalancer_frontend_tls_config.md +++ b/docs/resources/loadbalancer_frontend_tls_config.md @@ -65,7 +65,7 @@ resource "upcloud_loadbalancer_backend" "lb_be_1" { ## Schema -### Required +### Required Attributes - `certificate_bundle` (String) Reference to certificate bundle ID. - `frontend` (String) ID of the load balancer frontend to which the TLS config is connected. @@ -74,5 +74,3 @@ resource "upcloud_loadbalancer_backend" "lb_be_1" { ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/docs/resources/loadbalancer_manual_certificate_bundle.md b/docs/resources/loadbalancer_manual_certificate_bundle.md index 5bb4afaaa..77e593f85 100644 --- a/docs/resources/loadbalancer_manual_certificate_bundle.md +++ b/docs/resources/loadbalancer_manual_certificate_bundle.md @@ -31,13 +31,13 @@ resource "upcloud_loadbalancer_manual_certificate_bundle" "lb_cb_m1" { ## Schema -### Required +### Required Attributes - `certificate` (String) Certificate within base64 string must be in PEM format. - `name` (String) The name of the bundle must be unique within customer account. - `private_key` (String, Sensitive) Private key within base64 string must be in PEM format. -### Optional +### Optional Attributes - `intermediates` (String) Intermediate certificates within base64 string must be in PEM format. @@ -47,5 +47,3 @@ resource "upcloud_loadbalancer_manual_certificate_bundle" "lb_cb_m1" { - `not_after` (String) The time after which a certificate is no longer valid. - `not_before` (String) The time on which a certificate becomes valid. - `operational_state` (String) The service operational state indicates the service's current operational, effective state. Managed by the system. - - diff --git a/docs/resources/loadbalancer_resolver.md b/docs/resources/loadbalancer_resolver.md index 04fba824d..7faae466a 100644 --- a/docs/resources/loadbalancer_resolver.md +++ b/docs/resources/loadbalancer_resolver.md @@ -51,7 +51,7 @@ resource "upcloud_loadbalancer_resolver" "lb_resolver_1" { ## Schema -### Required +### Required Attributes - `cache_invalid` (Number) Time in seconds to cache invalid results. - `cache_valid` (Number) Time in seconds to cache valid results. @@ -66,5 +66,3 @@ resource "upcloud_loadbalancer_resolver" "lb_resolver_1" { ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/docs/resources/loadbalancer_static_backend_member.md b/docs/resources/loadbalancer_static_backend_member.md index dd55969cd..700315df9 100644 --- a/docs/resources/loadbalancer_static_backend_member.md +++ b/docs/resources/loadbalancer_static_backend_member.md @@ -55,7 +55,7 @@ resource "upcloud_loadbalancer_static_backend_member" "lb_be_1_sm_1" { ## Schema -### Required +### Required Attributes - `backend` (String) ID of the load balancer backend to which the member is connected. - `ip` (String) Server IP address in the customer private network. @@ -66,12 +66,10 @@ resource "upcloud_loadbalancer_static_backend_member" "lb_be_1_sm_1" { All servers will receive a load proportional to their weight relative to the sum of all weights, so the higher the weight, the higher the load. A value of 0 means the server will not participate in load balancing but will still accept persistent connections. -### Optional +### Optional Attributes - `enabled` (Boolean) Indicates if the member is enabled. Disabled members are excluded from load balancing. ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/docs/resources/managed_database_logical_database.md b/docs/resources/managed_database_logical_database.md index b40666189..6b5468245 100644 --- a/docs/resources/managed_database_logical_database.md +++ b/docs/resources/managed_database_logical_database.md @@ -43,12 +43,12 @@ resource "upcloud_managed_database_logical_database" "example2_db" { ## Schema -### Required +### Required Attributes - `name` (String) Name of the logical database - `service` (String) Service's UUID for which this user belongs to -### Optional +### Optional Attributes - `character_set` (String) Default character set for the database (LC_CTYPE) - `collation` (String) Default collation for the database (LC_COLLATE) @@ -56,5 +56,3 @@ resource "upcloud_managed_database_logical_database" "example2_db" { ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/docs/resources/managed_database_mysql.md b/docs/resources/managed_database_mysql.md index 66017ffac..a04c51fe9 100644 --- a/docs/resources/managed_database_mysql.md +++ b/docs/resources/managed_database_mysql.md @@ -51,19 +51,22 @@ resource "upcloud_managed_database_mysql" "example_3" { ## Schema -### Required +### Required Attributes - `name` (String) Name of the service. The name is used as a prefix for the logical hostname. Must be unique within an account - `plan` (String) Service plan to use. This determines how much resources the instance will have. You can list available plans with `upctl database plans `. - `title` (String) Title of a managed database instance - `zone` (String) Zone where the instance resides, e.g. `de-fra1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes - `maintenance_window_dow` (String) Maintenance window day of week. Lower case weekday name (monday, tuesday, ...) - `maintenance_window_time` (String) Maintenance window UTC time in hh:mm:ss format -- `network` (Block Set, Max: 8) Private networks attached to the managed database (see [below for nested schema](#nestedblock--network)) - `powered` (Boolean) The administrative power state of the service + +### Blocks + +- `network` (Block Set, Max: 8) Private networks attached to the managed database (see [below for nested schema](#nestedblock--network)) - `properties` (Block List, Max: 1) Database Engine properties for MySQL (see [below for nested schema](#nestedblock--properties)) ### Read-Only @@ -83,7 +86,7 @@ resource "upcloud_managed_database_mysql" "example_3" { ### Nested Schema for `network` -Required: +Required Attributes: - `family` (String) Network family. Currently only `IPv4` is supported. - `name` (String) The name of the network. Must be unique within the service. @@ -94,7 +97,7 @@ Required: ### Nested Schema for `properties` -Optional: +Optional Attributes: - `admin_password` (String, Sensitive) Custom password for admin user. Defaults to random string. This must be set only when a new service is being created. - `admin_username` (String) Custom username for admin user. This must be set only when a new service is being created. @@ -124,7 +127,6 @@ Optional: - `long_query_time` (Number) The slow_query_logs work as SQL statements that take more than long_query_time seconds to execute. Default is 10s. - `max_allowed_packet` (Number) Size of the largest message in bytes that can be received by the server. Default is 67108864 (64M). - `max_heap_table_size` (Number) Limits the size of internal in-memory tables. Also set tmp_table_size. Default is 16777216 (16M). -- `migration` (Block List, Max: 1) Migrate data from existing server. (see [below for nested schema](#nestedblock--properties--migration)) - `net_buffer_length` (Number) Start sizes of connection buffer and result buffer. Default is 16384 (16K). Changing this parameter will lead to a restart of the MySQL service. - `net_read_timeout` (Number) The number of seconds to wait for more data from a connection before aborting the read. - `net_write_timeout` (Number) The number of seconds to wait for a block to be written to a connection before aborting the write. @@ -138,10 +140,14 @@ Optional: - `version` (String) MySQL major version. - `wait_timeout` (Number) The number of seconds the server waits for activity on a noninteractive connection before closing it. +Blocks: + +- `migration` (Block List, Max: 1) Migrate data from existing server. (see [below for nested schema](#nestedblock--properties--migration)) + ### Nested Schema for `properties.migration` -Optional: +Optional Attributes: - `dbname` (String) Database name for bootstrapping the initial connection. - `host` (String) Hostname or IP address of the server where to migrate data from. @@ -174,5 +180,3 @@ Read-Only: - `name` (String) - `role` (String) - `state` (String) - - diff --git a/docs/resources/managed_database_opensearch.md b/docs/resources/managed_database_opensearch.md index c47746ba9..425853e58 100644 --- a/docs/resources/managed_database_opensearch.md +++ b/docs/resources/managed_database_opensearch.md @@ -38,21 +38,24 @@ resource "upcloud_managed_database_opensearch" "example_2" { ## Schema -### Required +### Required Attributes - `name` (String) Name of the service. The name is used as a prefix for the logical hostname. Must be unique within an account - `plan` (String) Service plan to use. This determines how much resources the instance will have. You can list available plans with `upctl database plans `. - `title` (String) Title of a managed database instance - `zone` (String) Zone where the instance resides, e.g. `de-fra1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes - `access_control` (Boolean) Enables users access control for OpenSearch service. User access control rules will only be enforced if this attribute is enabled. - `extended_access_control` (Boolean) Grant access to top-level `_mget`, `_msearch` and `_bulk` APIs. Users are limited to perform operations on indices based on the user-specific access control rules. - `maintenance_window_dow` (String) Maintenance window day of week. Lower case weekday name (monday, tuesday, ...) - `maintenance_window_time` (String) Maintenance window UTC time in hh:mm:ss format -- `network` (Block Set, Max: 8) Private networks attached to the managed database (see [below for nested schema](#nestedblock--network)) - `powered` (Boolean) The administrative power state of the service + +### Blocks + +- `network` (Block Set, Max: 8) Private networks attached to the managed database (see [below for nested schema](#nestedblock--network)) - `properties` (Block List, Max: 1) Database Engine properties for OpenSearch (see [below for nested schema](#nestedblock--properties)) ### Read-Only @@ -72,7 +75,7 @@ resource "upcloud_managed_database_opensearch" "example_2" { ### Nested Schema for `network` -Required: +Required Attributes: - `family` (String) Network family. Currently only `IPv4` is supported. - `name` (String) The name of the network. Must be unique within the service. @@ -83,11 +86,10 @@ Required: ### Nested Schema for `properties` -Optional: +Optional Attributes: - `action_auto_create_index_enabled` (Boolean) action.auto_create_index. Explicitly allow or block automatic creation of indices. Defaults to true. - `action_destructive_requires_name` (Boolean) Require explicit index names when deleting. -- `auth_failure_listeners` (Block List, Max: 1) Opensearch Security Plugin Settings. (see [below for nested schema](#nestedblock--properties--auth_failure_listeners)) - `automatic_utility_network_ip_filter` (Boolean) Automatic utility network IP Filter. Automatically allow connections from servers in the utility network within the same zone. - `cluster_max_shards_per_node` (Number) Controls the number of shards allowed in the cluster per data node. - `cluster_routing_allocation_node_concurrent_recoveries` (Number) Concurrent incoming/outgoing shard recoveries per node. How many concurrent incoming/outgoing shard recoveries (normally replicas) are allowed to happen on a node. Defaults to 2. @@ -100,7 +102,6 @@ Optional: - `http_max_header_size` (Number) The max size of allowed headers, in bytes. - `http_max_initial_line_length` (Number) The max length of an HTTP URL, in bytes. - `index_patterns` (List of String) Index patterns. -- `index_template` (Block List, Max: 1) Template settings for all new indexes. (see [below for nested schema](#nestedblock--properties--index_template)) - `indices_fielddata_cache_size` (Number) Relative amount. Maximum amount of heap memory used for field data cache. This is an expert setting; decreasing the value too much will increase overhead of loading field data; too much memory used for field data cache will decrease amount of heap available for other operations. - `indices_memory_index_buffer_size` (Number) Percentage value. Default is 10%. Total amount of heap used for indexing buffer, before writing segments to disk. This is an expert setting. Too low value will slow down indexing; too high value will increase indexing performance but causes performance issues for query performance. - `indices_memory_max_index_buffer_size` (Number) Absolute value. Default is unbound. Doesn't work without indices.memory.index_buffer_size. Maximum amount of heap used for query cache, an absolute indices.memory.index_buffer_size maximum hard limit. @@ -118,13 +119,10 @@ Optional: - `ism_history_rollover_retention_period` (Number) How long audit history indices are kept in days. - `keep_index_refresh_interval` (Boolean) Don't reset index.refresh_interval to the default value. Aiven automation resets index.refresh_interval to default value for every index to be sure that indices are always visible to search. If it doesn't fit your case, you can disable this by setting up this flag to true. - `max_index_count` (Number) Maximum index count. DEPRECATED: use index_patterns instead. -- `openid` (Block List, Max: 1) OpenSearch OpenID Connect Configuration. (see [below for nested schema](#nestedblock--properties--openid)) -- `opensearch_dashboards` (Block List, Max: 1) OpenSearch Dashboards settings. (see [below for nested schema](#nestedblock--properties--opensearch_dashboards)) - `override_main_response_version` (Boolean) Compatibility mode sets OpenSearch to report its version as 7.10 so clients continue to work. Default is false. - `plugins_alerting_filter_by_backend_roles` (Boolean) Enable or disable filtering of alerting by backend roles. Requires Security plugin. Defaults to false. - `public_access` (Boolean) Public Access. Allow access to the service from the public Internet. - `reindex_remote_whitelist` (List of String) Whitelisted addresses for reindexing. Changing this value will cause all OpenSearch instances to restart. -- `saml` (Block List, Max: 1) OpenSearch SAML configuration. (see [below for nested schema](#nestedblock--properties--saml)) - `script_max_compilations_rate` (String) Script max compilation rate - circuit breaker to prevent/minimize OOMs. Script compilation circuit breaker limits the number of inline script compilations within a period of time. Default is use-context. - `search_max_buckets` (Number) Maximum number of aggregation buckets allowed in a single response. OpenSearch default value is used when this is not defined. - `service_log` (Boolean) Service logging. Store logs for the service so that they are available in the HTTP API and console. @@ -141,10 +139,18 @@ Optional: - `thread_pool_write_size` (Number) write thread pool size. Size for the thread pool. See documentation for exact details. Do note this may have maximum value depending on CPU count - value is automatically lowered if set to higher than maximum value. - `version` (String) OpenSearch major version. +Blocks: + +- `auth_failure_listeners` (Block List, Max: 1) Opensearch Security Plugin Settings. (see [below for nested schema](#nestedblock--properties--auth_failure_listeners)) +- `index_template` (Block List, Max: 1) Template settings for all new indexes. (see [below for nested schema](#nestedblock--properties--index_template)) +- `openid` (Block List, Max: 1) OpenSearch OpenID Connect Configuration. (see [below for nested schema](#nestedblock--properties--openid)) +- `opensearch_dashboards` (Block List, Max: 1) OpenSearch Dashboards settings. (see [below for nested schema](#nestedblock--properties--opensearch_dashboards)) +- `saml` (Block List, Max: 1) OpenSearch SAML configuration. (see [below for nested schema](#nestedblock--properties--saml)) + ### Nested Schema for `properties.auth_failure_listeners` -Optional: +Blocks: - `internal_authentication_backend_limiting` (Block List, Max: 1) (see [below for nested schema](#nestedblock--properties--auth_failure_listeners--internal_authentication_backend_limiting)) - `ip_rate_limiting` (Block List, Max: 1) IP address rate limiting settings. (see [below for nested schema](#nestedblock--properties--auth_failure_listeners--ip_rate_limiting)) @@ -152,7 +158,7 @@ Optional: ### Nested Schema for `properties.auth_failure_listeners.internal_authentication_backend_limiting` -Optional: +Optional Attributes: - `allowed_tries` (Number) The number of login attempts allowed before login is blocked. - `authentication_backend` (String) The internal backend. Enter `internal`. @@ -166,7 +172,7 @@ Optional: ### Nested Schema for `properties.auth_failure_listeners.ip_rate_limiting` -Optional: +Optional Attributes: - `allowed_tries` (Number) The number of login attempts allowed before login is blocked. - `block_expiry_seconds` (Number) The duration of time that login remains blocked after a failed login. @@ -180,7 +186,7 @@ Optional: ### Nested Schema for `properties.index_template` -Optional: +Optional Attributes: - `mapping_nested_objects_limit` (Number) index.mapping.nested_objects.limit. The maximum number of nested JSON objects that a single document can contain across all nested types. This limit helps to prevent out of memory errors when a document contains too many nested objects. Default is 10000. - `number_of_replicas` (Number) The number of replicas each primary shard has. @@ -190,7 +196,7 @@ Optional: ### Nested Schema for `properties.openid` -Optional: +Optional Attributes: - `client_id` (String) The ID of the OpenID Connect client. The ID of the OpenID Connect client configured in your IdP. Required. - `client_secret` (String) The client secret of the OpenID Connect. The client secret of the OpenID Connect client configured in your IdP. Required. @@ -209,7 +215,7 @@ Optional: ### Nested Schema for `properties.opensearch_dashboards` -Optional: +Optional Attributes: - `enabled` (Boolean) Enable or disable OpenSearch Dashboards. - `max_old_space_size` (Number) Limits the maximum amount of memory (in MiB) the OpenSearch Dashboards process can use. This sets the max_old_space_size option of the nodejs running the OpenSearch Dashboards. Note: the memory reserved by OpenSearch Dashboards is not available for OpenSearch. @@ -219,7 +225,7 @@ Optional: ### Nested Schema for `properties.saml` -Optional: +Optional Attributes: - `enabled` (Boolean) Enable or disable OpenSearch SAML authentication. Enables or disables SAML-based authentication for OpenSearch. When enabled, users can authenticate using SAML with an Identity Provider. - `idp_entity_id` (String) Identity Provider Entity ID. The unique identifier for the Identity Provider (IdP) entity that is used for SAML authentication. This value is typically provided by the IdP. @@ -251,5 +257,3 @@ Read-Only: - `name` (String) - `role` (String) - `state` (String) - - diff --git a/docs/resources/managed_database_postgresql.md b/docs/resources/managed_database_postgresql.md index 2f03e7544..50edd2d4b 100644 --- a/docs/resources/managed_database_postgresql.md +++ b/docs/resources/managed_database_postgresql.md @@ -38,19 +38,22 @@ resource "upcloud_managed_database_postgresql" "example_2" { ## Schema -### Required +### Required Attributes - `name` (String) Name of the service. The name is used as a prefix for the logical hostname. Must be unique within an account - `plan` (String) Service plan to use. This determines how much resources the instance will have. You can list available plans with `upctl database plans `. - `title` (String) Title of a managed database instance - `zone` (String) Zone where the instance resides, e.g. `de-fra1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes - `maintenance_window_dow` (String) Maintenance window day of week. Lower case weekday name (monday, tuesday, ...) - `maintenance_window_time` (String) Maintenance window UTC time in hh:mm:ss format -- `network` (Block Set, Max: 8) Private networks attached to the managed database (see [below for nested schema](#nestedblock--network)) - `powered` (Boolean) The administrative power state of the service + +### Blocks + +- `network` (Block Set, Max: 8) Private networks attached to the managed database (see [below for nested schema](#nestedblock--network)) - `properties` (Block List, Max: 1) Database Engine properties for PostgreSQL (see [below for nested schema](#nestedblock--properties)) ### Read-Only @@ -71,7 +74,7 @@ resource "upcloud_managed_database_postgresql" "example_2" { ### Nested Schema for `network` -Required: +Required Attributes: - `family` (String) Network family. Currently only `IPv4` is supported. - `name` (String) The name of the network. Must be unique within the service. @@ -82,7 +85,7 @@ Required: ### Nested Schema for `properties` -Optional: +Optional Attributes: - `admin_password` (String, Sensitive) Custom password for admin user. Defaults to random string. This must be set only when a new service is being created. - `admin_username` (String) Custom username for admin user. This must be set only when a new service is being created. @@ -126,22 +129,17 @@ Optional: - `max_standby_streaming_delay` (Number) Max standby streaming delay in milliseconds. - `max_wal_senders` (Number) PostgreSQL maximum WAL senders. - `max_worker_processes` (Number) Sets the maximum number of background processes that the system can support. -- `migration` (Block List, Max: 1) Migrate data from existing server. (see [below for nested schema](#nestedblock--properties--migration)) - `pg_partman_bgw_interval` (Number) Sets the time interval to run pg_partman's scheduled tasks. - `pg_partman_bgw_role` (String) Controls which role to use for pg_partman's scheduled background tasks. - `pg_stat_monitor_enable` (Boolean) Enable pg_stat_monitor extension if available for the current cluster. Enable the pg_stat_monitor extension. Enabling this extension will cause the cluster to be restarted.When this extension is enabled, pg_stat_statements results for utility commands are unreliable. - `pg_stat_monitor_pgsm_enable_query_plan` (Boolean) Enables or disables query plan monitoring. - `pg_stat_monitor_pgsm_max_buckets` (Number) Sets the maximum number of buckets. - `pg_stat_statements_track` (String) Controls which statements are counted. Specify top to track top-level statements (those issued directly by clients), all to also track nested statements (such as statements invoked within functions), or none to disable statement statistics collection. The default value is top. -- `pgaudit` (Block List, Max: 1) PGAudit settings. System-wide settings for the pgaudit extension. (see [below for nested schema](#nestedblock--properties--pgaudit)) -- `pgbouncer` (Block List, Max: 1) PGBouncer connection pooling settings. System-wide settings for pgbouncer. (see [below for nested schema](#nestedblock--properties--pgbouncer)) -- `pglookout` (Block List, Max: 1) PGLookout settings. System-wide settings for pglookout. (see [below for nested schema](#nestedblock--properties--pglookout)) - `public_access` (Boolean) Public Access. Allow access to the service from the public Internet. - `service_log` (Boolean) Service logging. Store logs for the service so that they are available in the HTTP API and console. - `shared_buffers_percentage` (Number) Percentage of total RAM that the database server uses for shared memory buffers. Valid range is 20-60 (float), which corresponds to 20% - 60%. This setting adjusts the shared_buffers configuration value. - `synchronous_replication` (String) Synchronous replication type. Note that the service plan also needs to support synchronous replication. - `temp_file_limit` (Number) PostgreSQL temporary file limit in KiB, -1 for unlimited. -- `timescaledb` (Block List, Max: 1) TimescaleDB extension configuration values. System-wide settings for the timescaledb extension. (see [below for nested schema](#nestedblock--properties--timescaledb)) - `timezone` (String) PostgreSQL service timezone. - `track_activity_query_size` (Number) Specifies the number of bytes reserved to track the currently executing command for each active session. - `track_commit_timestamp` (String) Record commit time of transactions. @@ -153,10 +151,18 @@ Optional: - `wal_writer_delay` (Number) WAL flush interval in milliseconds. Note that setting this value to lower than the default 200ms may negatively impact performance. - `work_mem` (Number) Sets the maximum amount of memory to be used by a query operation (such as a sort or hash table) before writing to temporary disk files, in MB. Default is 1MB + 0.075% of total RAM (up to 32MB). +Blocks: + +- `migration` (Block List, Max: 1) Migrate data from existing server. (see [below for nested schema](#nestedblock--properties--migration)) +- `pgaudit` (Block List, Max: 1) PGAudit settings. System-wide settings for the pgaudit extension. (see [below for nested schema](#nestedblock--properties--pgaudit)) +- `pgbouncer` (Block List, Max: 1) PGBouncer connection pooling settings. System-wide settings for pgbouncer. (see [below for nested schema](#nestedblock--properties--pgbouncer)) +- `pglookout` (Block List, Max: 1) PGLookout settings. System-wide settings for pglookout. (see [below for nested schema](#nestedblock--properties--pglookout)) +- `timescaledb` (Block List, Max: 1) TimescaleDB extension configuration values. System-wide settings for the timescaledb extension. (see [below for nested schema](#nestedblock--properties--timescaledb)) + ### Nested Schema for `properties.migration` -Optional: +Optional Attributes: - `dbname` (String) Database name for bootstrapping the initial connection. - `host` (String) Hostname or IP address of the server where to migrate data from. @@ -171,7 +177,7 @@ Optional: ### Nested Schema for `properties.pgaudit` -Optional: +Optional Attributes: - `feature_enabled` (Boolean) Enable pgaudit extension. Enable pgaudit extension. When enabled, pgaudit extension will be automatically installed.Otherwise, extension will be uninstalled but auditing configurations will be preserved. - `log` (List of String) Specifies which classes of statements will be logged by session audit logging. @@ -192,7 +198,7 @@ Optional: ### Nested Schema for `properties.pgbouncer` -Optional: +Optional Attributes: - `autodb_idle_timeout` (Number) If the automatically created database pools have been unused this many seconds, they are freed. If 0 then timeout is disabled. [seconds]. - `autodb_max_db_connections` (Number) Do not allow more than this many server connections per database (regardless of user). Setting it to 0 means unlimited. @@ -208,7 +214,7 @@ Optional: ### Nested Schema for `properties.pglookout` -Optional: +Optional Attributes: - `max_failover_replication_time_lag` (Number) Number of seconds of master unavailability before triggering database failover to standby. @@ -216,7 +222,7 @@ Optional: ### Nested Schema for `properties.timescaledb` -Optional: +Optional Attributes: - `max_background_workers` (Number) The number of background workers for timescaledb operations. You should configure this setting to the sum of your number of databases and the total number of concurrent background workers you want running at any given point in time. @@ -242,5 +248,3 @@ Read-Only: - `name` (String) - `role` (String) - `state` (String) - - diff --git a/docs/resources/managed_database_redis.md b/docs/resources/managed_database_redis.md index f6c7e9fdf..fbb6744d7 100644 --- a/docs/resources/managed_database_redis.md +++ b/docs/resources/managed_database_redis.md @@ -36,19 +36,22 @@ resource "upcloud_managed_database_redis" "example_2" { ## Schema -### Required +### Required Attributes - `name` (String) Name of the service. The name is used as a prefix for the logical hostname. Must be unique within an account - `plan` (String) Service plan to use. This determines how much resources the instance will have. You can list available plans with `upctl database plans `. - `title` (String) Title of a managed database instance - `zone` (String) Zone where the instance resides, e.g. `de-fra1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes - `maintenance_window_dow` (String) Maintenance window day of week. Lower case weekday name (monday, tuesday, ...) - `maintenance_window_time` (String) Maintenance window UTC time in hh:mm:ss format -- `network` (Block Set, Max: 8) Private networks attached to the managed database (see [below for nested schema](#nestedblock--network)) - `powered` (Boolean) The administrative power state of the service + +### Blocks + +- `network` (Block Set, Max: 8) Private networks attached to the managed database (see [below for nested schema](#nestedblock--network)) - `properties` (Block List, Max: 1) Database Engine properties for Redis (see [below for nested schema](#nestedblock--properties)) ### Read-Only @@ -68,7 +71,7 @@ resource "upcloud_managed_database_redis" "example_2" { ### Nested Schema for `network` -Required: +Required Attributes: - `family` (String) Network family. Currently only `IPv4` is supported. - `name` (String) The name of the network. Must be unique within the service. @@ -79,11 +82,10 @@ Required: ### Nested Schema for `properties` -Optional: +Optional Attributes: - `automatic_utility_network_ip_filter` (Boolean) Automatic utility network IP Filter. Automatically allow connections from servers in the utility network within the same zone. - `ip_filter` (List of String) IP filter. Allow incoming connections from CIDR address block, e.g. '10.20.0.0/16'. -- `migration` (Block List, Max: 1) Migrate data from existing server. (see [below for nested schema](#nestedblock--properties--migration)) - `public_access` (Boolean) Public Access. Allow access to the service from the public Internet. - `redis_acl_channels_default` (String) Default ACL for pub/sub channels used when Redis user is created. Determines default pub/sub channels' ACL for new users if ACL is not supplied. When this option is not defined, all_channels is assumed to keep backward compatibility. This option doesn't affect Redis configuration acl-pubsub-default. - `redis_io_threads` (Number) Redis IO thread count. Set Redis IO thread count. Changing this will cause a restart of the Redis service. @@ -99,10 +101,14 @@ Optional: - `redis_version` (String) Redis major version. - `service_log` (Boolean) Service logging. Store logs for the service so that they are available in the HTTP API and console. +Blocks: + +- `migration` (Block List, Max: 1) Migrate data from existing server. (see [below for nested schema](#nestedblock--properties--migration)) + ### Nested Schema for `properties.migration` -Optional: +Optional Attributes: - `dbname` (String) Database name for bootstrapping the initial connection. - `host` (String) Hostname or IP address of the server where to migrate data from. @@ -135,5 +141,3 @@ Read-Only: - `name` (String) - `role` (String) - `state` (String) - - diff --git a/docs/resources/managed_database_user.md b/docs/resources/managed_database_user.md index 0a1498776..68af7bc04 100644 --- a/docs/resources/managed_database_user.md +++ b/docs/resources/managed_database_user.md @@ -30,16 +30,19 @@ resource "upcloud_managed_database_user" "example_user" { ## Schema -### Required +### Required Attributes - `service` (String) Service's UUID for which this user belongs to - `username` (String) Name of the database user -### Optional +### Optional Attributes - `authentication` (String) MySQL only, authentication type. -- `opensearch_access_control` (Block List, Max: 1) OpenSearch access control object. (see [below for nested schema](#nestedblock--opensearch_access_control)) - `password` (String, Sensitive) Password for the database user. Defaults to a random value + +### Blocks + +- `opensearch_access_control` (Block List, Max: 1) OpenSearch access control object. (see [below for nested schema](#nestedblock--opensearch_access_control)) - `pg_access_control` (Block List, Max: 1) PostgreSQL access control object. (see [below for nested schema](#nestedblock--pg_access_control)) - `redis_access_control` (Block List, Max: 1) Redis access control object. (see [below for nested schema](#nestedblock--redis_access_control)) @@ -51,14 +54,14 @@ resource "upcloud_managed_database_user" "example_user" { ### Nested Schema for `opensearch_access_control` -Required: +Blocks: - `rules` (Block List, Min: 1) Set user access control rules. (see [below for nested schema](#nestedblock--opensearch_access_control--rules)) ### Nested Schema for `opensearch_access_control.rules` -Required: +Required Attributes: - `index` (String) Set index name, pattern or top level API. - `permission` (String) Set permission access. @@ -68,7 +71,7 @@ Required: ### Nested Schema for `pg_access_control` -Optional: +Optional Attributes: - `allow_replication` (Boolean) Grant replication privilege @@ -76,11 +79,9 @@ Optional: ### Nested Schema for `redis_access_control` -Optional: +Optional Attributes: - `categories` (List of String) Set access control to all commands in specified categories. - `channels` (List of String) Set access control to Pub/Sub channels. - `commands` (List of String) Set access control to commands. - `keys` (List of String) Set access control to keys. - - diff --git a/docs/resources/managed_object_storage.md b/docs/resources/managed_object_storage.md index b6a282d33..b1f3826c6 100644 --- a/docs/resources/managed_object_storage.md +++ b/docs/resources/managed_object_storage.md @@ -53,15 +53,18 @@ resource "upcloud_managed_object_storage" "this" { ## Schema -### Required +### Required Attributes - `configured_status` (String) Service status managed by the end user. - `name` (String) Name of the Managed Object Storage service. Must be unique within account. - `region` (String) Region in which the service will be hosted, see `upcloud_managed_object_storage_regions` data source. -### Optional +### Optional Attributes - `labels` (Map of String) Key-value pairs to classify the managed object storage. + +### Blocks + - `network` (Block Set) Attached networks from where object storage can be used. Private networks must reside in object storage region. To gain access from multiple private networks that might reside in different zones, create the networks and a corresponding router for each network. (see [below for nested schema](#nestedblock--network)) ### Read-Only @@ -75,13 +78,13 @@ resource "upcloud_managed_object_storage" "this" { ### Nested Schema for `network` -Required: +Required Attributes: - `family` (String) Network family. IPv6 currently not supported. - `name` (String) Network name. Must be unique within the service. - `type` (String) Network type. -Optional: +Optional Attributes: - `uuid` (String) Private network uuid. For public networks the field should be omitted. @@ -95,5 +98,3 @@ Read-Only: - `iam_url` (String) - `sts_url` (String) - `type` (String) - - diff --git a/docs/resources/managed_object_storage_policy.md b/docs/resources/managed_object_storage_policy.md index 97e2c97b7..2a1195842 100644 --- a/docs/resources/managed_object_storage_policy.md +++ b/docs/resources/managed_object_storage_policy.md @@ -30,13 +30,13 @@ resource "upcloud_managed_object_storage_policy" "this" { ## Schema -### Required +### Required Attributes - `document` (String) Policy document, URL-encoded compliant with RFC 3986. - `name` (String) Policy name. - `service_uuid` (String) Managed Object Storage service UUID. -### Optional +### Optional Attributes - `description` (String) Description of the policy. @@ -49,5 +49,3 @@ resource "upcloud_managed_object_storage_policy" "this" { - `id` (String) The ID of this resource. - `system` (Boolean) Defines whether the policy was set up by the system. - `updated_at` (String) Update time. - - diff --git a/docs/resources/managed_object_storage_user.md b/docs/resources/managed_object_storage_user.md index 6ccbeb0e0..f83b2c2a6 100644 --- a/docs/resources/managed_object_storage_user.md +++ b/docs/resources/managed_object_storage_user.md @@ -28,7 +28,7 @@ resource "upcloud_managed_object_storage_user" "this" { ## Schema -### Required +### Required Attributes - `service_uuid` (String) Managed Object Storage service UUID. - `username` (String) Custom usernames for accessing the object storage. No relation to UpCloud API accounts. See `upcloud_managed_object_storage_user_access_key` for managing access keys and `upcloud_managed_object_storage_user_policy` for managing policies. @@ -38,5 +38,3 @@ resource "upcloud_managed_object_storage_user" "this" { - `arn` (String) User ARN. - `created_at` (String) Creation time. - `id` (String) The ID of this resource. - - diff --git a/docs/resources/managed_object_storage_user_access_key.md b/docs/resources/managed_object_storage_user_access_key.md index 1fd903b71..c40df8bc8 100644 --- a/docs/resources/managed_object_storage_user_access_key.md +++ b/docs/resources/managed_object_storage_user_access_key.md @@ -34,7 +34,7 @@ resource "upcloud_managed_object_storage_user_access_key" "this" { ## Schema -### Required +### Required Attributes - `service_uuid` (String) Managed Object Storage service UUID. - `status` (String) Status of the key. Valid values: `Active`|`Inactive` @@ -47,5 +47,3 @@ resource "upcloud_managed_object_storage_user_access_key" "this" { - `id` (String) The ID of this resource. - `last_used_at` (String) Last used. - `secret_access_key` (String, Sensitive) Secret access key. - - diff --git a/docs/resources/managed_object_storage_user_policy.md b/docs/resources/managed_object_storage_user_policy.md index c67a34120..6d599cf24 100644 --- a/docs/resources/managed_object_storage_user_policy.md +++ b/docs/resources/managed_object_storage_user_policy.md @@ -41,7 +41,7 @@ resource "upcloud_managed_object_storage_user_policy" "this" { ## Schema -### Required +### Required Attributes - `name` (String) Policy name. - `service_uuid` (String) Managed Object Storage service UUID. @@ -50,5 +50,3 @@ resource "upcloud_managed_object_storage_user_policy" "this" { ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/docs/resources/network.md b/docs/resources/network.md index b296dbdef..4e37fabe2 100644 --- a/docs/resources/network.md +++ b/docs/resources/network.md @@ -3,12 +3,12 @@ page_title: "upcloud_network Resource - terraform-provider-upcloud" subcategory: Network description: |- - This resource represents an SDN private network that cloud servers from the same zone can be attached to. + This resource represents an SDN private network that cloud servers and other resources from the same zone can be attached to. --- # upcloud_network (Resource) -This resource represents an SDN private network that cloud servers from the same zone can be attached to. +This resource represents an SDN private network that cloud servers and other resources from the same zone can be attached to. ## Example Usage @@ -37,31 +37,34 @@ resource "upcloud_router" "example_router" { ## Schema -### Required +### Required Attributes -- `ip_network` (Block List, Min: 1, Max: 1) A list of IP subnets within the network (see [below for nested schema](#nestedblock--ip_network)) -- `name` (String) A valid name for the network +- `name` (String) Name of the network. - `zone` (String) The zone the network is in, e.g. `de-fra1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes -- `router` (String) The UUID of a router +- `router` (String) UUID of a router to attach to this network. + +### Blocks + +- `ip_network` (Block List) IP subnet within the network. Network must have exactly one IP subnet. (see [below for nested schema](#nestedblock--ip_network)) ### Read-Only -- `id` (String) The ID of this resource. +- `id` (String) UUID of the network. - `type` (String) The network type ### Nested Schema for `ip_network` -Required: +Required Attributes: - `address` (String) The CIDR range of the subnet - `dhcp` (Boolean) Is DHCP enabled? - `family` (String) IP address family -Optional: +Optional Attributes: - `dhcp_default_route` (Boolean) Is the gateway the DHCP default route? - `dhcp_dns` (Set of String) The DNS servers given by DHCP diff --git a/docs/resources/object_storage.md b/docs/resources/object_storage.md index 8a8827dc7..7169516b9 100644 --- a/docs/resources/object_storage.md +++ b/docs/resources/object_storage.md @@ -40,7 +40,7 @@ resource "upcloud_object_storage" "my_object_storage" { ## Schema -### Required +### Required Attributes - `access_key` (String) The access key used to identify user. Can be set to an empty string, which will tell the provider to get the access key from environment variable. @@ -58,11 +58,14 @@ resource "upcloud_object_storage" "my_object_storage" { - `size` (Number) The size of the object storage instance in gigabytes - `zone` (String) The zone in which the object storage instance will be created, e.g. `de-fra1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes -- `bucket` (Block Set) (see [below for nested schema](#nestedblock--bucket)) - `description` (String) The description of the object storage instance to be created +### Blocks + +- `bucket` (Block Set) (see [below for nested schema](#nestedblock--bucket)) + ### Read-Only - `created` (String) @@ -74,7 +77,7 @@ resource "upcloud_object_storage" "my_object_storage" { ### Nested Schema for `bucket` -Required: +Required Attributes: - `name` (String) The name of the bucket diff --git a/docs/resources/router.md b/docs/resources/router.md index 0077476b8..b8c84ee76 100644 --- a/docs/resources/router.md +++ b/docs/resources/router.md @@ -4,8 +4,8 @@ page_title: "upcloud_router Resource - terraform-provider-upcloud" subcategory: Network description: |- This resource represents a generated UpCloud router resource. - Routers can be used to connect multiple Private Networks. - UpCloud Servers on any attached network can communicate directly with each other. + Routers can be used to connect multiple Private Networks. + UpCloud Servers on any attached network can communicate directly with each other. --- # upcloud_router (Resource) @@ -25,11 +25,11 @@ resource "upcloud_router" "my_example_router" { ## Schema -### Required +### Required Attributes - `name` (String) Name of the router -### Optional +### Blocks - `static_route` (Block Set) A collection of static routes for this router (see [below for nested schema](#nestedblock--static_route)) @@ -42,12 +42,12 @@ resource "upcloud_router" "my_example_router" { ### Nested Schema for `static_route` -Required: +Required Attributes: - `nexthop` (String) Next hop address. NOTE: For static route to be active the next hop has to be an address of a reachable running Cloud Server in one of the Private Networks attached to the router. - `route` (String) Destination prefix of the route. -Optional: +Optional Attributes: - `name` (String) Name or description of the route. diff --git a/docs/resources/server.md b/docs/resources/server.md index 7ff47dd79..73683b74f 100644 --- a/docs/resources/server.md +++ b/docs/resources/server.md @@ -51,25 +51,33 @@ resource "upcloud_server" "example" { ## Schema -### Required +### Required Attributes - `hostname` (String) A valid domain name -- `network_interface` (Block List, Min: 1) One or more blocks describing the network interfaces of the server. (see [below for nested schema](#nestedblock--network_interface)) - `zone` (String) The zone in which the server will be hosted, e.g. `de-fra1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes - `boot_order` (String) The boot device order, `cdrom`|`disk`|`network` or comma separated combination of those values. Defaults to `disk` - `cpu` (Number) The number of CPU for the server - `firewall` (Boolean) Are firewall rules active for the server - `host` (Number) Use this to start the VM on a specific host. Refers to value from host -attribute. Only available for private cloud hosts - `labels` (Map of String) Key-value pairs to classify the server. -- `login` (Block Set, Max: 1) Configure access credentials to the server (see [below for nested schema](#nestedblock--login)) - `mem` (Number) The size of memory for the server (in megabytes) - `metadata` (Boolean) Is the metadata service active for the server - `nic_model` (String) The model of the server's network interfaces - `plan` (String) The pricing plan used for the server. You can list available server plans with `upctl server plans` - `server_group` (String) The UUID of a server group to attach this server to. Note that the server can also be attached to a server group via the `members` property of `upcloud_server_group`. Only one of the these should be defined at a time. This value is only updated if it has been set to non-zero value. +- `tags` (Set of String) The server related tags +- `timezone` (String) A timezone identifier, e.g. `Europe/Helsinki` +- `title` (String) A short, informational description +- `user_data` (String) Defines URL for a server setup script, or the script body itself +- `video_model` (String) The model of the server's video interface + +### Blocks + +- `login` (Block Set, Max: 1) Configure access credentials to the server (see [below for nested schema](#nestedblock--login)) +- `network_interface` (Block List, Min: 1) One or more blocks describing the network interfaces of the server. (see [below for nested schema](#nestedblock--network_interface)) - `simple_backup` (Block Set, Max: 1) Simple backup schedule configuration The idea behind simple backups is to provide a simplified way of backing up *all* of the storages attached to a given server. This means you cannot have simple backup set for a server, and then some individual backup_rules on the storages attached to said server. @@ -80,33 +88,42 @@ resource "upcloud_server" "example" { please first remove simple_backup block from a server, run 'terraform apply', then add backup_rule to desired storages and run 'terraform apply' again. (see [below for nested schema](#nestedblock--simple_backup)) - `storage_devices` (Block Set) A list of storage devices associated with the server (see [below for nested schema](#nestedblock--storage_devices)) -- `tags` (Set of String) The server related tags - `template` (Block List, Max: 1) Block describing the preconfigured operating system (see [below for nested schema](#nestedblock--template)) -- `timezone` (String) A timezone identifier, e.g. `Europe/Helsinki` -- `title` (String) A short, informational description -- `user_data` (String) Defines URL for a server setup script, or the script body itself -- `video_model` (String) The model of the server's video interface ### Read-Only - `id` (String) The ID of this resource. + +### Nested Schema for `login` + +Optional Attributes: + +- `create_password` (Boolean) Indicates a password should be create to allow access +- `keys` (List of String) A list of ssh keys to access the server +- `password_delivery` (String) The delivery method for the server's root password (one of `none`, `email` or `sms`) +- `user` (String) Username to be create to access the server + + ### Nested Schema for `network_interface` -Required: +Required Attributes: - `type` (String) Network interface type. For private network interfaces, a network must be specified with an existing network id. -Optional: +Optional Attributes: -- `additional_ip_address` (Block Set, Max: 4) 0-4 blocks of additional IP addresses to assign to this interface. Allowed only with network interfaces of type `private` (see [below for nested schema](#nestedblock--network_interface--additional_ip_address)) - `bootable` (Boolean) `true` if this interface should be used for network booting. - `ip_address` (String) The assigned primary IP address. - `ip_address_family` (String) The type of the primary IP address of this interface (one of `IPv4` or `IPv6`). - `network` (String) The unique ID of a network to attach this network to. - `source_ip_filtering` (Boolean) `true` if source IP should be filtered. +Blocks: + +- `additional_ip_address` (Block Set, Max: 4) 0-4 blocks of additional IP addresses to assign to this interface. Allowed only with network interfaces of type `private` (see [below for nested schema](#nestedblock--network_interface--additional_ip_address)) + Read-Only: - `ip_address_floating` (Boolean) `true` indicates that the primary IP address is a floating IP address. @@ -115,7 +132,7 @@ Read-Only: ### Nested Schema for `network_interface.additional_ip_address` -Optional: +Optional Attributes: - `ip_address` (String) The assigned additional IP address. - `ip_address_family` (String) The type of this additional IP address of this interface (one of `IPv4` or `IPv6`). @@ -126,21 +143,10 @@ Read-Only: - -### Nested Schema for `login` - -Optional: - -- `create_password` (Boolean) Indicates a password should be create to allow access -- `keys` (List of String) A list of ssh keys to access the server -- `password_delivery` (String) The delivery method for the server's root password (one of `none`, `email` or `sms`) -- `user` (String) Username to be create to access the server - - ### Nested Schema for `simple_backup` -Required: +Required Attributes: - `plan` (String) Simple backup plan. Accepted values: daily, dailies, weeklies, monthlies. - `time` (String) Time of the day at which backup will be taken. Should be provided in a hhmm format (e.g. 2230). @@ -149,11 +155,11 @@ Required: ### Nested Schema for `storage_devices` -Required: +Required Attributes: - `storage` (String) A valid storage UUID -Optional: +Optional Attributes: - `address` (String) The device address the storage will be attached to (`scsi`|`virtio`|`ide`). Leave `address_position` field empty to auto-select next available address from that bus. - `address_position` (String) The device position in the given bus (defined via field `address`). Valid values for address `virtio` are `0-15` (`0`, for example). Valid values for `scsi` or `ide` are `0-1:0-1` (`0:0`, for example). Leave empty to auto-select next available address in the given bus. @@ -163,22 +169,14 @@ Optional: ### Nested Schema for `template` -Required: +Required Attributes: - `storage` (String) A valid storage UUID or template name. You can list available public templates with `upctl storage list --public --template` and available private templates with `upctl storage list --template`. -Optional: +Optional Attributes: - `address` (String) The device address the storage will be attached to (`scsi`|`virtio`|`ide`). Leave `address_position` field empty to auto-select next available address from that bus. - `address_position` (String) The device position in the given bus (defined via field `address`). For example `0:0`, or `0`. Leave empty to auto-select next available address in the given bus. -- `backup_rule` (Block List, Max: 1) The criteria to backup the storage - Please keep in mind that it's not possible to have a server with backup_rule attached to a server with simple_backup specified. - Such configurations will throw errors during execution. - Also, due to how UpCloud API works with simple backups and how Terraform orders the update operations, - it is advised to never switch between simple_backup on the server and individual storages backup_rules in one apply. - If you want to switch from using server simple backup to per-storage defined backup rules, - please first remove simple_backup block from a server, run 'terraform apply', - then add 'backup_rule' to desired storages and run 'terraform apply' again. (see [below for nested schema](#nestedblock--template--backup_rule)) - `delete_autoresize_backup` (Boolean) If set to true, the backup taken before the partition and filesystem resize attempt will be deleted immediately after success. - `encrypt` (Boolean) Sets if the storage is encrypted at rest - `filesystem_autoresize` (Boolean) If set to true, provider will attempt to resize partition and filesystem when the size of template storage changes. @@ -188,6 +186,17 @@ Optional: - `size` (Number) The size of the storage in gigabytes - `title` (String) A short, informative description +Blocks: + +- `backup_rule` (Block List, Max: 1) The criteria to backup the storage + Please keep in mind that it's not possible to have a server with backup_rule attached to a server with simple_backup specified. + Such configurations will throw errors during execution. + Also, due to how UpCloud API works with simple backups and how Terraform orders the update operations, + it is advised to never switch between simple_backup on the server and individual storages backup_rules in one apply. + If you want to switch from using server simple backup to per-storage defined backup rules, + please first remove simple_backup block from a server, run 'terraform apply', + then add 'backup_rule' to desired storages and run 'terraform apply' again. (see [below for nested schema](#nestedblock--template--backup_rule)) + Read-Only: - `id` (String) The unique identifier for the storage @@ -196,7 +205,7 @@ Read-Only: ### Nested Schema for `template.backup_rule` -Required: +Required Attributes: - `interval` (String) The weekday when the backup is created - `retention` (Number) The number of days before a backup is automatically deleted diff --git a/docs/resources/server_group.md b/docs/resources/server_group.md index 5cac5a3ff..429dad8b9 100644 --- a/docs/resources/server_group.md +++ b/docs/resources/server_group.md @@ -32,11 +32,11 @@ resource "upcloud_server_group" "main" { ## Schema -### Required +### Required Attributes - `title` (String) Title of your server group -### Optional +### Optional Attributes - `anti_affinity_policy` (String) Defines if a server group is an anti-affinity group. Setting this to `strict` or `yes` will result in all servers in the group being placed on separate compute hosts. The value can be `strict`, `yes`, or `no`. diff --git a/docs/resources/storage.md b/docs/resources/storage.md index df4055318..34fc27998 100644 --- a/docs/resources/storage.md +++ b/docs/resources/storage.md @@ -106,13 +106,23 @@ resource "upcloud_server" "example_server" { ## Schema -### Required +### Required Attributes - `size` (Number) The size of the storage in gigabytes - `title` (String) A short, informative description - `zone` (String) The zone in which the storage will be created, e.g. `de-fra1`. You can list available zones with `upctl zone list`. -### Optional +### Optional Attributes + +- `delete_autoresize_backup` (Boolean) If set to true, the backup taken before the partition and filesystem resize attempt will be deleted immediately after success. +- `encrypt` (Boolean) Sets if the storage is encrypted at rest +- `filesystem_autoresize` (Boolean) If set to true, provider will attempt to resize partition and filesystem when the size of the storage changes. + Please note that before the resize attempt is made, backup of the storage will be taken. If the resize attempt fails, the backup will be used + to restore the storage and then deleted. If the resize attempt succeeds, backup will be kept (unless delete_autoresize_backup option is set to true). + Taking and keeping backups incure costs. +- `tier` (String) The storage tier to use + +### Blocks - `backup_rule` (Block List, Max: 1) The criteria to backup the storage Please keep in mind that it's not possible to have a server with backup_rule attached to a server with simple_backup specified. @@ -123,14 +133,7 @@ resource "upcloud_server" "example_server" { please first remove simple_backup block from a server, run 'terraform apply', then add 'backup_rule' to desired storages and run 'terraform apply' again. (see [below for nested schema](#nestedblock--backup_rule)) - `clone` (Block Set, Max: 1) Block defining another storage/template to clone to storage (see [below for nested schema](#nestedblock--clone)) -- `delete_autoresize_backup` (Boolean) If set to true, the backup taken before the partition and filesystem resize attempt will be deleted immediately after success. -- `encrypt` (Boolean) Sets if the storage is encrypted at rest -- `filesystem_autoresize` (Boolean) If set to true, provider will attempt to resize partition and filesystem when the size of the storage changes. - Please note that before the resize attempt is made, backup of the storage will be taken. If the resize attempt fails, the backup will be used - to restore the storage and then deleted. If the resize attempt succeeds, backup will be kept (unless delete_autoresize_backup option is set to true). - Taking and keeping backups incure costs. - `import` (Block Set, Max: 1) Block defining external data to import to storage (see [below for nested schema](#nestedblock--import)) -- `tier` (String) The storage tier to use ### Read-Only @@ -139,7 +142,7 @@ resource "upcloud_server" "example_server" { ### Nested Schema for `backup_rule` -Required: +Required Attributes: - `interval` (String) The weekday when the backup is created - `retention` (Number) The number of days before a backup is automatically deleted @@ -149,7 +152,7 @@ Required: ### Nested Schema for `clone` -Required: +Required Attributes: - `id` (String) The unique identifier of the storage/template to clone @@ -157,12 +160,12 @@ Required: ### Nested Schema for `import` -Required: +Required Attributes: - `source` (String) The mode of the import task. One of `http_import` or `direct_upload`. - `source_location` (String) The location of the file to import. For `http_import` an accessible URL for `direct_upload` a local file. -Optional: +Optional Attributes: - `source_hash` (String) For `direct_upload`; an optional hash of the file to upload. diff --git a/docs/resources/tag.md b/docs/resources/tag.md index 96fe5dacf..64c7a5738 100644 --- a/docs/resources/tag.md +++ b/docs/resources/tag.md @@ -15,11 +15,11 @@ This resource is deprecated, use tags schema in server resource ## Schema -### Required +### Required Attributes - `name` (String) The value representing the tag -### Optional +### Optional Attributes - `description` (String) Free form text representing the meaning of the tag - `servers` (Set of String) A collection of servers that have been assigned the tag @@ -27,5 +27,3 @@ This resource is deprecated, use tags schema in server resource ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/go.mod b/go.mod index 3790c5c4e..9f4d1b9fb 100644 --- a/go.mod +++ b/go.mod @@ -7,43 +7,46 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-retryablehttp v0.6.8 github.com/hashicorp/go-uuid v1.0.3 + github.com/hashicorp/terraform-plugin-framework v1.7.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 + github.com/hashicorp/terraform-plugin-go v0.22.1 github.com/hashicorp/terraform-plugin-log v0.9.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 + github.com/hashicorp/terraform-plugin-mux v0.15.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 github.com/minio/minio-go/v7 v7.0.10 github.com/stretchr/testify v1.7.2 gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect + github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.13.0 // indirect + github.com/fatih/color v1.16.0 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.5.1 // indirect + github.com/hashicorp/go-plugin v1.6.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.6.0 // indirect - github.com/hashicorp/hcl/v2 v2.18.0 // indirect + github.com/hashicorp/hc-install v0.6.3 // indirect + github.com/hashicorp/hcl/v2 v2.19.1 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.19.0 // indirect - github.com/hashicorp/terraform-json v0.17.1 // indirect - github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect - github.com/hashicorp/terraform-registry-address v0.2.2 // indirect + github.com/hashicorp/terraform-exec v0.20.0 // indirect + github.com/hashicorp/terraform-json v0.21.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect - github.com/hashicorp/yamux v0.0.0-20210316155119-a95892c5f864 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect github.com/json-iterator/go v1.1.10 // indirect github.com/klauspost/cpuid/v2 v2.0.6 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect @@ -58,17 +61,17 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rs/xid v1.3.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect - github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.14.0 // indirect + github.com/zclconf/go-cty v1.14.2 // indirect golang.org/x/crypto v0.21.0 // indirect - golang.org/x/mod v0.12.0 // indirect + golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect - google.golang.org/grpc v1.57.2 // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect + google.golang.org/grpc v1.62.1 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect ) diff --git a/go.sum b/go.sum index e1fd772b1..dc4abbbff 100644 --- a/go.sum +++ b/go.sum @@ -2,12 +2,10 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs= -github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v1.1.0-alpha.0 h1:nHGfwXmFvJrSR9xu8qL7BkO4DqTHXE9N5vPhgY2I+j0= +github.com/ProtonMail/go-crypto v1.1.0-alpha.0/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/UpCloudLtd/upcloud-go-api/v8 v8.3.0 h1:FYZT286rV+rWZOI676VBMNhYAMSDbFmw95+ANYvIW4A= github.com/UpCloudLtd/upcloud-go-api/v8 v8.3.0/go.mod h1:pMuPcIQ5VUC65UETsaEPgHiDymxwX/3xYm4vlC4E9VI= -github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= -github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= @@ -15,10 +13,10 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -26,31 +24,32 @@ github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= -github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= -github.com/go-git/go-git/v5 v5.8.1 h1:Zo79E4p7TRk0xoRgMq0RShiTHGKcKI4+DI6BfJc/Q+A= -github.com/go-git/go-git/v5 v5.8.1/go.mod h1:FHFuoD6yGz5OSKEBK+aWN9Oah0q54Jxl0abmj6GnqAo= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= +github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -69,8 +68,8 @@ github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.5.1 h1:oGm7cWBaYIp3lJpx1RUEfLWophprE2EV/KUeqBYo+6k= -github.com/hashicorp/go-plugin v1.5.1/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= +github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= +github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= github.com/hashicorp/go-retryablehttp v0.6.8 h1:92lWxgpa+fF3FozM4B3UZtHZMJX8T5XT+TFdCxsPyWs= github.com/hashicorp/go-retryablehttp v0.6.8/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -78,28 +77,34 @@ github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/C github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.6.0 h1:fDHnU7JNFNSQebVKYhHZ0va1bC6SrPQ8fpebsvNr2w4= -github.com/hashicorp/hc-install v0.6.0/go.mod h1:10I912u3nntx9Umo1VAeYPUUuehk0aRQJYpMwbX5wQA= -github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8= -github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/hashicorp/hc-install v0.6.3 h1:yE/r1yJvWbtrJ0STwScgEnCanb0U9v7zp0Gbkmcoxqs= +github.com/hashicorp/hc-install v0.6.3/go.mod h1:KamGdbodYzlufbWh4r9NRo8y6GLHWZP2GBtdnms1Ln0= +github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= +github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM= -github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg= -github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA= -github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o= -github.com/hashicorp/terraform-plugin-go v0.19.0 h1:BuZx/6Cp+lkmiG0cOBk6Zps0Cb2tmqQpDM3iAtnhDQU= -github.com/hashicorp/terraform-plugin-go v0.19.0/go.mod h1:EhRSkEPNoylLQntYsk5KrDHTZJh9HQoumZXbOGOXmec= +github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo= +github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw= +github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U= +github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= +github.com/hashicorp/terraform-plugin-framework v1.7.0 h1:wOULbVmfONnJo9iq7/q+iBOBJul5vRovaYJIu2cY/Pw= +github.com/hashicorp/terraform-plugin-framework v1.7.0/go.mod h1:jY9Id+3KbZ17OMpulgnWLSfwxNVYSoYBQFTgsx044CI= +github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc= +github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg= +github.com/hashicorp/terraform-plugin-go v0.22.1 h1:iTS7WHNVrn7uhe3cojtvWWn83cm2Z6ryIUDTRO0EV7w= +github.com/hashicorp/terraform-plugin-go v0.22.1/go.mod h1:qrjnqRghvQ6KnDbB12XeZ4FluclYwptntoWCr9QaXTI= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 h1:wcOKYwPI9IorAJEBLzgclh3xVolO7ZorYd6U1vnok14= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0/go.mod h1:qH/34G25Ugdj5FcM95cSoXzUgIbgfhVLXCcEcYaMwq8= -github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno= -github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo= +github.com/hashicorp/terraform-plugin-mux v0.15.0 h1:+/+lDx0WUsIOpkAmdwBIoFU8UP9o2eZASoOnLsWbKME= +github.com/hashicorp/terraform-plugin-mux v0.15.0/go.mod h1:9ezplb1Dyq394zQ+ldB0nvy/qbNAz3mMoHHseMTMaKo= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= +github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= +github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= -github.com/hashicorp/yamux v0.0.0-20210316155119-a95892c5f864 h1:Y4V+SFe7d3iH+9pJCoeWIOS5/xBJIFsltS7E+KJSsJY= -github.com/hashicorp/yamux v0.0.0-20210316155119-a95892c5f864/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= @@ -124,11 +129,14 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= @@ -166,8 +174,8 @@ github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4= github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM= -github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo= +github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= +github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= @@ -176,49 +184,40 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc= -github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI= +github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -232,43 +231,36 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= -google.golang.org/grpc v1.57.2 h1:uw37EN34aMFFXB2QPW7Tq6tdTbind1GpRxw5aOX3a5k= -google.golang.org/grpc v1.57.2/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= +google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= @@ -285,6 +277,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/service/managedobjectstorage/data_sources.go b/internal/service/managedobjectstorage/policies_data_source.go similarity index 54% rename from internal/service/managedobjectstorage/data_sources.go rename to internal/service/managedobjectstorage/policies_data_source.go index 5927f794a..1a2401013 100644 --- a/internal/service/managedobjectstorage/data_sources.go +++ b/internal/service/managedobjectstorage/policies_data_source.go @@ -2,7 +2,6 @@ package managedobjectstorage import ( "context" - "time" "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud" "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request" @@ -11,76 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -func DataSourceManagedObjectStorageRegions() *schema.Resource { - return &schema.Resource{ - Description: `Returns a list of available Managed Object Storage regions.`, - ReadContext: dataSourceRegionsRead, - Schema: map[string]*schema.Schema{ - "regions": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Description: "Name of the region.", - Computed: true, - }, - "primary_zone": { - Type: schema.TypeString, - Description: "Primary zone of the region.", - Computed: true, - }, - "zones": { - Type: schema.TypeSet, - Description: "List of zones in the region.", - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - } -} - -func dataSourceRegionsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) (diags diag.Diagnostics) { - svc := meta.(*service.Service) - - regions, err := svc.GetManagedObjectStorageRegions(ctx, &request.GetManagedObjectStorageRegionsRequest{}) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(time.Now().UTC().String()) - - err = d.Set("regions", buildManagedObjectStorageRegions(regions)) - if err != nil { - return diag.FromErr(err) - } - - return diags -} - -func buildManagedObjectStorageRegions(regions []upcloud.ManagedObjectStorageRegion) []map[string]interface{} { - maps := make([]map[string]interface{}, 0) - for _, region := range regions { - zones := make([]string, 0) - for _, zone := range region.Zones { - zones = append(zones, zone.Name) - } - maps = append(maps, map[string]interface{}{ - "name": region.Name, - "primary_zone": region.PrimaryZone, - "zones": zones, - }) - } - - return maps -} - func DataSourceManagedObjectStoragePolicies() *schema.Resource { return &schema.Resource{ Description: "Policies available for a Managed Object Storage resource. See `managed_object_storage_user_policy` for attaching to a user.", diff --git a/internal/service/managedobjectstorage/regions_data_source.go b/internal/service/managedobjectstorage/regions_data_source.go new file mode 100644 index 000000000..317588948 --- /dev/null +++ b/internal/service/managedobjectstorage/regions_data_source.go @@ -0,0 +1,126 @@ +package managedobjectstorage + +import ( + "context" + "fmt" + "time" + + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" + "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request" + "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func NewRegionsDataSource() datasource.DataSource { + return ®ionsDataSource{} +} + +var ( + _ datasource.DataSource = ®ionsDataSource{} + _ datasource.DataSourceWithConfigure = ®ionsDataSource{} +) + +type regionsDataSource struct { + client *service.Service +} + +func (d *regionsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_managed_object_storage_regions" +} + +func (d *regionsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*service.Service) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected resource Configure type", + fmt.Sprintf("Expected *service.Service, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + d.client = client +} + +type regionsModel struct { + ID types.String `tfsdk:"id"` + Regions []regionModel `tfsdk:"regions"` +} + +type regionModel struct { + Name types.String `tfsdk:"name"` + PrimaryZone types.String `tfsdk:"primary_zone"` + Zones types.Set `tfsdk:"zones"` +} + +func (d *regionsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Returns a list of available Managed Object Storage regions.", + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + }, + }, + Blocks: map[string]schema.Block{ + "regions": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + Description: "Name of the region.", + Computed: true, + }, + "primary_zone": schema.StringAttribute{ + Description: "Primary zone of the region.", + Computed: true, + }, + "zones": schema.SetAttribute{ + Description: "List of zones in the region.", + Computed: true, + ElementType: types.StringType, + }, + }, + }, + }, + }, + } +} + +func (d *regionsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data regionsModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + data.ID = types.StringValue(time.Now().UTC().String()) + + regions, err := d.client.GetManagedObjectStorageRegions(ctx, &request.GetManagedObjectStorageRegionsRequest{}) + if err != nil { + resp.Diagnostics.AddError( + "Unable to read managed object-storage regions", + utils.ErrorDiagnosticDetail(err), + ) + return + } + + data.Regions = make([]regionModel, len(regions)) + for i, region := range regions { + data.Regions[i].Name = types.StringValue(region.Name) + data.Regions[i].PrimaryZone = types.StringValue(region.PrimaryZone) + + zonesSlice := make([]string, 0) + for _, zone := range region.Zones { + zonesSlice = append(zonesSlice, zone.Name) + } + + zones, diags := types.SetValueFrom(ctx, types.StringType, utils.NilAsEmptyList(zonesSlice)) + resp.Diagnostics.Append(diags...) + data.Regions[i].Zones = zones + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/internal/service/network/network.go b/internal/service/network/network.go index e06207cb1..8affb30e0 100644 --- a/internal/service/network/network.go +++ b/internal/service/network/network.go @@ -4,291 +4,399 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" + validatorutil "github.com/UpCloudLtd/terraform-provider-upcloud/internal/validator" "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud" "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request" "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) - "github.com/hashicorp/go-cty/cty" +var ( + _ resource.Resource = &networkResource{} + _ resource.ResourceWithConfigure = &networkResource{} + _ resource.ResourceWithImportState = &networkResource{} ) -func ResourceNetwork() *schema.Resource { - return &schema.Resource{ - Description: "This resource represents an SDN private network that cloud servers from the same zone can be attached to.", - ReadContext: resourceNetworkRead, - CreateContext: resourceNetworkCreate, - UpdateContext: resourceNetworkUpdate, - DeleteContext: resourceNetworkDelete, - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, - Schema: map[string]*schema.Schema{ - "ip_network": { - Type: schema.TypeList, +func NewNetworkResource() resource.Resource { + return &networkResource{} +} + +type networkResource struct { + client *service.Service +} + +func (r *networkResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_network" +} + +// Configure adds the provider configured client to the resource. +func (r *networkResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*service.Service) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected resource Configure type", + fmt.Sprintf("Expected *service.Service, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client +} + +type networkModel struct { + Name types.String `tfsdk:"name"` + ID types.String `tfsdk:"id"` + Type types.String `tfsdk:"type"` + Zone types.String `tfsdk:"zone"` + Router types.String `tfsdk:"router"` + IPNetwork types.List `tfsdk:"ip_network"` +} + +type ipNetworkModel struct { + Address types.String `tfsdk:"address"` + DHCP types.Bool `tfsdk:"dhcp"` + DHCPDefaultRoute types.Bool `tfsdk:"dhcp_default_route"` + DHCPDns types.Set `tfsdk:"dhcp_dns"` + DHCPRoutes types.Set `tfsdk:"dhcp_routes"` + Family types.String `tfsdk:"family"` + Gateway types.String `tfsdk:"gateway"` +} + +func (r *networkResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "This resource represents an SDN private network that cloud servers and other resources from the same zone can be attached to.", + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + MarkdownDescription: "Name of the network.", + Required: true, + }, + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "UUID of the network.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "type": schema.StringAttribute{ + MarkdownDescription: "The network type", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "zone": schema.StringAttribute{ + Description: "The zone the network is in, e.g. `de-fra1`. You can list available zones with `upctl zone list`.", Required: true, - MaxItems: 1, - MinItems: 1, - Description: "A list of IP subnets within the network", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "address": { - Type: schema.TypeString, - Description: "The CIDR range of the subnet", - Required: true, - ForceNew: true, - ValidateFunc: validation.IsCIDR, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "router": schema.StringAttribute{ + Description: "UUID of a router to attach to this network.", + Optional: true, + }, + }, + Blocks: map[string]schema.Block{ + "ip_network": schema.ListNestedBlock{ + Description: "IP subnet within the network. Network must have exactly one IP subnet.", + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "address": schema.StringAttribute{ + Description: "The CIDR range of the subnet", + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + validatorutil.NewFrameworkStringValidator(validation.IsCIDR), + }, }, - "dhcp": { - Type: schema.TypeBool, + "dhcp": schema.BoolAttribute{ Description: "Is DHCP enabled?", Required: true, }, - "dhcp_default_route": { - Type: schema.TypeBool, + "dhcp_default_route": schema.BoolAttribute{ Description: "Is the gateway the DHCP default route?", Computed: true, Optional: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, }, - "dhcp_dns": { - Type: schema.TypeSet, + "dhcp_dns": schema.SetAttribute{ + ElementType: types.StringType, Description: "The DNS servers given by DHCP", Computed: true, Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.Any(validation.IsIPv4Address, validation.IsIPv6Address), + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.Set{ + setvalidator.ValueStringsAre( + stringvalidator.Any( + validatorutil.NewFrameworkStringValidator(validation.IsIPv4Address), + validatorutil.NewFrameworkStringValidator(validation.IsIPv6Address), + ), + ), }, }, - "dhcp_routes": { - Type: schema.TypeSet, + "dhcp_routes": schema.SetAttribute{ + ElementType: types.StringType, Description: "The additional DHCP classless static routes given by DHCP", Computed: true, Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.IsCIDR, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.Set{ + setvalidator.ValueStringsAre( + stringvalidator.Any( + validatorutil.NewFrameworkStringValidator(validation.IsCIDR), + ), + ), }, }, - "family": { - Type: schema.TypeString, + "family": schema.StringAttribute{ Description: "IP address family", Required: true, - ValidateDiagFunc: func(v interface{}, _ cty.Path) diag.Diagnostics { - switch v.(string) { - case upcloud.IPAddressFamilyIPv4, upcloud.IPAddressFamilyIPv6: - return nil - default: - return diag.Diagnostics{diag.Diagnostic{ - Severity: diag.Error, - Summary: "'family' has incorrect value", - Detail: fmt.Sprintf("'family' should have value of %s or %s", - upcloud.IPAddressFamilyIPv4, - upcloud.IPAddressFamilyIPv6), - }} - } + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.String{ + stringvalidator.OneOf(upcloud.IPAddressFamilyIPv4, upcloud.IPAddressFamilyIPv6), }, }, - "gateway": { - Type: schema.TypeString, + "gateway": schema.StringAttribute{ Description: "Gateway address given by DHCP", Computed: true, Optional: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, }, }, }, - }, - "name": { - Type: schema.TypeString, - Description: "A valid name for the network", - Required: true, - }, - "type": { - Type: schema.TypeString, - Description: "The network type", - Computed: true, - }, - "zone": { - Type: schema.TypeString, - Description: "The zone the network is in, e.g. `de-fra1`. You can list available zones with `upctl zone list`.", - Required: true, - ForceNew: true, - }, - "router": { - Type: schema.TypeString, - Description: "The UUID of a router", - Optional: true, + Validators: []validator.List{ + listvalidator.IsRequired(), + listvalidator.SizeBetween(1, 1), + }, }, }, } } -func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client := meta.(*service.Service) +func setValues(ctx context.Context, data *networkModel, network *upcloud.Network) diag.Diagnostics { + respDiagnostics := diag.Diagnostics{} - req := request.CreateNetworkRequest{} - if v := d.Get("name"); v != nil { - req.Name = v.(string) - } - - if v := d.Get("zone"); v != nil { - req.Zone = v.(string) - } + data.Name = types.StringValue(network.Name) + data.ID = types.StringValue(network.UUID) + data.Type = types.StringValue(network.Type) + data.Zone = types.StringValue(network.Zone) - if v := d.Get("router"); v != nil { - req.Router = v.(string) + if network.Router == "" { + data.Router = types.StringNull() + } else { + data.Router = types.StringValue(network.Router) } - if v, ok := d.GetOk("ip_network"); ok { - ipn := v.([]interface{})[0] - ipnConf := ipn.(map[string]interface{}) - - uipn := upcloud.IPNetwork{ - Address: ipnConf["address"].(string), - DHCP: upcloud.FromBool(ipnConf["dhcp"].(bool)), - DHCPDefaultRoute: upcloud.FromBool(ipnConf["dhcp_default_route"].(bool)), - Family: ipnConf["family"].(string), - Gateway: ipnConf["gateway"].(string), - } + ipNetworks := make([]ipNetworkModel, len(network.IPNetworks)) - for _, dns := range ipnConf["dhcp_dns"].(*schema.Set).List() { - uipn.DHCPDns = append(uipn.DHCPDns, dns.(string)) - } + for i, ipnet := range network.IPNetworks { + ipNetworks[i].Address = types.StringValue(ipnet.Address) + ipNetworks[i].DHCP = utils.AsBool(ipnet.DHCP) + ipNetworks[i].DHCPDefaultRoute = utils.AsBool(ipnet.DHCPDefaultRoute) - for _, route := range ipnConf["dhcp_routes"].(*schema.Set).List() { - uipn.DHCPRoutes = append(uipn.DHCPRoutes, route.(string)) - } + dhcpdns, diags := types.SetValueFrom(ctx, types.StringType, utils.NilAsEmptyList(ipnet.DHCPDns)) + respDiagnostics.Append(diags...) + ipNetworks[i].DHCPDns = dhcpdns - req.IPNetworks = append(req.IPNetworks, uipn) - } + dhcproutes, diags := types.SetValueFrom(ctx, types.StringType, utils.NilAsEmptyList(ipnet.DHCPRoutes)) + respDiagnostics.Append(diags...) + ipNetworks[i].DHCPRoutes = dhcproutes - network, err := client.CreateNetwork(ctx, &req) - if err != nil { - return diag.FromErr(err) + ipNetworks[i].Family = types.StringValue(ipnet.Family) + ipNetworks[i].Gateway = types.StringValue(ipnet.Gateway) } - d.SetId(network.UUID) + var diags diag.Diagnostics + data.IPNetwork, diags = types.ListValueFrom(ctx, data.IPNetwork.ElementType(ctx), ipNetworks) + respDiagnostics.Append(diags...) - return resourceNetworkRead(ctx, d, meta) + return respDiagnostics } -func resourceNetworkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client := meta.(*service.Service) +func buildIPNetworks(ctx context.Context, dataIPNetworks types.List) ([]upcloud.IPNetwork, diag.Diagnostics) { + var planNetworks []ipNetworkModel + respDiagnostics := dataIPNetworks.ElementsAs(ctx, &planNetworks, false) - req := request.GetNetworkDetailsRequest{ - UUID: d.Id(), - } + networks := make([]upcloud.IPNetwork, 0) - network, err := client.GetNetworkDetails(ctx, &req) - if err != nil { - return utils.HandleResourceError(d.Get("name").(string), d, err) - } + for _, ipnet := range planNetworks { + dhcpdns, diags := utils.SetAsSliceOfStrings(ctx, ipnet.DHCPDns) + respDiagnostics.Append(diags...) - _ = d.Set("name", network.Name) - _ = d.Set("type", network.Type) - _ = d.Set("zone", network.Zone) + dhcproutes, diags := utils.SetAsSliceOfStrings(ctx, ipnet.DHCPRoutes) + respDiagnostics.Append(diags...) - if network.Router != "" { - _ = d.Set("router", network.Router) + networks = append(networks, upcloud.IPNetwork{ + Address: ipnet.Address.ValueString(), + DHCP: utils.AsUpCloudBoolean(ipnet.DHCP), + DHCPDefaultRoute: utils.AsUpCloudBoolean(ipnet.DHCPDefaultRoute), + DHCPDns: dhcpdns, + DHCPRoutes: dhcproutes, + Family: ipnet.Family.ValueString(), + Gateway: ipnet.Gateway.ValueString(), + }) } - if len(network.IPNetworks) > 1 { - return diag.Errorf("too many ip_networks: %d", len(network.IPNetworks)) + return networks, respDiagnostics +} + +func (r *networkResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var data networkModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return } - if len(network.IPNetworks) == 1 { - ipn := map[string]interface{}{ - "address": network.IPNetworks[0].Address, - "dhcp": network.IPNetworks[0].DHCP.Bool(), - "dhcp_default_route": network.IPNetworks[0].DHCPDefaultRoute.Bool(), - "dhcp_dns": network.IPNetworks[0].DHCPDns, - "dhcp_routes": network.IPNetworks[0].DHCPRoutes, - "family": network.IPNetworks[0].Family, - "gateway": network.IPNetworks[0].Gateway, - } + apiReq := request.CreateNetworkRequest{ + Name: data.Name.ValueString(), + Zone: data.Zone.ValueString(), + Router: data.Router.ValueString(), + } - _ = d.Set("ip_network", []map[string]interface{}{ - ipn, - }) + networks, diags := buildIPNetworks(ctx, data.IPNetwork) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return } + apiReq.IPNetworks = networks - d.SetId(network.UUID) + network, err := r.client.CreateNetwork(ctx, &apiReq) + if err != nil { + resp.Diagnostics.AddError( + "Unable to create network", + utils.ErrorDiagnosticDetail(err), + ) + return + } - return nil + resp.Diagnostics.Append(setValues(ctx, &data, network)...) + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func resourceNetworkUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client := meta.(*service.Service) +func (r *networkResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var data networkModel + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) - req := request.ModifyNetworkRequest{ - UUID: d.Id(), + if resp.Diagnostics.HasError() { + return } - if d.HasChange("name") { - _, v := d.GetChange("name") - req.Name = v.(string) + network, err := r.client.GetNetworkDetails(ctx, &request.GetNetworkDetailsRequest{ + UUID: data.ID.ValueString(), + }) + if err != nil { + resp.Diagnostics.AddError( + "Unable to read network details", + utils.ErrorDiagnosticDetail(err), + ) + return } - if d.HasChange("ip_network") { - v := d.Get("ip_network") - - ipn := v.([]interface{})[0] - ipnConf := ipn.(map[string]interface{}) - - uipn := upcloud.IPNetwork{ - Address: ipnConf["address"].(string), - DHCP: upcloud.FromBool(ipnConf["dhcp"].(bool)), - DHCPDefaultRoute: upcloud.FromBool(ipnConf["dhcp_default_route"].(bool)), - Family: ipnConf["family"].(string), - Gateway: ipnConf["gateway"].(string), - } + resp.Diagnostics.Append(setValues(ctx, &data, network)...) + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} - for _, dns := range ipnConf["dhcp_dns"].(*schema.Set).List() { - uipn.DHCPDns = append(uipn.DHCPDns, dns.(string)) - } +func (r *networkResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var data networkModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) - for _, route := range ipnConf["dhcp_routes"].(*schema.Set).List() { - uipn.DHCPRoutes = append(uipn.DHCPRoutes, route.(string)) - } + apiReq := request.ModifyNetworkRequest{ + UUID: data.ID.ValueString(), + Name: data.Name.ValueString(), + } - req.IPNetworks = []upcloud.IPNetwork{uipn} + networks, diags := buildIPNetworks(ctx, data.IPNetwork) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return } + apiReq.IPNetworks = networks - network, err := client.ModifyNetwork(ctx, &req) + network, err := r.client.ModifyNetwork(ctx, &apiReq) if err != nil { - return diag.FromErr(err) + resp.Diagnostics.AddError( + "Unable to delete network", + utils.ErrorDiagnosticDetail(err), + ) + return } - if d.HasChange("router") { - _, v := d.GetChange("router") - if v.(string) == "" { - err = client.DetachNetworkRouter(ctx, &request.DetachNetworkRouterRequest{NetworkUUID: d.Id()}) - } else { - err = client.AttachNetworkRouter(ctx, &request.AttachNetworkRouterRequest{NetworkUUID: d.Id(), RouterUUID: v.(string)}) + if network.Router != data.Router.ValueString() { + err = r.client.AttachNetworkRouter(ctx, &request.AttachNetworkRouterRequest{ + NetworkUUID: data.ID.ValueString(), + RouterUUID: data.Router.ValueString(), + }) + if err != nil { + resp.Diagnostics.AddError( + "Unable to modify networks router attachment", + utils.ErrorDiagnosticDetail(err), + ) + return } + + network, err = r.client.GetNetworkDetails(ctx, &request.GetNetworkDetailsRequest{ + UUID: data.ID.ValueString(), + }) if err != nil { - return diag.FromErr(err) + resp.Diagnostics.AddError( + "Unable to read network details", + utils.ErrorDiagnosticDetail(err), + ) + return } } - d.SetId(network.UUID) - - return nil + resp.Diagnostics.Append(setValues(ctx, &data, network)...) + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func resourceNetworkDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client := meta.(*service.Service) - - req := request.DeleteNetworkRequest{ - UUID: d.Id(), - } - err := client.DeleteNetwork(ctx, &req) - if err != nil { - return diag.FromErr(err) +func (r *networkResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var data networkModel + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if err := r.client.DeleteNetwork(ctx, &request.DeleteNetworkRequest{ + UUID: data.ID.ValueString(), + }); err != nil { + resp.Diagnostics.AddError( + "Unable to delete network", + utils.ErrorDiagnosticDetail(err), + ) } +} - return nil +func (r *networkResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } diff --git a/internal/utils/error.go b/internal/utils/error.go index 7da3c7dd1..2e1c6ab66 100644 --- a/internal/utils/error.go +++ b/internal/utils/error.go @@ -19,3 +19,11 @@ func HandleResourceError(resourceName string, d *schema.ResourceData, err error) } return diag.FromErr(err) } + +func ErrorDiagnosticDetail(err error) string { + if err == nil { + return "" + } + + return "Error: " + err.Error() +} diff --git a/internal/utils/types.go b/internal/utils/types.go new file mode 100644 index 000000000..f779bc363 --- /dev/null +++ b/internal/utils/types.go @@ -0,0 +1,53 @@ +package utils + +import ( + "context" + + "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func AsUpCloudBoolean(b types.Bool) upcloud.Boolean { + if b.IsNull() || b.IsUnknown() { + return upcloud.Empty + } + + if b.ValueBool() { + return upcloud.True + } + + return upcloud.False +} + +func AsBool(b upcloud.Boolean) types.Bool { + if b.Empty() { + return types.BoolPointerValue(nil) + } + + return types.BoolValue(b.Bool()) +} + +func SetAsSliceOfStrings(ctx context.Context, set types.Set) ([]string, diag.Diagnostics) { + if set.IsNull() || set.IsUnknown() { + return nil, nil + } + + elements := make([]types.String, 0, len(set.Elements())) + strings := make([]string, 0, len(set.Elements())) + diags := set.ElementsAs(ctx, &elements, false) + + for _, element := range elements { + strings = append(strings, element.ValueString()) + } + + return strings, diags +} + +func NilAsEmptyList[T any](l []T) []T { + if l == nil { + return []T{} + } + + return l +} diff --git a/internal/validator/framework.go b/internal/validator/framework.go new file mode 100644 index 000000000..fbd9a85c7 --- /dev/null +++ b/internal/validator/framework.go @@ -0,0 +1,45 @@ +package validator + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +type frameworkStringValidator struct { + validateFunc schema.SchemaValidateFunc //nolint:staticcheck // Network validators use the deprecated schema.SchemaValidateFunc +} + +func (v *frameworkStringValidator) Description(_ context.Context) string { + return "" +} + +func (v *frameworkStringValidator) MarkdownDescription(_ context.Context) string { + return "" +} + +func (v *frameworkStringValidator) ValidateString(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { + if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() { + return + } + + warnings, errors := v.validateFunc(req.ConfigValue.ValueString(), req.Path.String()) + + for _, warning := range warnings { + resp.Diagnostics = append(resp.Diagnostics, diag.NewWarningDiagnostic(warning, "")) + } + + for _, err := range errors { + resp.Diagnostics = append(resp.Diagnostics, diag.NewErrorDiagnostic(err.Error(), "")) + } +} + +var _ validator.String = &frameworkStringValidator{} + +func NewFrameworkStringValidator(validate schema.SchemaValidateFunc) validator.String { //nolint:staticcheck // Network validators use the deprecated schema.SchemaValidateFunc + return &frameworkStringValidator{ + validateFunc: validate, + } +} diff --git a/main.go b/main.go index 4684b3663..16b27f574 100644 --- a/main.go +++ b/main.go @@ -2,29 +2,35 @@ package main // import "github.com/UpCloudLtd/terraform-provider-upcloud" import ( "flag" + "log" "github.com/UpCloudLtd/terraform-provider-upcloud/upcloud" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" + "github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server" ) func main() { - var debugMode bool - var debugProviderAddr string - - flag.BoolVar(&debugMode, "debug", false, "set to true to run the provider with support for debuggers like delve") - flag.StringVar(&debugProviderAddr, "debug-provider-addr", "registry.terraform.io/upcloudltd/upcloud", - "use same provider address as used in your configs") + var debug bool + flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve") flag.Parse() - opts := &plugin.ServeOpts{ - ProviderFunc: func() *schema.Provider { - return upcloud.Provider() - }, - Debug: debugMode, - ProviderAddr: debugProviderAddr, + factory, err := upcloud.NewProviderServerFactory() + if err != nil { + log.Fatal(err) } - plugin.Serve(opts) + var serveOpts []tf5server.ServeOpt + + if debug { + serveOpts = append(serveOpts, tf5server.WithManagedDebug()) + } + + err = tf5server.Serve( + "registry.terraform.io/upcloudltd/upcloud", + factory, + serveOpts..., + ) + if err != nil { + log.Fatal(err) + } } diff --git a/upcloud/datasource_upcloud_hosts_test.go b/upcloud/datasource_upcloud_hosts_test.go index 9500a7b2f..5479e0288 100644 --- a/upcloud/datasource_upcloud_hosts_test.go +++ b/upcloud/datasource_upcloud_hosts_test.go @@ -6,18 +6,15 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccUpCloudHosts_basic(t *testing.T) { - var providers []*schema.Provider - resourceName := "data.upcloud_hosts.empty" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataSourceUpCloudHostsConfigEmpty(), diff --git a/upcloud/datasource_upcloud_ip_addresses_test.go b/upcloud/datasource_upcloud_ip_addresses_test.go index 726d3b726..f14e2b044 100644 --- a/upcloud/datasource_upcloud_ip_addresses_test.go +++ b/upcloud/datasource_upcloud_ip_addresses_test.go @@ -5,18 +5,15 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccDataSourceUpCloudIPAddresses_basic(t *testing.T) { - var providers []*schema.Provider - resourceName := "data.upcloud_ip_addresses.empty" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataSourceUpCloudIPAddressesConfigEmpty(), diff --git a/upcloud/datasource_upcloud_managed_database_mysql_sessions_test.go b/upcloud/datasource_upcloud_managed_database_mysql_sessions_test.go index 52f2d4dd1..d5c4e7492 100644 --- a/upcloud/datasource_upcloud_managed_database_mysql_sessions_test.go +++ b/upcloud/datasource_upcloud_managed_database_mysql_sessions_test.go @@ -5,17 +5,15 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccDataSourceUpcloudManagedDatabaseMySQLSessions(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/data_source_mysql_sessions_s1.tf") - var providers []*schema.Provider name := "data.upcloud_managed_database_mysql_sessions.mysql_sessions" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/datasource_upcloud_managed_database_opensearch_indices_test.go b/upcloud/datasource_upcloud_managed_database_opensearch_indices_test.go index 2ff161ff1..19e82f657 100644 --- a/upcloud/datasource_upcloud_managed_database_opensearch_indices_test.go +++ b/upcloud/datasource_upcloud_managed_database_opensearch_indices_test.go @@ -6,20 +6,18 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccDataSourceUpcloudManagedDatabaseOpenSearchIndices(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/data_source_opensearch_indices_s1.tf") - var providers []*schema.Provider name := "data.upcloud_managed_database_opensearch_indices.opensearch_indices" prop := func(name string) string { return fmt.Sprintf("indices.0.%s", name) } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/datasource_upcloud_managed_database_postgresql_sessions_test.go b/upcloud/datasource_upcloud_managed_database_postgresql_sessions_test.go index af8775c23..2010f6f60 100644 --- a/upcloud/datasource_upcloud_managed_database_postgresql_sessions_test.go +++ b/upcloud/datasource_upcloud_managed_database_postgresql_sessions_test.go @@ -5,17 +5,15 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccDataSourceUpcloudManagedDatabasePostgreSQLSessions(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/data_source_postgresql_sessions_s1.tf") - var providers []*schema.Provider name := "data.upcloud_managed_database_postgresql_sessions.postgresql_sessions" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/datasource_upcloud_managed_database_redis_sessions_test.go b/upcloud/datasource_upcloud_managed_database_redis_sessions_test.go index d86156c75..60b5b9688 100644 --- a/upcloud/datasource_upcloud_managed_database_redis_sessions_test.go +++ b/upcloud/datasource_upcloud_managed_database_redis_sessions_test.go @@ -5,17 +5,15 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccDataSourceUpcloudManagedDatabaseRedisSessions(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/data_source_redis_sessions_s1.tf") - var providers []*schema.Provider name := "data.upcloud_managed_database_redis_sessions.redis_sessions" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/datasource_upcloud_managed_object_storage_policies_test.go b/upcloud/datasource_upcloud_managed_object_storage_policies_test.go index e706f7e89..0b1749f60 100644 --- a/upcloud/datasource_upcloud_managed_object_storage_policies_test.go +++ b/upcloud/datasource_upcloud_managed_object_storage_policies_test.go @@ -5,17 +5,15 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccDataSourceUpcloudManagedObjectStoragePolicies(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_object_storage/data_source_managed_object_storage_policies_s1.tf") - var providers []*schema.Provider name := "data.upcloud_managed_object_storage_policies.this" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/datasource_upcloud_managed_object_storage_regions_test.go b/upcloud/datasource_upcloud_managed_object_storage_regions_test.go index 728e752e6..3b43413a0 100644 --- a/upcloud/datasource_upcloud_managed_object_storage_regions_test.go +++ b/upcloud/datasource_upcloud_managed_object_storage_regions_test.go @@ -5,22 +5,24 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccDataSourceUpcloudManagedObjectStorageRegions(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_object_storage/data_source_managed_object_storage_regions_s1.tf") - var providers []*schema.Provider name := "data.upcloud_managed_object_storage_regions.this" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(name, "regions.#"), + resource.TestCheckTypeSetElemNestedAttrs(name, "regions.*", map[string]string{ + "name": "europe-1", + "primary_zone": "fi-hel2", + }), ), }, }, diff --git a/upcloud/datasource_upcloud_networks_test.go b/upcloud/datasource_upcloud_networks_test.go index 197c42519..b1a987768 100644 --- a/upcloud/datasource_upcloud_networks_test.go +++ b/upcloud/datasource_upcloud_networks_test.go @@ -8,18 +8,15 @@ import ( "testing" "time" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccUpCloudNetworksNoZone(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccNetworksConfig("", ""), @@ -30,11 +27,9 @@ func TestAccUpCloudNetworksNoZone(t *testing.T) { } func TestAccUpCloudNetworksWithZone(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccNetworksConfig("fi-hel1", ""), @@ -45,11 +40,9 @@ func TestAccUpCloudNetworksWithZone(t *testing.T) { } func TestAccUpCloudNetworksWithFilter(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccNetworksConfig("", "^Public.*"), diff --git a/upcloud/datasource_upcloud_storage_test.go b/upcloud/datasource_upcloud_storage_test.go index e14255454..58a0a4783 100644 --- a/upcloud/datasource_upcloud_storage_test.go +++ b/upcloud/datasource_upcloud_storage_test.go @@ -4,17 +4,14 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccDataSourceUpCloudStorage(t *testing.T) { - var providers []*schema.Provider - templateResourceName := "data.upcloud_storage.ubuntu_template" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: dataSourceUpCloudStorageTestTemplateConfig(), diff --git a/upcloud/datasource_upcloud_tags_test.go b/upcloud/datasource_upcloud_tags_test.go index bb51cdbc5..10d002f25 100644 --- a/upcloud/datasource_upcloud_tags_test.go +++ b/upcloud/datasource_upcloud_tags_test.go @@ -6,19 +6,16 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccDataSourceUpCloudTags_basic(t *testing.T) { - var providers []*schema.Provider - resourceName := "data.upcloud_tags.empty" tagName := fmt.Sprintf("tag-%s", acctest.RandString(10)) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataSourceUpCloudTagsConfigEmpty(tagName), diff --git a/upcloud/datasource_upcloud_zone_test.go b/upcloud/datasource_upcloud_zone_test.go index 75e6d4ed6..4ad5731f5 100644 --- a/upcloud/datasource_upcloud_zone_test.go +++ b/upcloud/datasource_upcloud_zone_test.go @@ -5,12 +5,9 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccDataSourceUpCloudZone_basic(t *testing.T) { - var providers []*schema.Provider - resourceName := "data.upcloud_zone.my_zone" expectedZoneName := "uk-lon1" @@ -18,8 +15,8 @@ func TestAccDataSourceUpCloudZone_basic(t *testing.T) { expectedPublic := "true" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataSourceUpCloudZoneConfig(expectedZoneName), diff --git a/upcloud/datasource_upcloud_zones_test.go b/upcloud/datasource_upcloud_zones_test.go index 0542d23e1..1c32c6eda 100644 --- a/upcloud/datasource_upcloud_zones_test.go +++ b/upcloud/datasource_upcloud_zones_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) @@ -18,13 +17,11 @@ const ( ) func TestAccDataSourceUpCloudZones_default(t *testing.T) { - var providers []*schema.Provider - resourceName := "data.upcloud_zones.empty" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataSourceUpCloudZonesConfigEmpty(), @@ -37,14 +34,12 @@ func TestAccDataSourceUpCloudZones_default(t *testing.T) { } func TestAccDataSourceUpCloudZones_public(t *testing.T) { - var providers []*schema.Provider - filterType := publicFilter resourceName := fmt.Sprintf("data.upcloud_zones.%s", filterType) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataSourceUpCloudZonesConfigFilter(filterType), @@ -59,14 +54,12 @@ func TestAccDataSourceUpCloudZones_public(t *testing.T) { } func TestAccDataSourceUpCloudZones_private(t *testing.T) { - var providers []*schema.Provider - filterType := privateFilter resourceName := fmt.Sprintf("data.upcloud_zones.%s", filterType) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataSourceUpCloudZonesConfigFilter(filterType), @@ -80,14 +73,12 @@ func TestAccDataSourceUpCloudZones_private(t *testing.T) { } func TestAccDataSourceUpCloudZones_all(t *testing.T) { - var providers []*schema.Provider - filterType := allFilter resourceName := fmt.Sprintf("data.upcloud_zones.%s", filterType) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataSourceUpCloudZonesConfigFilter(filterType), diff --git a/upcloud/muxserver.go b/upcloud/muxserver.go new file mode 100644 index 000000000..37500d44c --- /dev/null +++ b/upcloud/muxserver.go @@ -0,0 +1,24 @@ +package upcloud + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-mux/tf5muxserver" +) + +func NewProviderServerFactory() (func() tfprotov5.ProviderServer, error) { + providers := []func() tfprotov5.ProviderServer{ + providerserver.NewProtocol5(New()), + Provider().GRPCProvider, + } + + ctx := context.Background() + muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...) + if err != nil { + return nil, err + } + + return muxServer.ProviderServer, nil +} diff --git a/upcloud/provider.go b/upcloud/provider.go index 98fe22de9..5fc3411c7 100644 --- a/upcloud/provider.go +++ b/upcloud/provider.go @@ -2,176 +2,133 @@ package upcloud import ( "context" - "fmt" - "net/http" + "os" "time" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - - "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/client" - "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/config" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/cloud" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/database" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/firewall" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/gateway" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/ip" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/kubernetes" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/loadbalancer" "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/managedobjectstorage" "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/network" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/objectstorage" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/router" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/server" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/servergroup" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/storage" - "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/tag" - retryablehttp "github.com/hashicorp/go-retryablehttp" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/provider" + "github.com/hashicorp/terraform-plugin-framework/provider/schema" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" ) -func Provider() *schema.Provider { - return &schema.Provider{ - Schema: map[string]*schema.Schema{ - "username": { - Type: schema.TypeString, +const ( + usernameDescription = "UpCloud username with API access. Can also be configured using the `UPCLOUD_USERNAME` environment variable." + passwordDescription = "Password for UpCloud API user. Can also be configured using the `UPCLOUD_PASSWORD` environment variable." + requestTimeoutDescription = "The duration (in seconds) that the provider waits for an HTTP request towards UpCloud API to complete. Defaults to 120 seconds" +) + +type upcloudProviderModel struct { + Username types.String `tfsdk:"username"` + Password types.String `tfsdk:"password"` + RetryWaitMinSec types.Int64 `tfsdk:"retry_wait_min_sec"` + RetryWaitMaxSec types.Int64 `tfsdk:"retry_wait_max_sec"` + RetryMax types.Int64 `tfsdk:"retry_max"` + RequestTimeoutSec types.Int64 `tfsdk:"request_timeout_sec"` +} + +type upcloudProvider struct{} + +var _ provider.Provider = New() + +func New() provider.Provider { + return &upcloudProvider{} +} + +func (p *upcloudProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) { + resp.TypeName = "upcloud" + resp.Version = config.Version +} + +func (p *upcloudProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "username": schema.StringAttribute{ + Description: usernameDescription, Optional: true, - DefaultFunc: schema.EnvDefaultFunc("UPCLOUD_USERNAME", nil), - Description: "UpCloud username with API access. Can also be configured using the `UPCLOUD_USERNAME` environment variable.", }, - "password": { - Type: schema.TypeString, + "password": schema.StringAttribute{ + Description: passwordDescription, Optional: true, - DefaultFunc: schema.EnvDefaultFunc("UPCLOUD_PASSWORD", nil), - Description: "Password for UpCloud API user. Can also be configured using the `UPCLOUD_PASSWORD` environment variable.", }, - "retry_wait_min_sec": { - Type: schema.TypeInt, + "retry_wait_min_sec": schema.Int64Attribute{ Optional: true, - Default: 1, Description: "Minimum time to wait between retries", }, - "retry_wait_max_sec": { - Type: schema.TypeInt, + "retry_wait_max_sec": schema.Int64Attribute{ Optional: true, - Default: 30, Description: "Maximum time to wait between retries", }, - "retry_max": { - Type: schema.TypeInt, + "retry_max": schema.Int64Attribute{ Optional: true, - Default: 4, Description: "Maximum number of retries", }, - "request_timeout_sec": { - Type: schema.TypeInt, + "request_timeout_sec": schema.Int64Attribute{ Optional: true, - Default: 120, - Description: "The duration (in seconds) that the provider waits for an HTTP request towards UpCloud API to complete. Defaults to 120 seconds", + Description: requestTimeoutDescription, }, }, + } +} - ResourcesMap: map[string]*schema.Resource{ - "upcloud_server": server.ResourceServer(), - "upcloud_server_group": servergroup.ResourceServerGroup(), - "upcloud_router": router.ResourceRouter(), - "upcloud_storage": storage.ResourceStorage(), - "upcloud_firewall_rules": firewall.ResourceFirewallRules(), - "upcloud_tag": tag.ResourceTag(), - "upcloud_network": network.ResourceNetwork(), - "upcloud_gateway": gateway.ResourceGateway(), - "upcloud_gateway_connection": gateway.ResourceConnection(), - "upcloud_gateway_connection_tunnel": gateway.ResourceTunnel(), - "upcloud_floating_ip_address": ip.ResourceFloatingIPAddress(), - "upcloud_object_storage": objectstorage.ResourceObjectStorage(), - "upcloud_managed_database_postgresql": database.ResourcePostgreSQL(), - "upcloud_managed_database_mysql": database.ResourceMySQL(), - "upcloud_managed_database_redis": database.ResourceRedis(), - "upcloud_managed_database_opensearch": database.ResourceOpenSearch(), - "upcloud_managed_database_user": database.ResourceUser(), - "upcloud_managed_database_logical_database": database.ResourceLogicalDatabase(), - "upcloud_managed_object_storage": managedobjectstorage.ResourceManagedObjectStorage(), - "upcloud_managed_object_storage_policy": managedobjectstorage.ResourceManagedObjectStoragePolicy(), - "upcloud_managed_object_storage_user": managedobjectstorage.ResourceManagedObjectStorageUser(), - "upcloud_managed_object_storage_user_access_key": managedobjectstorage.ResourceManagedObjectStorageUserAccessKey(), - "upcloud_managed_object_storage_user_policy": managedobjectstorage.ResourceManagedObjectStorageUserPolicy(), - "upcloud_loadbalancer": loadbalancer.ResourceLoadBalancer(), - "upcloud_loadbalancer_resolver": loadbalancer.ResourceResolver(), - "upcloud_loadbalancer_backend": loadbalancer.ResourceBackend(), - "upcloud_loadbalancer_backend_tls_config": loadbalancer.ResourceBackendTLSConfig(), - "upcloud_loadbalancer_static_backend_member": loadbalancer.ResourceStaticBackendMember(), - "upcloud_loadbalancer_dynamic_backend_member": loadbalancer.ResourceDynamicBackendMember(), - "upcloud_loadbalancer_frontend": loadbalancer.ResourceFrontend(), - "upcloud_loadbalancer_frontend_rule": loadbalancer.ResourceFrontendRule(), - "upcloud_loadbalancer_frontend_tls_config": loadbalancer.ResourceFrontendTLSConfig(), - "upcloud_loadbalancer_dynamic_certificate_bundle": loadbalancer.ResourceDynamicCertificateBundle(), - "upcloud_loadbalancer_manual_certificate_bundle": loadbalancer.ResourceManualCertificateBundle(), - "upcloud_kubernetes_cluster": kubernetes.ResourceCluster(), - "upcloud_kubernetes_node_group": kubernetes.ResourceNodeGroup(), - }, - - DataSourcesMap: map[string]*schema.Resource{ - "upcloud_zone": cloud.DataSourceZone(), - "upcloud_zones": cloud.DataSourceZones(), - "upcloud_networks": network.DataSourceNetworks(), - "upcloud_hosts": cloud.DataSourceHosts(), - "upcloud_ip_addresses": ip.DataSourceIPAddresses(), - "upcloud_tags": tag.DataSourceTags(), - "upcloud_storage": storage.DataSourceStorage(), - "upcloud_kubernetes_cluster": kubernetes.DataSourceCluster(), - "upcloud_managed_database_opensearch_indices": database.DataSourceOpenSearchIndices(), - "upcloud_managed_database_mysql_sessions": database.DataSourceSessionsMySQL(), - "upcloud_managed_database_postgresql_sessions": database.DataSourceSessionsPostgreSQL(), - "upcloud_managed_database_redis_sessions": database.DataSourceSessionsRedis(), - "upcloud_managed_object_storage_regions": managedobjectstorage.DataSourceManagedObjectStorageRegions(), - "upcloud_managed_object_storage_policies": managedobjectstorage.DataSourceManagedObjectStoragePolicies(), - }, - - ConfigureContextFunc: providerConfigure, +func withDefault[T comparable](val T, def T) T { + var empty T + if val == empty { + return def } + return val } -func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { - var diags diag.Diagnostics +func withEnvDefault(val string, env string) string { + return withDefault(val, os.Getenv(env)) +} - requestTimeout := time.Duration(d.Get("request_timeout_sec").(int)) * time.Second +func (p *upcloudProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { + var model upcloudProviderModel + if diags := req.Config.Get(ctx, &model); diags.HasError() { + resp.Diagnostics = append(resp.Diagnostics, diags...) + return + } + requestTimeout := time.Duration(withDefault(model.RequestTimeoutSec.ValueInt64(), 120)) * time.Second config := Config{ - Username: d.Get("username").(string), - Password: d.Get("password").(string), + Username: withEnvDefault(model.Username.ValueString(), "UPCLOUD_USERNAME"), + Password: withEnvDefault(model.Password.ValueString(), "UPCLOUD_PASSWORD"), } httpClient := retryablehttp.NewClient() - httpClient.RetryWaitMin = time.Duration(d.Get("retry_wait_min_sec").(int)) * time.Second - httpClient.RetryWaitMax = time.Duration(d.Get("retry_wait_max_sec").(int)) * time.Second - httpClient.RetryMax = d.Get("retry_max").(int) + httpClient.RetryWaitMin = time.Duration(withDefault(model.RetryWaitMinSec.ValueInt64(), 1)) * time.Second + httpClient.RetryWaitMax = time.Duration(withDefault(model.RetryWaitMaxSec.ValueInt64(), 30)) * time.Second + httpClient.RetryMax = int(withDefault(model.RetryMax.ValueInt64(), 4)) service := newUpCloudServiceConnection( - d.Get("username").(string), - d.Get("password").(string), + config.Username, + config.Password, httpClient.HTTPClient, requestTimeout, ) _, err := config.checkLogin(service) if err != nil { - return nil, diag.FromErr(err) + resp.Diagnostics.AddError("Authentication failed", "Failed to authenticate to UpCloud API with given credentials") } - return service, diags + resp.ResourceData = service + resp.DataSourceData = service } -func newUpCloudServiceConnection(username, password string, httpClient *http.Client, requestTimeout time.Duration) *service.Service { - providerClient := client.New( - username, - password, - client.WithHTTPClient(httpClient), - client.WithTimeout(requestTimeout), - ) - - providerClient.UserAgent = fmt.Sprintf("terraform-provider-upcloud/%s", config.Version) +func (p *upcloudProvider) Resources(_ context.Context) []func() resource.Resource { + return []func() resource.Resource{ + network.NewNetworkResource, + } +} - return service.New(providerClient) +func (p *upcloudProvider) DataSources(_ context.Context) []func() datasource.DataSource { + return []func() datasource.DataSource{ + managedobjectstorage.NewRegionsDataSource, + } } diff --git a/upcloud/provider_test.go b/upcloud/provider_test.go index 32479d97b..848f3f887 100644 --- a/upcloud/provider_test.go +++ b/upcloud/provider_test.go @@ -5,36 +5,24 @@ import ( "os" "testing" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) var ( - testAccProviders map[string]*schema.Provider - testAccProviderFactories func(providers *[]*schema.Provider) map[string]func() (*schema.Provider, error) + testAccProviderFactories map[string]func() (tfprotov5.ProviderServer, error) testAccProvider *schema.Provider - testAccProviderFunc func() *schema.Provider ) func init() { testAccProvider = Provider() - testAccProviders = map[string]*schema.Provider{ - "upcloud": testAccProvider, - } + testAccProviderFactories = make(map[string]func() (tfprotov5.ProviderServer, error)) - testAccProviderFactories = func(providers *[]*schema.Provider) map[string]func() (*schema.Provider, error) { - providerNames := []string{"upcloud"} - factories := make(map[string]func() (*schema.Provider, error), len(providerNames)) - for _, name := range providerNames { - p := Provider() - factories[name] = func() (*schema.Provider, error) { //nolint:unparam - return p, nil - } - *providers = append(*providers, p) - } - return factories + testAccProviderFactories["upcloud"] = func() (tfprotov5.ProviderServer, error) { + factory, err := NewProviderServerFactory() + return factory(), err } - testAccProviderFunc = func() *schema.Provider { return testAccProvider } } func TestProvider(t *testing.T) { diff --git a/upcloud/resource_upcloud_firewall_rules_test.go b/upcloud/resource_upcloud_firewall_rules_test.go index 973ec547c..1ad04cccb 100644 --- a/upcloud/resource_upcloud_firewall_rules_test.go +++ b/upcloud/resource_upcloud_firewall_rules_test.go @@ -8,7 +8,6 @@ import ( "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud" "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request" "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -17,14 +16,13 @@ import ( const firewallRulesResourceName = "upcloud_firewall_rules.my_rule" func TestUpcloudFirewallRules_basic(t *testing.T) { - var providers []*schema.Provider var firewallRules upcloud.FirewallRules resourceName := firewallRulesResourceName resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckFirewallRulesDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckFirewallRulesDestroy, Steps: []resource.TestStep{ { Config: testUpcloudFirewallRulesInstanceConfig(), @@ -66,15 +64,13 @@ func TestUpcloudFirewallRules_basic(t *testing.T) { } func TestUpcloudFirewallRules_update(t *testing.T) { - var providers []*schema.Provider - var firewallRules upcloud.FirewallRules resourceName := "upcloud_firewall_rules.my_rule" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckFirewallRulesDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckFirewallRulesDestroy, Steps: []resource.TestStep{ { Config: testUpcloudFirewallRulesInstanceConfig(), @@ -95,15 +91,13 @@ func TestUpcloudFirewallRules_update(t *testing.T) { } func TestUpcloudFirewallRules_import(t *testing.T) { - var providers []*schema.Provider - var firewallRules upcloud.FirewallRules resourceName := firewallRulesResourceName resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckFirewallRulesDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckFirewallRulesDestroy, Steps: []resource.TestStep{ { Config: testUpcloudFirewallRulesInstanceConfig(), diff --git a/upcloud/resource_upcloud_floating_ip_address_test.go b/upcloud/resource_upcloud_floating_ip_address_test.go index f7393e5cd..dc77dc566 100644 --- a/upcloud/resource_upcloud_floating_ip_address_test.go +++ b/upcloud/resource_upcloud_floating_ip_address_test.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) const ( @@ -19,8 +18,6 @@ const ( ) func TestAccUpcloudFloatingIPAddress_basic(t *testing.T) { - var providers []*schema.Provider - resourceName := floatingIPResourceName expectedZone := zone expectedMacAddress := "" @@ -28,8 +25,8 @@ func TestAccUpcloudFloatingIPAddress_basic(t *testing.T) { expectedAccess := "public" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testUpcloudFloatingIPAddressBasicConfig(), @@ -46,16 +43,14 @@ func TestAccUpcloudFloatingIPAddress_basic(t *testing.T) { } func TestAccUpcloudFloatingIPAddress_create_with_server(t *testing.T) { - var providers []*schema.Provider - serverResourceName := "upcloud_server.my_server" expectedZone := zone expectedFamily := "IPv4" expectedAccess := "public" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testUpcloudFloatingIPAddressCreateWithServerConfig([]string{"my_server"}, 0), @@ -73,14 +68,12 @@ func TestAccUpcloudFloatingIPAddress_create_with_server(t *testing.T) { } func TestAccUpcloudFloatingIPAddress_switch_between_servers(t *testing.T) { - var providers []*schema.Provider - firstServerResourceName := "upcloud_server.my_first_server" secondServerResourceName := "upcloud_server.my_second_server" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testUpcloudFloatingIPAddressCreateWithServerConfig([]string{"my_first_server", "my_second_server"}, 0), @@ -127,13 +120,12 @@ func testAccCheckFloatingIP(floatingIPResourceName, serverResourceName string) r } func TestAccUpcloudFloatingIPAddress_import(t *testing.T) { - var providers []*schema.Provider resourceName := floatingIPResourceName resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckFloatingIPAddressDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckFloatingIPAddressDestroy, Steps: []resource.TestStep{ { Config: testUpcloudFloatingIPAddressBasicConfig(), diff --git a/upcloud/resource_upcloud_gateway_test.go b/upcloud/resource_upcloud_gateway_test.go index b67f30d6a..376b7369f 100644 --- a/upcloud/resource_upcloud_gateway_test.go +++ b/upcloud/resource_upcloud_gateway_test.go @@ -7,14 +7,12 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudGateway(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_gateway/gateway_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_gateway/gateway_s2.tf") - var providers []*schema.Provider name := "upcloud_gateway.this" conn1Name := "upcloud_gateway_connection.this" conn2Name := "upcloud_gateway_connection.this2" @@ -22,8 +20,8 @@ func TestAccUpcloudGateway(t *testing.T) { tunnel2Name := "upcloud_gateway_connection_tunnel.this2" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, @@ -193,11 +191,9 @@ func TestAccUpcloudGateway_LabelsValidation(t *testing.T) { }) } - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - Steps: steps, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + Steps: steps, }) } diff --git a/upcloud/resource_upcloud_kubernetes_test.go b/upcloud/resource_upcloud_kubernetes_test.go index f8f72aae7..182f5cfc4 100644 --- a/upcloud/resource_upcloud_kubernetes_test.go +++ b/upcloud/resource_upcloud_kubernetes_test.go @@ -5,21 +5,19 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudKubernetes(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_kubernetes/kubernetes_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_kubernetes/kubernetes_s2.tf") - var providers []*schema.Provider cName := "upcloud_kubernetes_cluster.main" g1Name := "upcloud_kubernetes_node_group.g1" g2Name := "upcloud_kubernetes_node_group.g2" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, @@ -73,12 +71,11 @@ func TestAccUpcloudKubernetes_labels(t *testing.T) { testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_kubernetes/kubernetes_labels_s2.tf") testDataS3 := utils.ReadTestDataFile(t, "testdata/upcloud_kubernetes/kubernetes_labels_s3.tf") - var providers []*schema.Provider cluster := "upcloud_kubernetes_cluster.main" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/resource_upcloud_loadbalancer_test.go b/upcloud/resource_upcloud_loadbalancer_test.go index a01190f81..186652bf2 100644 --- a/upcloud/resource_upcloud_loadbalancer_test.go +++ b/upcloud/resource_upcloud_loadbalancer_test.go @@ -6,7 +6,6 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudLoadBalancer(t *testing.T) { @@ -15,7 +14,6 @@ func TestAccUpcloudLoadBalancer(t *testing.T) { testDataS3 := utils.ReadTestDataFile(t, "testdata/upcloud_loadbalancer/loadbalancer_s3.tf") testDataS4 := utils.ReadTestDataFile(t, "testdata/upcloud_loadbalancer/loadbalancer_s4.tf") - var providers []*schema.Provider lbName := "upcloud_loadbalancer.lb" dnsName := "upcloud_loadbalancer_resolver.lb_dns_1" be1Name := "upcloud_loadbalancer_backend.lb_be_1" @@ -31,8 +29,8 @@ func TestAccUpcloudLoadBalancer(t *testing.T) { cbm1Name := "upcloud_loadbalancer_manual_certificate_bundle.lb_cb_m1" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, @@ -219,11 +217,9 @@ func TestAccUpcloudLoadBalancer_HTTPRedirectValidation(t *testing.T) { testDataE3 := utils.ReadTestDataFile(t, "testdata/upcloud_loadbalancer/loadbalancer_e3.tf") testDataE4 := utils.ReadTestDataFile(t, "testdata/upcloud_loadbalancer/loadbalancer_e4.tf") - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataE1, diff --git a/upcloud/resource_upcloud_managed_database_mysql_test.go b/upcloud/resource_upcloud_managed_database_mysql_test.go index cb2bc17c0..b97e78857 100644 --- a/upcloud/resource_upcloud_managed_database_mysql_test.go +++ b/upcloud/resource_upcloud_managed_database_mysql_test.go @@ -6,21 +6,19 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudManagedDatabaseMySQLProperties(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/mysql_properties_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/mysql_properties_s2.tf") - var providers []*schema.Provider name := "upcloud_managed_database_mysql.mysql_properties" prop := func(name string) string { return fmt.Sprintf("properties.0.%s", name) } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/resource_upcloud_managed_database_opensearch_test.go b/upcloud/resource_upcloud_managed_database_opensearch_test.go index 0941bdfb8..50907ae24 100644 --- a/upcloud/resource_upcloud_managed_database_opensearch_test.go +++ b/upcloud/resource_upcloud_managed_database_opensearch_test.go @@ -6,21 +6,19 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudManagedDatabaseOpenSearchProperties(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/opensearch_properties_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/opensearch_properties_s2.tf") - var providers []*schema.Provider name := "upcloud_managed_database_opensearch.opensearch_properties" prop := func(name string) string { return fmt.Sprintf("properties.0.%s", name) } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/resource_upcloud_managed_database_postgresql_test.go b/upcloud/resource_upcloud_managed_database_postgresql_test.go index 0565fa644..7bd2ba58a 100644 --- a/upcloud/resource_upcloud_managed_database_postgresql_test.go +++ b/upcloud/resource_upcloud_managed_database_postgresql_test.go @@ -6,21 +6,19 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudManagedDatabasePostgreSQLProperties(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/postgresql_properties_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/postgresql_properties_s2.tf") - var providers []*schema.Provider name := "upcloud_managed_database_postgresql.postgresql_properties" prop := func(name string) string { return fmt.Sprintf("properties.0.%s", name) } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/resource_upcloud_managed_database_redis_test.go b/upcloud/resource_upcloud_managed_database_redis_test.go index e72ae87e0..6bb78d308 100644 --- a/upcloud/resource_upcloud_managed_database_redis_test.go +++ b/upcloud/resource_upcloud_managed_database_redis_test.go @@ -6,21 +6,19 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudManagedDatabaseRedisProperties(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/redis_properties_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/redis_properties_s2.tf") - var providers []*schema.Provider name := "upcloud_managed_database_redis.redis_properties" prop := func(name string) string { return fmt.Sprintf("properties.0.%s", name) } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/resource_upcloud_managed_database_test.go b/upcloud/resource_upcloud_managed_database_test.go index aac250eb1..23dcabb2e 100644 --- a/upcloud/resource_upcloud_managed_database_test.go +++ b/upcloud/resource_upcloud_managed_database_test.go @@ -7,7 +7,6 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func withPrefixDB(text string) string { @@ -18,7 +17,6 @@ func TestAccUpcloudManagedDatabase(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/managed_database_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_database/managed_database_s2.tf") - var providers []*schema.Provider pg1Name := "upcloud_managed_database_postgresql.pg1" pg2Name := "upcloud_managed_database_postgresql.pg2" msql1Name := "upcloud_managed_database_mysql.msql1" @@ -40,8 +38,8 @@ func TestAccUpcloudManagedDatabase(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/resource_upcloud_managed_object_storage_test.go b/upcloud/resource_upcloud_managed_object_storage_test.go index d916500f5..288e4046f 100644 --- a/upcloud/resource_upcloud_managed_object_storage_test.go +++ b/upcloud/resource_upcloud_managed_object_storage_test.go @@ -7,20 +7,18 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudManagedObjectStorage(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_object_storage/managed_object_storage_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_object_storage/managed_object_storage_s2.tf") - var providers []*schema.Provider this := "upcloud_managed_object_storage.this" minimal := "upcloud_managed_object_storage.minimal" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, @@ -82,11 +80,9 @@ func TestAccUpcloudManagedObjectStorage_LabelsValidation(t *testing.T) { }) } - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - Steps: steps, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + Steps: steps, }) } diff --git a/upcloud/resource_upcloud_managed_object_storage_user_test.go b/upcloud/resource_upcloud_managed_object_storage_user_test.go index ae7842638..c2a594a1b 100644 --- a/upcloud/resource_upcloud_managed_object_storage_user_test.go +++ b/upcloud/resource_upcloud_managed_object_storage_user_test.go @@ -5,14 +5,12 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudManagedObjectStorageUser(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_object_storage/managed_object_storage_user_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_managed_object_storage/managed_object_storage_user_s2.tf") - var providers []*schema.Provider storage := "upcloud_managed_object_storage.user" policy := "upcloud_managed_object_storage_policy.user" user := "upcloud_managed_object_storage_user.user" @@ -20,8 +18,8 @@ func TestAccUpcloudManagedObjectStorageUser(t *testing.T) { userPolicy := "upcloud_managed_object_storage_user_policy.user" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/resource_upcloud_network_test.go b/upcloud/resource_upcloud_network_test.go index 58f02250a..b87fed13e 100644 --- a/upcloud/resource_upcloud_network_test.go +++ b/upcloud/resource_upcloud_network_test.go @@ -9,34 +9,33 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccUpCloudNetwork_basic(t *testing.T) { - var providers []*schema.Provider - netName := fmt.Sprintf("test_network_%s", acctest.RandString(5)) subnet := acctest.RandIntRange(0, 250) cidr := fmt.Sprintf("10.0.%d.0/24", subnet) gateway := fmt.Sprintf("10.0.%d.1", subnet) + config := testAccNetworkConfig( + netName, + "fi-hel1", + cidr, + gateway, + true, + false, + false, + []string{"10.0.0.2", "10.0.0.3"}, + []string{"192.168.0.0/24", "192.168.100.0/32"}, + ) + resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { - Config: testAccNetworkConfig( - netName, - "fi-hel1", - cidr, - gateway, - true, - false, - false, - []string{"10.0.0.2", "10.0.0.3"}, - []string{"192.168.0.0/24", "192.168.100.0/32"}, - ), + Config: config, Check: resource.ComposeAggregateTestCheckFunc( testAccNetworkExists("upcloud_network.test_network"), resource.TestCheckResourceAttr("upcloud_network.test_network", "name", netName), @@ -50,21 +49,25 @@ func TestAccUpCloudNetwork_basic(t *testing.T) { resource.TestCheckResourceAttr("upcloud_network.test_network", "ip_network.0.dhcp_routes.#", "2"), ), }, + { + Config: config, + ResourceName: "upcloud_network.test_network", + ImportState: true, + ImportStateVerify: true, + }, }, }) } func TestAccUpCloudNetwork_basicUpdate(t *testing.T) { - var providers []*schema.Provider - netName := fmt.Sprintf("test_network_%s", acctest.RandString(5)) subnet := acctest.RandIntRange(0, 250) cidr := fmt.Sprintf("10.0.%d.0/24", subnet) gateway := fmt.Sprintf("10.0.%d.1", subnet) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccNetworkConfig(netName, "fi-hel1", cidr, gateway, true, false, false, []string{"10.0.0.2"}, []string{"192.168.0.0/24"}), @@ -101,19 +104,19 @@ func TestAccUpCloudNetwork_basicUpdate(t *testing.T) { } func TestAccUpCloudNetwork_withRouter(t *testing.T) { - var providers []*schema.Provider - netName := fmt.Sprintf("test_network_%s", acctest.RandString(5)) subnet := acctest.RandIntRange(0, 250) cidr := fmt.Sprintf("10.0.%d.0/24", subnet) gateway := fmt.Sprintf("10.0.%d.1", subnet) + config := testAccNetworkConfig(netName, "fi-hel1", cidr, gateway, true, false, true, nil, nil) + resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { - Config: testAccNetworkConfig(netName, "fi-hel1", cidr, gateway, true, false, true, nil, nil), + Config: config, Check: resource.ComposeAggregateTestCheckFunc( testAccNetworkExists("upcloud_network.test_network"), resource.TestCheckResourceAttr("upcloud_network.test_network", "name", netName), @@ -126,21 +129,25 @@ func TestAccUpCloudNetwork_withRouter(t *testing.T) { testAccNetworkRouterIsSet("upcloud_network.test_network", "upcloud_router.test_network_router"), ), }, + { + Config: config, + ResourceName: "upcloud_network.test_network", + ImportState: true, + ImportStateVerify: true, + }, }, }) } func TestAccUpCloudNetwork_amendWithRouter(t *testing.T) { - var providers []*schema.Provider - netName := fmt.Sprintf("test_network_%s", acctest.RandString(5)) subnet := acctest.RandIntRange(0, 250) cidr := fmt.Sprintf("10.0.%d.0/24", subnet) gateway := fmt.Sprintf("10.0.%d.1", subnet) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccNetworkConfig(netName, "fi-hel1", cidr, gateway, true, false, false, nil, nil), @@ -175,20 +182,18 @@ func TestAccUpCloudNetwork_amendWithRouter(t *testing.T) { } func TestAccUpCloudNetwork_FamilyValidation(t *testing.T) { - var providers []*schema.Provider - netName := fmt.Sprintf("test_network_%s", acctest.RandString(5)) subnet := acctest.RandIntRange(0, 250) cidr := fmt.Sprintf("10.0.%d.0/24", subnet) gateway := fmt.Sprintf("10.0.%d.1", subnet) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccNetworkConfigWithFamily(netName, "fi-hel1", cidr, gateway, "rubbish", true, false, false, nil, nil), - ExpectError: regexp.MustCompile(`'family' has incorrect value`), + ExpectError: regexp.MustCompile(`family value must be one of: \["IPv4" "IPv6"\]`), }, }, }) @@ -218,8 +223,8 @@ func testAccNetworkConfigWithFamily(name string, zone string, address string, ga address = "%s" dhcp = "%t" dhcp_default_route = "%t" - family = "%s" - gateway = "%s" + family = "%s" + gateway = "%s" `, address, diff --git a/upcloud/resource_upcloud_objectstorage_test.go b/upcloud/resource_upcloud_objectstorage_test.go index e0d33f177..268b823c1 100644 --- a/upcloud/resource_upcloud_objectstorage_test.go +++ b/upcloud/resource_upcloud_objectstorage_test.go @@ -15,7 +15,6 @@ import ( "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service" "github.com/hashicorp/go-retryablehttp" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/minio/minio-go/v7" ) @@ -89,14 +88,12 @@ func TestMain(m *testing.M) { } func TestUpCloudObjectStorage_basic(t *testing.T) { - var providers []*schema.Provider - const expectedSize = "250" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: verifyObjectStorageDoesNotExist(objectStorageTestExpectedName1), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: verifyObjectStorageDoesNotExist(objectStorageTestExpectedName1), Steps: []resource.TestStep{ { Config: testUpCloudObjectStorageInstanceConfig( @@ -123,8 +120,6 @@ func TestUpCloudObjectStorage_basic(t *testing.T) { } func TestUpCloudObjectStorage_basic_update(t *testing.T) { - var providers []*schema.Provider - const expectedSize = "500" const expectedUpdatedSize = "1000" @@ -133,9 +128,9 @@ func TestUpCloudObjectStorage_basic_update(t *testing.T) { const expectedUpdatedSecret = "an updated secret" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: verifyObjectStorageDoesNotExist(objectStorageTestExpectedName2), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: verifyObjectStorageDoesNotExist(objectStorageTestExpectedName2), Steps: []resource.TestStep{ { Config: testUpCloudObjectStorageInstanceConfig( @@ -175,17 +170,15 @@ func TestUpCloudObjectStorage_basic_update(t *testing.T) { } func TestUpCloudObjectStorage_default_values(t *testing.T) { - var providers []*schema.Provider - const expectedSize = "500" const expectedUpdatedSize = "1000" const expectedUpdatedKey = "an updated access key" const expectedUpdatedSecret = "an updated secret" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: verifyObjectStorageDoesNotExist(objectStorageTestExpectedName2), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: verifyObjectStorageDoesNotExist(objectStorageTestExpectedName2), Steps: []resource.TestStep{ { Config: testUpCloudObjectStorageInstanceDefaultsConfig( @@ -216,8 +209,6 @@ func TestUpCloudObjectStorage_default_values(t *testing.T) { } func TestUpCloudObjectStorage_bucket_management(t *testing.T) { - var providers []*schema.Provider - const expectedSize = "500" const expectedBucketName1 = "bucket1" const expectedBucketName2 = "bucket2" @@ -226,9 +217,9 @@ func TestUpCloudObjectStorage_bucket_management(t *testing.T) { const expectedBucketName5 = "bucket5" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: verifyObjectStorageDoesNotExist(objectStorageTestExpectedName2), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: verifyObjectStorageDoesNotExist(objectStorageTestExpectedName2), Steps: []resource.TestStep{ { Config: testUpCloudObjectStorageWithBucketsInstanceConfig( @@ -304,8 +295,6 @@ func TestUpCloudObjectStorage_bucket_management(t *testing.T) { // We bundle creating object storage using env vars and import because import relies on passing access and secret key as env vars func TestUpCloudObjectStorage_keys_env_vars_and_import(t *testing.T) { - var providers []*schema.Provider - name := objectStorageTestExpectedName4 zone := "pl-waw1" desc := "just some random stuff" @@ -326,8 +315,8 @@ func TestUpCloudObjectStorage_keys_env_vars_and_import(t *testing.T) { os.Setenv(accessKeyEnvVarName, accessKey) os.Setenv(secretKeyEnvVarName, secretKey) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: verifyObjectStorageDoesNotExist(name), + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: verifyObjectStorageDoesNotExist(name), Steps: []resource.TestStep{ { // Pass empty strings as access and secret keys to check if those values will be taken from env vars diff --git a/upcloud/resource_upcloud_router_test.go b/upcloud/resource_upcloud_router_test.go index 571fd2731..04e079883 100644 --- a/upcloud/resource_upcloud_router_test.go +++ b/upcloud/resource_upcloud_router_test.go @@ -10,21 +10,18 @@ import ( "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccUpCloudRouter(t *testing.T) { - var providers []*schema.Provider - var router upcloud.Router name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) staticRoutes := []upcloud.StaticRoute{{Name: "my-example-route", Nexthop: "10.0.0.100", Route: "0.0.0.0/0"}} resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckRouterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckRouterDestroy, Steps: []resource.TestStep{ { Config: testAccRouterConfig(name, staticRoutes), @@ -43,8 +40,6 @@ func TestAccUpCloudRouter(t *testing.T) { } func TestAccUpCloudRouter_update(t *testing.T) { - var providers []*schema.Provider - var router upcloud.Router name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) updateName := fmt.Sprintf("tf-test-update-%s", acctest.RandString(10)) @@ -53,9 +48,9 @@ func TestAccUpCloudRouter_update(t *testing.T) { updateStaticRoutes := []upcloud.StaticRoute{{Name: "my-example-route-2", Nexthop: "10.0.0.101", Route: "0.0.0.0/0"}} resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckRouterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckRouterDestroy, Steps: []resource.TestStep{ { Config: testAccRouterConfig(name, staticRoutes), @@ -86,14 +81,12 @@ func TestAccUpCloudRouter_update(t *testing.T) { } func TestAccUpCloudRouter_import(t *testing.T) { - var providers []*schema.Provider - var router upcloud.Router name := fmt.Sprintf("tf-test-import-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckRouterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckRouterDestroy, Steps: []resource.TestStep{ { Config: testAccRouterConfig(name, nil), @@ -111,13 +104,12 @@ func TestAccUpCloudRouter_import(t *testing.T) { } func TestAccUpCloudRouter_detach(t *testing.T) { - var providers []*schema.Provider var router upcloud.Router var network upcloud.Network resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckRouterNetworkDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckRouterNetworkDestroy, Steps: []resource.TestStep{ { // first create network and router attached @@ -180,13 +172,12 @@ func TestAccUpCloudRouter_detach(t *testing.T) { } func TestAccUpCloudRouter_attachedDelete(t *testing.T) { - var providers []*schema.Provider var router upcloud.Router var network upcloud.Network resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckRouterNetworkDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckRouterNetworkDestroy, Steps: []resource.TestStep{ { // first create network and router attached diff --git a/upcloud/resource_upcloud_server_group_test.go b/upcloud/resource_upcloud_server_group_test.go index 850681f93..3f03bcbdc 100644 --- a/upcloud/resource_upcloud_server_group_test.go +++ b/upcloud/resource_upcloud_server_group_test.go @@ -7,21 +7,18 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpCloudServerGroup_ServerGroupMembers(t *testing.T) { testDataStep1 := utils.ReadTestDataFile(t, "testdata/upcloud_server_group/server_group_members_s1.tf") testDataStep2 := utils.ReadTestDataFile(t, "testdata/upcloud_server_group/server_group_members_s2.tf") - var providers []*schema.Provider - group1 := "upcloud_server_group.tf_test_1" group2 := "upcloud_server_group.tf_test_2" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataStep1, @@ -53,13 +50,11 @@ func TestAccUpCloudServerGroup_ServerServerGroup(t *testing.T) { testDataStep1 := utils.ReadTestDataFile(t, "testdata/upcloud_server_group/server_server_group_s1.tf") testDataStep2 := utils.ReadTestDataFile(t, "testdata/upcloud_server_group/server_server_group_s2.tf") - var providers []*schema.Provider - server := func(i int) string { return fmt.Sprintf("upcloud_server.test_%d", i) } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataStep1, @@ -82,11 +77,9 @@ func TestAccUpCloudServerGroup_ServerServerGroup(t *testing.T) { func TestAccUpCloudServerGroup_TrackMembersValidation(t *testing.T) { testDataE := utils.ReadTestDataFile(t, "testdata/upcloud_server_group/errors.tf") - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataE, diff --git a/upcloud/resource_upcloud_server_network_test.go b/upcloud/resource_upcloud_server_network_test.go index b3fde6fa6..2f05eb563 100644 --- a/upcloud/resource_upcloud_server_network_test.go +++ b/upcloud/resource_upcloud_server_network_test.go @@ -6,14 +6,12 @@ import ( "github.com/UpCloudLtd/terraform-provider-upcloud/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func TestAccUpcloudServerNetwork(t *testing.T) { testDataS1 := utils.ReadTestDataFile(t, "testdata/upcloud_server/server_s1.tf") testDataS2 := utils.ReadTestDataFile(t, "testdata/upcloud_server/server_s2.tf") - var providers []*schema.Provider server1Name := "upcloud_server.server1" verifyImportStep := func(name string) resource.TestStep { @@ -26,8 +24,8 @@ func TestAccUpcloudServerNetwork(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testDataS1, diff --git a/upcloud/resource_upcloud_server_test.go b/upcloud/resource_upcloud_server_test.go index 74b2fbe16..93bc1b44a 100644 --- a/upcloud/resource_upcloud_server_test.go +++ b/upcloud/resource_upcloud_server_test.go @@ -7,18 +7,15 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestUpcloudServer_customPlan(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: ` @@ -67,11 +64,9 @@ func TestUpcloudServer_customPlan(t *testing.T) { } func TestUpcloudServer_minimal(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: ` @@ -120,11 +115,9 @@ func TestUpcloudServer_minimal(t *testing.T) { } func TestUpcloudServer_basic(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: ` @@ -181,11 +174,9 @@ func TestUpcloudServer_basic(t *testing.T) { } func TestUpcloudServer_changePlan(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccServerConfigWithSmallServerPlan, @@ -206,11 +197,9 @@ func TestUpcloudServer_changePlan(t *testing.T) { } func TestUpcloudServer_simpleBackup(t *testing.T) { - var providers []*schema.Provider - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { // basic setup @@ -355,11 +344,9 @@ func TestUpcloudServer_simpleBackup(t *testing.T) { } func TestUpcloudServer_simpleBackupWithStorage(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { // basic setup @@ -572,11 +559,9 @@ func TestUpcloudServer_simpleBackupWithStorage(t *testing.T) { } func TestUpcloudServer_updateTags(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { // Setup server with tags @@ -718,13 +703,11 @@ func TestUpcloudServer_updateTags(t *testing.T) { } func TestUpcloudServer_networkInterface(t *testing.T) { - var providers []*schema.Provider - var serverID string resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccServerNetworkInterfaceConfig( @@ -1033,11 +1016,9 @@ func testAccServerNetworkInterfaceConfig(nis ...networkInterface) string { } func TestUpcloudServer_updatePreChecks(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: ` @@ -1083,11 +1064,9 @@ func TestUpcloudServer_updatePreChecks(t *testing.T) { } func TestUpcloudServer_createPreChecks(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { // Test creating with invalid plan diff --git a/upcloud/resource_upcloud_storage_test.go b/upcloud/resource_upcloud_storage_test.go index 703881094..a5ad7d240 100644 --- a/upcloud/resource_upcloud_storage_test.go +++ b/upcloud/resource_upcloud_storage_test.go @@ -16,7 +16,6 @@ import ( "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request" "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -30,11 +29,9 @@ const ( ) func TestAccUpcloudStorage_basic(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: ` @@ -131,7 +128,6 @@ func TestAccUpcloudStorage_basic(t *testing.T) { } func TestAccUpCloudStorage_import(t *testing.T) { - var providers []*schema.Provider var storageDetails upcloud.StorageDetails expectedSize := "10" @@ -140,9 +136,9 @@ func TestAccUpCloudStorage_import(t *testing.T) { expectedZone := "fi-hel1" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckStorageDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckStorageDestroy, Steps: []resource.TestStep{ { Config: testUpcloudStorageInstanceConfig(expectedSize, expectedTier, expectedTitle, expectedZone, false, false), @@ -160,13 +156,12 @@ func TestAccUpCloudStorage_import(t *testing.T) { } func TestAccUpCloudStorage_StorageImport(t *testing.T) { - var providers []*schema.Provider var storageDetails upcloud.StorageDetails resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckStorageDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckStorageDestroy, Steps: []resource.TestStep{ { Config: testUpcloudStorageInstanceConfigWithStorageImport( @@ -185,7 +180,6 @@ func TestAccUpCloudStorage_StorageImport(t *testing.T) { func TestAccUpCloudStorage_StorageImportDirect(t *testing.T) { if os.Getenv(resource.EnvTfAcc) != "" { - var providers []*schema.Provider var storageDetails upcloud.StorageDetails imagePath, sum, err := createTempImage() @@ -196,9 +190,9 @@ func TestAccUpCloudStorage_StorageImportDirect(t *testing.T) { sha256sum := hex.EncodeToString((*sum).Sum(nil)) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckStorageDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckStorageDestroy, Steps: []resource.TestStep{ { Config: testUpcloudStorageInstanceConfigWithStorageImport( @@ -217,12 +211,10 @@ func TestAccUpCloudStorage_StorageImportDirect(t *testing.T) { } func TestAccUpCloudStorage_StorageImportValidation(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckStorageDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckStorageDestroy, Steps: []resource.TestStep{ { Config: testUpcloudStorageInstanceConfigWithStorageImport( @@ -235,12 +227,10 @@ func TestAccUpCloudStorage_StorageImportValidation(t *testing.T) { } func TestAccUpCloudStorage_CloneImportValidation(t *testing.T) { - var providers []*schema.Provider - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckStorageDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckStorageDestroy, Steps: []resource.TestStep{ { Config: testUpcloudStorageInstanceConfigWithImportAndClone(), @@ -251,14 +241,13 @@ func TestAccUpCloudStorage_CloneImportValidation(t *testing.T) { } func TestAccUpCloudStorage_CloneStorage(t *testing.T) { - var providers []*schema.Provider var storageDetailsPlain upcloud.StorageDetails var storageDetailsClone upcloud.StorageDetails resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckStorageDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckStorageDestroy, Steps: []resource.TestStep{ { Config: testUpcloudStorageInstanceConfigWithClone(20), diff --git a/upcloud/resource_upcloud_tag_test.go b/upcloud/resource_upcloud_tag_test.go index cd0be96e1..3c4e46d19 100644 --- a/upcloud/resource_upcloud_tag_test.go +++ b/upcloud/resource_upcloud_tag_test.go @@ -10,20 +10,18 @@ import ( "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccUpcloudTag_basic(t *testing.T) { - var providers []*schema.Provider tag1 := acctest.RandString(10) tag2 := acctest.RandString(10) expectedNames := []string{tag1, tag2} resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckTagDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckTagDestroy, Steps: []resource.TestStep{ { Config: testUpcloudTagInstanceConfig(expectedNames), @@ -47,16 +45,15 @@ func TestAccUpcloudTag_basic(t *testing.T) { } func TestAccUpCloudTag_import(t *testing.T) { - var providers []*schema.Provider var tags upcloud.Tags tag1 := acctest.RandString(10) expectedNames := []string{tag1} resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: testAccProviderFactories(&providers), - CheckDestroy: testAccCheckTagDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckTagDestroy, Steps: []resource.TestStep{ { Config: testUpcloudTagInstanceConfig(expectedNames), diff --git a/upcloud/sdkv2_provider.go b/upcloud/sdkv2_provider.go new file mode 100644 index 000000000..a4ec09a11 --- /dev/null +++ b/upcloud/sdkv2_provider.go @@ -0,0 +1,175 @@ +package upcloud + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + + "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/client" + "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/config" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/cloud" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/database" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/firewall" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/gateway" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/ip" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/kubernetes" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/loadbalancer" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/managedobjectstorage" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/network" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/objectstorage" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/router" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/server" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/servergroup" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/storage" + "github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/tag" + + retryablehttp "github.com/hashicorp/go-retryablehttp" +) + +func Provider() *schema.Provider { + return &schema.Provider{ + Schema: map[string]*schema.Schema{ + "username": { + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("UPCLOUD_USERNAME", nil), + Description: "UpCloud username with API access. Can also be configured using the `UPCLOUD_USERNAME` environment variable.", + }, + "password": { + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("UPCLOUD_PASSWORD", nil), + Description: "Password for UpCloud API user. Can also be configured using the `UPCLOUD_PASSWORD` environment variable.", + }, + "retry_wait_min_sec": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + Description: "Minimum time to wait between retries", + }, + "retry_wait_max_sec": { + Type: schema.TypeInt, + Optional: true, + Default: 30, + Description: "Maximum time to wait between retries", + }, + "retry_max": { + Type: schema.TypeInt, + Optional: true, + Default: 4, + Description: "Maximum number of retries", + }, + "request_timeout_sec": { + Type: schema.TypeInt, + Optional: true, + Default: 120, + Description: "The duration (in seconds) that the provider waits for an HTTP request towards UpCloud API to complete. Defaults to 120 seconds", + }, + }, + + ResourcesMap: map[string]*schema.Resource{ + "upcloud_server": server.ResourceServer(), + "upcloud_server_group": servergroup.ResourceServerGroup(), + "upcloud_router": router.ResourceRouter(), + "upcloud_storage": storage.ResourceStorage(), + "upcloud_firewall_rules": firewall.ResourceFirewallRules(), + "upcloud_tag": tag.ResourceTag(), + "upcloud_gateway": gateway.ResourceGateway(), + "upcloud_gateway_connection": gateway.ResourceConnection(), + "upcloud_gateway_connection_tunnel": gateway.ResourceTunnel(), + "upcloud_floating_ip_address": ip.ResourceFloatingIPAddress(), + "upcloud_object_storage": objectstorage.ResourceObjectStorage(), + "upcloud_managed_database_postgresql": database.ResourcePostgreSQL(), + "upcloud_managed_database_mysql": database.ResourceMySQL(), + "upcloud_managed_database_redis": database.ResourceRedis(), + "upcloud_managed_database_opensearch": database.ResourceOpenSearch(), + "upcloud_managed_database_user": database.ResourceUser(), + "upcloud_managed_database_logical_database": database.ResourceLogicalDatabase(), + "upcloud_managed_object_storage": managedobjectstorage.ResourceManagedObjectStorage(), + "upcloud_managed_object_storage_policy": managedobjectstorage.ResourceManagedObjectStoragePolicy(), + "upcloud_managed_object_storage_user": managedobjectstorage.ResourceManagedObjectStorageUser(), + "upcloud_managed_object_storage_user_access_key": managedobjectstorage.ResourceManagedObjectStorageUserAccessKey(), + "upcloud_managed_object_storage_user_policy": managedobjectstorage.ResourceManagedObjectStorageUserPolicy(), + "upcloud_loadbalancer": loadbalancer.ResourceLoadBalancer(), + "upcloud_loadbalancer_resolver": loadbalancer.ResourceResolver(), + "upcloud_loadbalancer_backend": loadbalancer.ResourceBackend(), + "upcloud_loadbalancer_backend_tls_config": loadbalancer.ResourceBackendTLSConfig(), + "upcloud_loadbalancer_static_backend_member": loadbalancer.ResourceStaticBackendMember(), + "upcloud_loadbalancer_dynamic_backend_member": loadbalancer.ResourceDynamicBackendMember(), + "upcloud_loadbalancer_frontend": loadbalancer.ResourceFrontend(), + "upcloud_loadbalancer_frontend_rule": loadbalancer.ResourceFrontendRule(), + "upcloud_loadbalancer_frontend_tls_config": loadbalancer.ResourceFrontendTLSConfig(), + "upcloud_loadbalancer_dynamic_certificate_bundle": loadbalancer.ResourceDynamicCertificateBundle(), + "upcloud_loadbalancer_manual_certificate_bundle": loadbalancer.ResourceManualCertificateBundle(), + "upcloud_kubernetes_cluster": kubernetes.ResourceCluster(), + "upcloud_kubernetes_node_group": kubernetes.ResourceNodeGroup(), + }, + + DataSourcesMap: map[string]*schema.Resource{ + "upcloud_zone": cloud.DataSourceZone(), + "upcloud_zones": cloud.DataSourceZones(), + "upcloud_networks": network.DataSourceNetworks(), + "upcloud_hosts": cloud.DataSourceHosts(), + "upcloud_ip_addresses": ip.DataSourceIPAddresses(), + "upcloud_tags": tag.DataSourceTags(), + "upcloud_storage": storage.DataSourceStorage(), + "upcloud_kubernetes_cluster": kubernetes.DataSourceCluster(), + "upcloud_managed_database_opensearch_indices": database.DataSourceOpenSearchIndices(), + "upcloud_managed_database_mysql_sessions": database.DataSourceSessionsMySQL(), + "upcloud_managed_database_postgresql_sessions": database.DataSourceSessionsPostgreSQL(), + "upcloud_managed_database_redis_sessions": database.DataSourceSessionsRedis(), + "upcloud_managed_object_storage_policies": managedobjectstorage.DataSourceManagedObjectStoragePolicies(), + }, + + ConfigureContextFunc: providerConfigure, + } +} + +func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { + var diags diag.Diagnostics + + requestTimeout := time.Duration(d.Get("request_timeout_sec").(int)) * time.Second + + config := Config{ + Username: d.Get("username").(string), + Password: d.Get("password").(string), + } + + httpClient := retryablehttp.NewClient() + httpClient.RetryWaitMin = time.Duration(d.Get("retry_wait_min_sec").(int)) * time.Second + httpClient.RetryWaitMax = time.Duration(d.Get("retry_wait_max_sec").(int)) * time.Second + httpClient.RetryMax = d.Get("retry_max").(int) + + service := newUpCloudServiceConnection( + d.Get("username").(string), + d.Get("password").(string), + httpClient.HTTPClient, + requestTimeout, + ) + + _, err := config.checkLogin(service) + if err != nil { + return nil, diag.FromErr(err) + } + + return service, diags +} + +func newUpCloudServiceConnection(username, password string, httpClient *http.Client, requestTimeout time.Duration) *service.Service { + providerClient := client.New( + username, + password, + client.WithHTTPClient(httpClient), + client.WithTimeout(requestTimeout), + ) + + providerClient.UserAgent = fmt.Sprintf("terraform-provider-upcloud/%s", config.Version) + + return service.New(providerClient) +}