diff --git a/examples/ibm-private-dns/main.tf b/examples/ibm-private-dns/main.tf index 297fe51dce..442d4c5eb0 100644 --- a/examples/ibm-private-dns/main.tf +++ b/examples/ibm-private-dns/main.tf @@ -192,6 +192,8 @@ resource "ibm_dns_custom_resolver" "test" { name = "testCR-TF" instance_id = ibm_resource_instance.test-pdns-instance.guid description = "testdescription-CR" + profile = "essential" + allow_disruptive_updates = false locations { subnet_crn = "crn:v1:staging:public:is:us-south-1:a/01652b251c3ae2787110a995d8db0135::subnet:0716-6c3a997d-72b2-47f6-8788-6bd95e1bdb03" enabled = false @@ -203,6 +205,8 @@ resource "ibm_dns_custom_resolver" "test" { description = "new test CR TF-1" high_availability = true enabled = true + profile = "essential" + allow_disruptive_updates = false locations { subnet_crn = "crn:v1:staging:public:is:us-south-1:a/01652b251c3ae2787110a995d8db0135::subnet:0716-a094c4e8-02cd-4b04-858d-3432" enabled = false @@ -236,6 +240,12 @@ resource "ibm_dns_custom_resolver_forwarding_rule" "test" { type = "zone" match = "test.example.com" forward_to = ["168.20.22.122"] + views { + name = "view-example-name" + description = "view description" + expression = "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" + forward_to = ["10.240.2.6","10.240.2.7"] + } } data "ibm_dns_custom_resolver_forwarding_rules" "test-fr" { diff --git a/go.mod b/go.mod index 12921f5e7b..89a844fca6 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/IBM-Cloud/terraform-provider-ibm -go 1.22.5 +go 1.23.3 -toolchain go1.23.2 +toolchain go1.23.4 require ( github.com/IBM-Cloud/bluemix-go v0.0.0-20241117121028-a3be206688b3 @@ -22,7 +22,7 @@ require ( github.com/IBM/eventstreams-go-sdk v1.4.0 github.com/IBM/go-sdk-core v1.1.0 github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/go-sdk-core/v5 v5.18.3 + github.com/IBM/go-sdk-core/v5 v5.18.5 github.com/IBM/ibm-backup-recovery-sdk-go v1.0.1 github.com/IBM/ibm-cos-sdk-go v1.12.0 github.com/IBM/ibm-cos-sdk-go-config/v2 v2.2.0 @@ -32,7 +32,7 @@ require ( github.com/IBM/logs-go-sdk v0.4.0 github.com/IBM/logs-router-go-sdk v1.0.5 github.com/IBM/mqcloud-go-sdk v0.2.0 - github.com/IBM/networking-go-sdk v0.49.0 + github.com/IBM/networking-go-sdk v0.50.0 github.com/IBM/platform-services-go-sdk v0.72.0 github.com/IBM/project-go-sdk v0.3.5 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 @@ -66,7 +66,7 @@ require ( github.com/rook/rook/pkg/apis v0.0.0-20231204200402-5287527732f7 github.com/softlayer/softlayer-go v1.0.3 github.com/stretchr/testify v1.10.0 - golang.org/x/crypto v0.31.0 + golang.org/x/crypto v0.32.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools v2.2.0+incompatible k8s.io/api v0.31.1 @@ -102,7 +102,7 @@ require ( github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fatih/color v1.16.0 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.6 // indirect + github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/go-jose/go-jose/v4 v4.0.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -118,7 +118,7 @@ require ( github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.22.1 // indirect + github.com/go-playground/validator/v10 v10.23.0 // indirect github.com/go-test/deep v1.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -201,7 +201,7 @@ require ( github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/zclconf/go-cty v1.15.0 // indirect - go.mongodb.org/mongo-driver v1.17.1 // indirect + go.mongodb.org/mongo-driver v1.17.2 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect go.opentelemetry.io/otel/trace v1.28.0 // indirect @@ -209,11 +209,11 @@ require ( go.uber.org/ratelimit v0.2.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.34.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/term v0.27.0 // indirect + golang.org/x/sys v0.29.0 // indirect + golang.org/x/term v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.26.0 // indirect diff --git a/go.sum b/go.sum index 74dacf8d07..ee73a6e47f 100644 --- a/go.sum +++ b/go.sum @@ -133,8 +133,8 @@ github.com/IBM/go-sdk-core/v5 v5.6.3/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3bt github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI= github.com/IBM/go-sdk-core/v5 v5.17.4/go.mod h1:KsAAI7eStAWwQa4F96MLy+whYSh39JzNjklZRbN/8ns= -github.com/IBM/go-sdk-core/v5 v5.18.3 h1:q6IDU3N2bHGwijK9pMnzKC5gqdaRII56NzB4ZNdSFvY= -github.com/IBM/go-sdk-core/v5 v5.18.3/go.mod h1:5kILxqEWOrwMhoD2b7J6Xv9Z2M6YIdT/6Oy+XRSsCGQ= +github.com/IBM/go-sdk-core/v5 v5.18.5 h1:g0JRl3sYXJczB/yuDlrN6x22LJ6jIxhp0Sa4ARNW60c= +github.com/IBM/go-sdk-core/v5 v5.18.5/go.mod h1:KonTFRR+8ZSgw5cxBSYo6E4WZoY1+7n1kfHM82VcjFU= github.com/IBM/ibm-backup-recovery-sdk-go v1.0.1 h1:JSdt2WuiRCSKok+Jvv+x0eQP6duR1dUg6utKH0bI734= github.com/IBM/ibm-backup-recovery-sdk-go v1.0.1/go.mod h1:ezUFoHQn8MvZI5vNd3H/ds4BCDYOXDodGFrTUgsU33k= github.com/IBM/ibm-cos-sdk-go v1.12.0 h1:Wrk3ve4JS3euhl7XjNFd3RlvPT56199G2/rKaPWpRKU= @@ -154,8 +154,8 @@ github.com/IBM/logs-router-go-sdk v1.0.5 h1:r0kC1+HfmSeQCD6zQTUp4PDI/zp4Ueo1Zo19 github.com/IBM/logs-router-go-sdk v1.0.5/go.mod h1:tCN2vFgu5xG0ob9iJcxi5M4bJ6mWmu3nhmRPnvlwev0= github.com/IBM/mqcloud-go-sdk v0.2.0 h1:QOWk8ZGk0QfIL0MOGTKzNdM3Qe0Hk+ifAFtNSFQo5HU= github.com/IBM/mqcloud-go-sdk v0.2.0/go.mod h1:VZQKMtqmcdXKhmLhLiPuS/UHMs/5yo2tA/nD83cQt9E= -github.com/IBM/networking-go-sdk v0.49.0 h1:lPS34u3C0JVrbxH+Ulua76Nwl6Frv8BEfq6LRkyvOv0= -github.com/IBM/networking-go-sdk v0.49.0/go.mod h1:G9CKbmPE8gSLjN+ABh4hIZ1bMx076enl5Eekvj6zQnA= +github.com/IBM/networking-go-sdk v0.50.0 h1:3BHO1GrFnkkZ4mYyn2nQc+Djw48/g3znJe3k4a4p1Yk= +github.com/IBM/networking-go-sdk v0.50.0/go.mod h1:aDKmbdfJG+JnoV9RvxOPg7nmgTKReyBgX8aAZHolcm8= github.com/IBM/platform-services-go-sdk v0.72.0 h1:AfJe6bgqmTQU4ff/2URu3wkRLZD0XIzojn7SLf2yIns= github.com/IBM/platform-services-go-sdk v0.72.0/go.mod h1:ApFkvqw7NaluWJ5Uq+afdM/2jQqo5ILc0SzKSVobYNw= github.com/IBM/project-go-sdk v0.3.5 h1:L+YClFUa14foS0B/hOOY9n7sIdsT5/XQicnXOyJSpyM= @@ -370,8 +370,8 @@ github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8 github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= -github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc= -github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc= +github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= +github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -502,8 +502,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= -github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o= +github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -1270,8 +1270,8 @@ go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4x go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= -go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM= -go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= +go.mongodb.org/mongo-driver v1.17.2 h1:gvZyk8352qSfzyZ2UMWcpDpMSGEr1eqE4T793SqyhzM= +go.mongodb.org/mongo-driver v1.17.2/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -1343,8 +1343,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= +golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1474,8 +1474,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1638,8 +1638,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1660,8 +1660,8 @@ golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= +golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index 7b31327868..ffc1098f0c 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -2034,6 +2034,7 @@ func Validator() validate.ValidatorDict { "ibm_is_reservation": vpc.ResourceIBMISReservationValidator(), "ibm_kms_key_rings": kms.ResourceIBMKeyRingValidator(), "ibm_dns_glb_monitor": dnsservices.ResourceIBMPrivateDNSGLBMonitorValidator(), + "ibm_dns_custom_resolver": dnsservices.ResourceIBMPrivateDNSCustomResolverValidator(), "ibm_dns_custom_resolver_forwarding_rule": dnsservices.ResourceIBMPrivateDNSForwardingRuleValidator(), "ibm_schematics_action": schematics.ResourceIBMSchematicsActionValidator(), "ibm_schematics_job": schematics.ResourceIBMSchematicsJobValidator(), diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go index 49733eeabc..994c10e570 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go @@ -51,6 +51,16 @@ func DataSourceIBMPrivateDNSCustomResolver() *schema.Resource { Type: schema.TypeString, Computed: true, }, + pdnsCRProfile: { + Type: schema.TypeString, + Computed: true, + Description: "The profile name of the custom resolver.", + }, + pdnsCRAllowDisruptiveUpdates: { + Type: schema.TypeBool, + Computed: true, + Description: "Whether a disruptive update is allowed for the custom resolver", + }, pdnsCustomResolverLocations: { Type: schema.TypeList, Description: "Locations on which the custom resolver will be running", @@ -109,17 +119,19 @@ func dataSourceIBMDNSCustomResolverRead(context context.Context, d *schema.Resou customResolver[pdnsCRDescription] = *instance.Description customResolver[pdnsCRHealth] = *instance.Health customResolver[pdnsCREnabled] = *instance.Enabled + customResolver[pdnsCRProfile] = *instance.Profile + customResolver[pdnsCRAllowDisruptiveUpdates] = *instance.AllowDisruptiveUpdates customResolver[pdnsCustomResolverLocations] = flattenPdnsCRLocations(instance.Locations) customResolvers = append(customResolvers, customResolver) } - d.SetId(dataSourceIBMPrivateDNSCustomResolverID(d)) + d.SetId(dataSourceIBMPrivateDNSCustomResolverID()) d.Set(pdnsInstanceID, instanceID) d.Set(pdnsCustomResolvers, customResolvers) return nil } // dataSourceIBMPrivateDNSCustomResolverID returns a reasonable ID for dns custom resolver list. -func dataSourceIBMPrivateDNSCustomResolverID(d *schema.ResourceData) string { +func dataSourceIBMPrivateDNSCustomResolverID() string { return time.Now().UTC().String() } diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go index 25bcabd67c..032c74e1d2 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go @@ -61,6 +61,36 @@ func DataSourceIBMPrivateDNSForwardingRules() *schema.Resource { Type: schema.TypeString, }, }, + pdnsCRFRViews: { + Type: schema.TypeList, + Description: "An array of views used by forwarding rules.", + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + pdnsCRFRVName: { + Type: schema.TypeString, + Computed: true, + Description: "Unique name of the view.", + }, + pdnsCRFRVDescription: { + Type: schema.TypeString, + Computed: true, + Description: "Description of the view.", + }, + pdnsCRFRVExpression: { + Type: schema.TypeString, + Computed: true, + Description: "Expression of the view.", + }, + pdnsCRFRVForwardTo: { + Type: schema.TypeList, + Computed: true, + Description: "The upstream DNS servers that the matching DNS queries will be forwarded to.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, }, }, }, @@ -84,23 +114,24 @@ func dataSourceIbmDnsCrForwardingRulesRead(context context.Context, d *schema.Re } forwardRules := make([]interface{}, 0) - for _, instance := range result.ForwardingRules { + for _, rule := range result.ForwardingRules { forwardRule := map[string]interface{}{} - forwardRule[pdnsCRFRRuleID] = *instance.ID - forwardRule[pdnsCRFRDesctiption] = *instance.Description - forwardRule[pdnsCRFRType] = *instance.Type - forwardRule[pdnsCRFRMatch] = *instance.Match - forwardRule[pdnsCRFRForwardTo] = instance.ForwardTo + forwardRule[pdnsCRFRRuleID] = *rule.ID + forwardRule[pdnsCRFRDesctiption] = *rule.Description + forwardRule[pdnsCRFRType] = *rule.Type + forwardRule[pdnsCRFRMatch] = *rule.Match + forwardRule[pdnsCRFRForwardTo] = rule.ForwardTo + forwardRule[pdnsCRFRViews] = flattenPDNSFRViews(rule.Views) forwardRules = append(forwardRules, forwardRule) } - d.SetId(dataSourceIBMPrivateDNSForwardrulesID(d)) + d.SetId(dataSourceIBMPrivateDNSForwardrulesID()) d.Set(pdnsInstanceID, instanceID) d.Set(pdnsCRFRResolverID, resolverID) d.Set(pdnsCRForwardRules, forwardRules) return nil } -func dataSourceIBMPrivateDNSForwardrulesID(d *schema.ResourceData) string { +func dataSourceIBMPrivateDNSForwardrulesID() string { return time.Now().UTC().String() } diff --git a/ibm/service/dnsservices/resource_ibm_dns_linked_zone.go b/ibm/service/dnsservices/resource_ibm_dns_linked_zone.go index 16949e5b8c..2c83fcb86f 100644 --- a/ibm/service/dnsservices/resource_ibm_dns_linked_zone.go +++ b/ibm/service/dnsservices/resource_ibm_dns_linked_zone.go @@ -120,12 +120,10 @@ func resourceIBMDNSLinkedZoneCreate(ctx context.Context, d *schema.ResourceData, } ownerInstanceID := d.Get(DnsLinkedZoneOwnerInstanceID).(string) ownerZoneID := d.Get(DnsLinkedZoneOwnerZoneID).(string) - createLinkedZoneOptions := sess.NewCreateLinkedZoneOptions(instanceID) + createLinkedZoneOptions := sess.NewCreateLinkedZoneOptions(instanceID, ownerInstanceID, ownerZoneID) createLinkedZoneOptions.SetDescription(description) createLinkedZoneOptions.SetLabel(label) - createLinkedZoneOptions.SetOwnerInstanceID(ownerInstanceID) - createLinkedZoneOptions.SetOwnerZoneID(ownerZoneID) mk := "dns_linked_zone_" + instanceID conns.IbmMutexKV.Lock(mk) defer conns.IbmMutexKV.Unlock(mk) diff --git a/ibm/service/dnsservices/resource_ibm_dns_linked_zone_test.go b/ibm/service/dnsservices/resource_ibm_dns_linked_zone_test.go index 3bcb9f65cb..d7163b28b1 100644 --- a/ibm/service/dnsservices/resource_ibm_dns_linked_zone_test.go +++ b/ibm/service/dnsservices/resource_ibm_dns_linked_zone_test.go @@ -17,6 +17,8 @@ import ( func TestAccIBMDNSLinkedZone_basic(t *testing.T) { name := fmt.Sprintf("seczone-cr-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)) + ownerInstanceId := "OWNER Instance ID" + ownerZoneId := "OWNER ZONE ID" resource.Test(t, resource.TestCase{ PreCheck: func() {}, @@ -24,9 +26,11 @@ func TestAccIBMDNSLinkedZone_basic(t *testing.T) { CheckDestroy: testAccCheckIBMDNSLinkedZoneDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMDNSLinkedZoneBasic(name), + Config: testAccCheckIBMDNSLinkedZoneBasic(name, ownerInstanceId, ownerZoneId), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "name", name), + resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "owner_instance_id", ownerInstanceId), + resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "owner_zone_id", ownerZoneId), ), }, }, @@ -35,13 +39,15 @@ func TestAccIBMDNSLinkedZone_basic(t *testing.T) { func TestAccIBMDNSLinkedZone_update(t *testing.T) { name := fmt.Sprintf("seczone-cr-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)) + ownerInstanceId := "OWNER Instance ID" + ownerZoneId := "OWNER ZONE ID" resource.Test(t, resource.TestCase{ PreCheck: func() {}, Providers: acc.TestAccProviders, CheckDestroy: testAccCheckIBMDNSLinkedZoneDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMDNSLinkedZoneBasic(name), + Config: testAccCheckIBMDNSLinkedZoneBasic(name, ownerInstanceId, ownerZoneId), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "name", name), ), @@ -69,25 +75,28 @@ func testAccCheckIBMDNSLinkedZoneUpdateConfig(name string, description string, l plan = "standard" } resource "ibm_dns_linked_zone" "test" { + name = "%s" instance_id = ibm_resource_instance.test-pdns-cr-instance.id owner_instance_id = "OWNER Instance ID" owner_zone_id = "OWNER ZONE ID" - description = "new test CR - TF" - label = "label" + description = "%s" + label = "%s" } - `) + `, name, description, label) } func TestAccIBMDNSLinkedZoneImport(t *testing.T) { var linkedZoneID string name := fmt.Sprintf("seczone-vpc-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) + ownerInstanceId := "OWNER Instance ID" + ownerZoneId := "OWNER ZONE ID" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, CheckDestroy: testAccCheckIBMDNSLinkedZoneDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMDNSLinkedZoneBasic(name), + Config: testAccCheckIBMDNSLinkedZoneBasic(name, ownerInstanceId, ownerZoneId), Check: resource.ComposeTestCheckFunc( testAccCheckIBMDNSLinkedZoneExists("ibm_dns_linked_zone.test", &linkedZoneID), resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "name", name), @@ -134,7 +143,7 @@ func testAccCheckIBMDNSLinkedZoneDestroy(s *terraform.State) error { return nil } -func testAccCheckIBMDNSLinkedZoneBasic(name string) string { +func testAccCheckIBMDNSLinkedZoneBasic(name string, ownerInstanceId string, ownerZoneId string) string { return fmt.Sprintf(` resource "ibm_resource_group" "rg" { name = "DNS_linked_zone_test" @@ -149,10 +158,10 @@ func testAccCheckIBMDNSLinkedZoneBasic(name string) string { resource "ibm_dns_linked_zone" "test" { name = "%s" instance_id = ibm_resource_instance.test-pdns-cr-instance.id - owner_instance_id = "OWNER Instance ID" - owner_zone_id = "OWNER ZONE ID" + owner_instance_id = "%s" + owner_zone_id = "%s" } - `, name) + `, name, ownerInstanceId, ownerZoneId) } //func testAccCheckIBMDNSLinkedZoneResource(vpcname, subnetname, zone, cidr, name, description string) string { diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go index 37d008baa5..8e0a6d5c2a 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go @@ -13,6 +13,7 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" "github.com/IBM/networking-go-sdk/dnssvcsv1" "github.com/IBM/go-sdk-core/v5/core" @@ -21,25 +22,27 @@ import ( ) const ( - ibmDNSCustomResolver = "ibm_dns_custom_resolver" - pdnsCustomResolvers = "custom_resolvers" - pdnsCustomResolverLocations = "locations" - pdnsCRId = "custom_resolver_id" - pdnsCRName = "name" - pdnsCRDescription = "description" - pdnsCRHealth = "health" - pdnsCREnabled = "enabled" - pdnsCRCreatedOn = "created_on" - pdnsCRModifiedOn = "modified_on" - pdnsCRLocationId = "location_id" - pdnsCRLocationSubnetCrn = "subnet_crn" - pdnsCRLocationEnabled = "enabled" - pdnsCRLocationHealthy = "healthy" - pdnsCRLocationDnsServerIp = "dns_server_ip" - pdnsCustomResolverCritical = "CRITICAL" - pdnsCustomResolverDegraded = "DEGRADED" - pdnsCustomResolverHealthy = "HEALTHY" - pdnsCRHighAvailability = "high_availability" + ibmDNSCustomResolver = "ibm_dns_custom_resolver" + pdnsCustomResolvers = "custom_resolvers" + pdnsCustomResolverLocations = "locations" + pdnsCRId = "custom_resolver_id" + pdnsCRName = "name" + pdnsCRDescription = "description" + pdnsCRHealth = "health" + pdnsCREnabled = "enabled" + pdnsCRCreatedOn = "created_on" + pdnsCRModifiedOn = "modified_on" + pdnsCRLocationId = "location_id" + pdnsCRLocationSubnetCrn = "subnet_crn" + pdnsCRLocationEnabled = "enabled" + pdnsCRLocationHealthy = "healthy" + pdnsCRLocationDnsServerIp = "dns_server_ip" + pdnsCustomResolverCritical = "CRITICAL" + pdnsCustomResolverDegraded = "DEGRADED" + pdnsCustomResolverHealthy = "HEALTHY" + pdnsCRHighAvailability = "high_availability" + pdnsCRProfile = "profile" + pdnsCRAllowDisruptiveUpdates = "allow_disruptive_updates" ) func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { @@ -132,6 +135,19 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { }, }, }, + pdnsCRProfile: { + Type: schema.TypeString, + Optional: true, + Default: "essential", + Description: "The profile name of the custom resolver.", + ValidateFunc: validate.InvokeValidator(ibmDNSCustomResolver, pdnsCRProfile), + }, + pdnsCRAllowDisruptiveUpdates: { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Whether a disruptive update is allowed for the custom resolver.", + }, pdnsCRForwardRules: { Type: schema.TypeList, Computed: true, @@ -165,6 +181,36 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { Type: schema.TypeString, }, }, + pdnsCRFRViews: { + Type: schema.TypeList, + Description: "An array of views used by forwarding rules.", + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + pdnsCRFRVName: { + Type: schema.TypeString, + Required: true, + Description: "Unique name of the view.", + }, + pdnsCRFRVDescription: { + Type: schema.TypeString, + Optional: true, + Description: "Description of the view.", + }, + pdnsCRFRVExpression: { + Type: schema.TypeString, + Required: true, + Description: "Expression of the view.", + }, + pdnsCRFRVForwardTo: { + Type: schema.TypeList, + Required: true, + Description: "The upstream DNS servers that the matching DNS queries will be forwarded to.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, }, }, }, @@ -183,6 +229,21 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { } } +func ResourceIBMPrivateDNSCustomResolverValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: pdnsCRProfile, + ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, + Type: validate.TypeString, + Optional: true, + AllowedValues: "essential, advanced, premier", + }, + ) + resourceValidator := validate.ResourceValidator{ResourceName: ibmDNSCustomResolver, Schema: validateSchema} + return &resourceValidator +} + type location struct { locationId string subnet string @@ -205,10 +266,11 @@ func resouceIBMPrivateDNSCustomResolverCreate(context context.Context, d *schema if des, ok := d.GetOk(pdnsCRDescription); ok { crDescription = des.(string) } + crProfile := d.Get(pdnsCRProfile).(string) - customResolverOption := sess.NewCreateCustomResolverOptions(crn) - customResolverOption.SetName(crName) + customResolverOption := sess.NewCreateCustomResolverOptions(crn, crName) customResolverOption.SetDescription(crDescription) + customResolverOption.SetProfile(crProfile) cr_highaval := d.Get(pdnsCRHighAvailability).(bool) @@ -294,6 +356,7 @@ func resouceIBMPrivateDNSCustomResolverRead(context context.Context, d *schema.R forwardRule[pdnsCRFRType] = *instance.Type forwardRule[pdnsCRFRMatch] = *instance.Match forwardRule[pdnsCRFRForwardTo] = instance.ForwardTo + forwardRule[pdnsCRFRViews] = flattenPDNSFRViews(instance.Views) forwardRules = append(forwardRules, forwardRule) } d.Set(pdnsInstanceID, crn) @@ -304,6 +367,8 @@ func resouceIBMPrivateDNSCustomResolverRead(context context.Context, d *schema.R d.Set(pdnsCREnabled, *result.Enabled) d.Set(pdnsCustomResolverLocations, flattenPdnsCRLocations(result.Locations)) d.Set(pdnsCRForwardRules, forwardRules) + d.Set(pdnsCRProfile, *result.Profile) + d.Set(pdnsCRAllowDisruptiveUpdates, *result.AllowDisruptiveUpdates) return nil } @@ -331,7 +396,9 @@ func resouceIBMPrivateDNSCustomResolverUpdate(context context.Context, d *schema if d.HasChange(pdnsCRName) || d.HasChange(pdnsCRDescription) || d.HasChange(pdnsCREnabled) || - d.HasChange(pdnsCRHighAvailability) { + d.HasChange(pdnsCRHighAvailability) || + d.HasChange(pdnsCRProfile) || + d.HasChange(pdnsCRAllowDisruptiveUpdates) { // Validation if _, ok := d.GetOk(pdnsCustomResolverLocations); ok { @@ -368,6 +435,14 @@ func resouceIBMPrivateDNSCustomResolverUpdate(context context.Context, d *schema if !cr_enable { opt.SetEnabled(false) } + if des, ok := d.GetOk(pdnsCRProfile); ok { + crProfile := des.(string) + opt.SetProfile(crProfile) + } + if des, ok := d.GetOk(pdnsCRAllowDisruptiveUpdates); ok { + crDisruptiveUpdates := des.(bool) + opt.SetAllowDisruptiveUpdates(crDisruptiveUpdates) + } result, resp, err := sess.UpdateCustomResolverWithContext(context, opt) if err != nil || result == nil { return diag.FromErr(fmt.Errorf("[ERROR] Error updating the custom resolver %s:%s", err, resp)) @@ -491,7 +566,7 @@ func resouceIBMPrivateDNSCustomResolverDelete(context context.Context, d *schema optEnabled := sess.NewUpdateCustomResolverOptions(crn, customResolverID) optEnabled.SetEnabled(false) result, resp, errEnabled := sess.UpdateCustomResolverWithContext(context, optEnabled) - if err != nil || result == nil { + if errEnabled != nil || result == nil { return diag.FromErr(fmt.Errorf("[ERROR] Error updating the custom resolver to disable before deleting %s:%s", errEnabled, resp)) } @@ -644,8 +719,7 @@ func addCRLocation(meta interface{}, instanceID string, customResolverID string, if err != nil { return "", diag.FromErr(err) } - opt := sess.NewAddCustomResolverLocationOptions(instanceID, customResolverID) - opt.SetSubnetCrn(subnet) + opt := sess.NewAddCustomResolverLocationOptions(instanceID, customResolverID, subnet) opt.SetEnabled(false) result, resp, err := sess.AddCustomResolverLocation(opt) locationID := *result.ID diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index 4160058915..8426dfca04 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -11,21 +11,28 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/go-sdk-core/v5/core" + dns "github.com/IBM/networking-go-sdk/dnssvcsv1" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) const ( - pdnsCRForwardRule = "ibm_dns_custom_resolver_forwarding_rule" - pdnsCRForwardRules = "rules" - pdnsCRFRResolverID = "resolver_id" - pdnsCRFRDesctiption = "description" - pdnsCRFRType = "type" - pdnsCRFRMatch = "match" - pdnsCRFRForwardTo = "forward_to" - pdnsCRFRRuleID = "rule_id" - pdnsCRFRCreatedOn = "created_on" - pdnsCRFRModifiedOn = "modified_on" + pdnsCRForwardRule = "ibm_dns_custom_resolver_forwarding_rule" + pdnsCRForwardRules = "rules" + pdnsCRFRResolverID = "resolver_id" + pdnsCRFRDesctiption = "description" + pdnsCRFRType = "type" + pdnsCRFRMatch = "match" + pdnsCRFRForwardTo = "forward_to" + pdnsCRFRRuleID = "rule_id" + pdnsCRFRCreatedOn = "created_on" + pdnsCRFRModifiedOn = "modified_on" + pdnsCRFRViews = "views" + pdnsCRFRVName = "name" + pdnsCRFRVDescription = "description" + pdnsCRFRVExpression = "expression" + pdnsCRFRVForwardTo = "forward_to" ) func ResourceIBMPrivateDNSForwardingRule() *schema.Resource { @@ -75,6 +82,36 @@ func ResourceIBMPrivateDNSForwardingRule() *schema.Resource { Computed: true, Description: "the time when a forwarding rule ID is created, RFC3339 format.", }, + pdnsCRFRViews: { + Type: schema.TypeList, + Description: "An array of views used by forwarding rules.", + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + pdnsCRFRVName: { + Type: schema.TypeString, + Required: true, + Description: "Unique name of the view.", + }, + pdnsCRFRVDescription: { + Type: schema.TypeString, + Optional: true, + Description: "Description of the view.", + }, + pdnsCRFRVExpression: { + Type: schema.TypeString, + Required: true, + Description: "Expression of the view.", + }, + pdnsCRFRVForwardTo: { + Type: schema.TypeList, + Required: true, + Description: "The upstream DNS servers that the matching DNS queries will be forwarded to.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, }, } } @@ -102,20 +139,40 @@ func resourceIbmDnsCrForwardingRuleCreate(context context.Context, d *schema.Res } instanceID := d.Get(pdnsInstanceID).(string) resolverID := d.Get(pdnsCRFRResolverID).(string) - opt := dnsSvcsClient.NewCreateForwardingRuleOptions(instanceID, resolverID) - if des, ok := d.GetOk(pdnsCRFRDesctiption); ok { - opt.SetDescription(des.(string)) - } - if t, ok := d.GetOk(pdnsCRFRType); ok { - opt.SetType(t.(string)) - } - if m, ok := d.GetOk(pdnsCRFRMatch); ok { - opt.SetMatch(m.(string)) - } - if _, ok := d.GetOk(pdnsCRFRForwardTo); ok { - opt.SetForwardTo(flex.ExpandStringList(d.Get(pdnsCRFRForwardTo).([]interface{}))) + ruleType := d.Get(pdnsCRFRType).(string) + ruleMatch := d.Get(pdnsCRFRMatch).(string) + ruleDescription := d.Get(pdnsCRFRDesctiption).(string) + + views := d.Get(pdnsCRFRViews).([]interface{}) + + var forwardingRuleInp dns.ForwardingRuleInputIntf + opt := dnsSvcsClient.NewCreateForwardingRuleOptions(instanceID, resolverID, forwardingRuleInp) + + // If forward_to field is present then we check if views are also present or not. + // We call the respective functions depending upon the availibility of the views. + // We follow the same approach when forward_to is not present. In this case if views are also not present then we throw an error. + if forward, ok := d.GetOk(pdnsCRFRForwardTo); ok { + if _, ok := d.GetOk(pdnsCRFRViews); ok { + forwardingRuleInpBoth, _ := dnsSvcsClient.NewForwardingRuleInputForwardingRuleBoth(ruleType, ruleMatch, flex.ExpandStringList(forward.([]interface{})), expandPDNSFRViews(views)) + forwardingRuleInpBoth.Description = &ruleDescription + opt.SetForwardingRuleInput(forwardingRuleInpBoth) + + } else { + forwardingRuleInpOnlyRule, _ := dnsSvcsClient.NewForwardingRuleInputForwardingRuleOnlyForward(ruleType, ruleMatch, flex.ExpandStringList(forward.([]interface{}))) + forwardingRuleInpOnlyRule.Description = &ruleDescription + opt.SetForwardingRuleInput(forwardingRuleInpOnlyRule) + } + } else { + if _, ok := d.GetOk(pdnsCRFRViews); ok { + forwardingRuleInpOnlyView, _ := dnsSvcsClient.NewForwardingRuleInputForwardingRuleOnlyView(ruleType, ruleMatch, expandPDNSFRViews(views)) + forwardingRuleInpOnlyView.Description = &ruleDescription + opt.SetForwardingRuleInput(forwardingRuleInpOnlyView) + } else { + return diag.FromErr(fmt.Errorf("[ERROR] Cannot create the forwarding rules. One of the fields from forward_to or views must be provided.")) + } } + result, resp, err := dnsSvcsClient.CreateForwardingRuleWithContext(context, opt) if err != nil || result == nil { @@ -149,6 +206,7 @@ func resourceIbmDnsCrForwardingRuleRead(context context.Context, d *schema.Resou d.Set(pdnsCRFRType, *result.Type) d.Set(pdnsCRFRMatch, *result.Match) d.Set(pdnsCRFRForwardTo, result.ForwardTo) + d.Set(pdnsCRFRViews, flattenPDNSFRViews(result.Views)) return nil } @@ -166,14 +224,24 @@ func resourceIbmDnsCrForwardingRuleUpdate(context context.Context, d *schema.Res if d.HasChange(pdnsCRFRDesctiption) || d.HasChange(pdnsCRFRMatch) || - d.HasChange(pdnsCRFRForwardTo) { + d.HasChange(pdnsCRFRForwardTo) || + d.HasChange(pdnsCRFRViews) { if des, ok := d.GetOk(pdnsCRFRDesctiption); ok { frdesc := des.(string) opt.SetDescription(frdesc) } - if _, ok := d.GetOk(pdnsCRFRForwardTo); ok { - opt.SetForwardTo(flex.ExpandStringList(d.Get(pdnsCRFRForwardTo).([]interface{}))) + + // Update logic is changed. Now we can have empty forward_to field if views are present. The only constraint is both the fields should not be empty. + if _, ok := d.GetOk(pdnsCRFRForwardTo); !ok { + if _, ok := d.GetOk(pdnsCRFRViews); !ok { + return diag.FromErr(fmt.Errorf("[ERROR] Cannot update the forwarding rules. One of the fields from forward_to or views must be provided.")) + } } + + // Once we make sure the one of the field from forward_to or views is present we can allow empty fields to be updated. + opt.SetForwardTo(flex.ExpandStringList(d.Get(pdnsCRFRForwardTo).([]interface{}))) + opt.SetViews(expandPDNSFRViews(d.Get(pdnsCRFRViews).([]interface{}))) + if ty, ok := d.GetOk(pdnsCRFRType); ok { crtype := ty.(string) if strings.ToLower(crtype) == "Default" { @@ -183,6 +251,7 @@ func resourceIbmDnsCrForwardingRuleUpdate(context context.Context, d *schema.Res } } } + result, resp, err := dnsSvcsClient.UpdateForwardingRuleWithContext(context, opt) if err != nil || result == nil { return diag.FromErr(fmt.Errorf("[ERROR] Error updating the forwarding rule %s:%s", err, resp)) @@ -209,3 +278,32 @@ func resourceIbmDnsCrForwardingRuleDelete(context context.Context, d *schema.Res d.SetId("") return nil } + +func expandPDNSFRViews(viewsList []interface{}) []dns.ViewConfig { + views := []dns.ViewConfig{} + for _, viewElem := range viewsList { + viewItem := viewElem.(map[string]interface{}) + view := dns.ViewConfig{ + Name: core.StringPtr(viewItem[pdnsCRFRVName].(string)), + Description: core.StringPtr(viewItem[pdnsCRFRVDescription].(string)), + Expression: core.StringPtr(viewItem[pdnsCRFRVExpression].(string)), + ForwardTo: flex.ExpandStringList(viewItem[pdnsCRFRVForwardTo].([]interface{})), + } + views = append(views, view) + } + return views +} + +func flattenPDNSFRViews(list []dns.ViewConfig) []map[string]interface{} { + views := []map[string]interface{}{} + for _, view := range list { + l := map[string]interface{}{ + pdnsCRFRVName: *view.Name, + pdnsCRFRVExpression: *view.Expression, + pdnsCRFRVDescription: *view.Description, + pdnsCRFRVForwardTo: view.ForwardTo, + } + views = append(views, l) + } + return views +} diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go index e34ab97b2d..1458e1709a 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go @@ -18,23 +18,30 @@ func TestAccIBMPrivateDNSCustomResolverForwardingRule_basic(t *testing.T) { match := "test.example.com" vpcname := fmt.Sprintf("fr-vpc-%d", acctest.RandIntRange(10, 100)) subnetname := fmt.Sprintf("fr-subnet-name-%d", acctest.RandIntRange(10, 100)) + viewName := "view-example-1" + viewDesc := "view-example-description" + viewExpression := "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, typeVar, match), + Config: testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, typeVar, match, viewName, viewDesc, viewExpression), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "type", typeVar), resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "match", match), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "views.#", "1"), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "views.0.name", viewName), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "views.0.description", viewDesc), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "views.0.expression", viewExpression), ), }, }, }) } -func testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, zone, cidr, typeVar, match string) string { +func testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, zone, cidr, typeVar, match, viewName, viewDesc, viewExpression string) string { return fmt.Sprintf(` data "ibm_resource_group" "rg" { is_default = true @@ -75,6 +82,12 @@ func testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, zone, cidr, t type = "%s" match = "%s" forward_to = ["168.20.22.122"] + views { + name = "%s" + description = "%s" + expression = "%s" + forward_to = ["10.240.2.1"] + } } - `, vpcname, subnetname, zone, cidr, typeVar, match) + `, vpcname, subnetname, zone, cidr, typeVar, match, viewName, viewDesc, viewExpression) } diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_secondary_zone.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_secondary_zone.go index 34245e1abc..3d15a66a5d 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_secondary_zone.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_secondary_zone.go @@ -104,12 +104,10 @@ func resourceIBMPrivateDNSSecondaryZoneCreate(ctx context.Context, d *schema.Res enabled := d.Get(pdnsSecondaryZoneEnabled).(bool) transferFrom := flex.ExpandStringList(d.Get(pdnsSecondaryZoneTransferFrom).([]interface{})) - createSecondaryZoneOptions := sess.NewCreateSecondaryZoneOptions(instanceID, resolverID) + createSecondaryZoneOptions := sess.NewCreateSecondaryZoneOptions(instanceID, resolverID, zone, transferFrom) - createSecondaryZoneOptions.SetZone(zone) createSecondaryZoneOptions.SetDescription(description) createSecondaryZoneOptions.SetEnabled(enabled) - createSecondaryZoneOptions.SetTransferFrom(transferFrom) mk := "private_dns_secondary_zone_" + instanceID + resolverID conns.IbmMutexKV.Lock(mk) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_test.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_test.go index 4fb4d5e6d9..b63f46246a 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_test.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_test.go @@ -22,17 +22,19 @@ func TestAccIBMPrivateDNSCustomResolver_basic(t *testing.T) { subnetname := fmt.Sprintf("cr-subnet-name-%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("testpdnscustomresolver%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)) description := "new test CR - TF" + profile := "essential" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, name, description), + Config: testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, name, description, profile), Check: resource.ComposeTestCheckFunc( testAccCheckIBMPrivateDNSCustomResolverExists("ibm_dns_custom_resolver.test", resultprivatedns), resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "name", name), resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "description", description), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "profile", profile), ), }, }, @@ -45,16 +47,18 @@ func TestAccIBMPrivateDNSCustomResolverImport(t *testing.T) { subnetname := fmt.Sprintf("cr-subnet-name-%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("testpdnscustomresolver%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)) description := "new test CR - TF" + profile := "essential" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, name, description), + Config: testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, name, description, profile), Check: resource.ComposeTestCheckFunc( testAccCheckIBMPrivateDNSCustomResolverExists("ibm_dns_custom_resolver.test", resultprivatedns), resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "name", name), resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "description", description), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "profile", profile), ), }, { @@ -68,7 +72,7 @@ func TestAccIBMPrivateDNSCustomResolverImport(t *testing.T) { }) } -func testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, zone, cidr, name, description string) string { +func testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, zone, cidr, name, description, profile string) string { return fmt.Sprintf(` data "ibm_resource_group" "rg" { is_default = true @@ -101,8 +105,9 @@ func testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, zone, cid subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn enabled = true } + profile = "%s" } - `, vpcname, subnetname, zone, cidr, name, description) + `, vpcname, subnetname, zone, cidr, name, description, profile) } func testAccCheckIBMPrivateDNSCustomResolverExists(n string, result string) resource.TestCheckFunc { diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_glb.go b/ibm/service/dnsservices/resource_ibm_private_dns_glb.go index 2c00fb54cf..f0c757feaf 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_glb.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_glb.go @@ -152,12 +152,11 @@ func resourceIBMPrivateDNSGLBCreate(d *schema.ResourceData, meta interface{}) er } instanceID := d.Get(pdnsInstanceID).(string) zoneID := d.Get(pdnsZoneID).(string) - createlbOptions := sess.NewCreateLoadBalancerOptions(instanceID, zoneID) - lbname := d.Get(pdnsGLBName).(string) - createlbOptions.SetName(lbname) - createlbOptions.SetFallbackPool(d.Get(pdnsGLBFallbackPool).(string)) - createlbOptions.SetDefaultPools(flex.ExpandStringList(d.Get(pdnsGLBDefaultPool).([]interface{}))) + fallbackPool := d.Get(pdnsGLBFallbackPool).(string) + defaultPool := flex.ExpandStringList(d.Get(pdnsGLBDefaultPool).([]interface{})) + + createlbOptions := sess.NewCreateLoadBalancerOptions(instanceID, zoneID, lbname, fallbackPool, defaultPool) if description, ok := d.GetOk(pdnsGLBDescription); ok { createlbOptions.SetDescription(description.(string)) @@ -308,14 +307,14 @@ func resourceIBMPrivateDNSGLBExists(d *schema.ResourceData, meta interface{}) (b return true, nil } -func expandPDNSGlbAZPools(azpool interface{}) ([]dnssvcsv1.LoadBalancerAzPoolsItem, error) { +func expandPDNSGlbAZPools(azpool interface{}) ([]dnssvcsv1.AzPoolsItem, error) { azpools := azpool.(*schema.Set).List() - expandAZpools := make([]dnssvcsv1.LoadBalancerAzPoolsItem, 0) + expandAZpools := make([]dnssvcsv1.AzPoolsItem, 0) for _, v := range azpools { locationConfig := v.(map[string]interface{}) avzone := locationConfig[pdnsGLBAvailabilityZone].(string) pools := flex.ExpandStringList(locationConfig[pdnsGLBAZPoolsPools].([]interface{})) - aZItem := dnssvcsv1.LoadBalancerAzPoolsItem{ + aZItem := dnssvcsv1.AzPoolsItem{ AvailabilityZone: &avzone, Pools: pools, } @@ -324,7 +323,7 @@ func expandPDNSGlbAZPools(azpool interface{}) ([]dnssvcsv1.LoadBalancerAzPoolsIt return expandAZpools, nil } -func flattenPDNSGlbAZpool(azpool []dnssvcsv1.LoadBalancerAzPoolsItem) interface{} { +func flattenPDNSGlbAZpool(azpool []dnssvcsv1.AzPoolsItem) interface{} { flattened := make([]interface{}, 0) for _, v := range azpool { cfg := map[string]interface{}{ diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_glb_monitor.go b/ibm/service/dnsservices/resource_ibm_private_dns_glb_monitor.go index 7eea319b4d..ef2de87d78 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_glb_monitor.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_glb_monitor.go @@ -226,13 +226,13 @@ func resourceIBMPrivateDNSGLBMonitorCreate(d *schema.ResourceData, meta interfac return err } instanceID := d.Get(pdnsInstanceID).(string) - createMonitorOptions := sess.NewCreateMonitorOptions(instanceID) - monitorname := d.Get(pdnsGlbMonitorName).(string) + + createMonitorOptions := sess.NewCreateMonitorOptions(instanceID, monitorname, "") + monitorinterval := int64(d.Get(pdnsGlbMonitorInterval).(int)) monitorretries := int64(d.Get(pdnsGlbMonitorRetries).(int)) monitortimeout := int64(d.Get(pdnsGlbMonitorTimeout).(int)) - createMonitorOptions.SetName(monitorname) createMonitorOptions.SetInterval(monitorinterval) createMonitorOptions.SetRetries(monitorretries) createMonitorOptions.SetTimeout(monitortimeout) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_glb_pool.go b/ibm/service/dnsservices/resource_ibm_private_dns_glb_pool.go index 0fc4cc2a65..5c65d660ad 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_glb_pool.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_glb_pool.go @@ -178,10 +178,10 @@ func resourceIBMPrivateDNSGLBPoolCreate(d *schema.ResourceData, meta interface{} } instanceID := d.Get(pdnsInstanceID).(string) - CreatePoolOptions := sess.NewCreatePoolOptions(instanceID) - poolname := d.Get(pdnsGlbPoolName).(string) - CreatePoolOptions.SetName(poolname) + poolorigins := d.Get(pdnsGlbPoolOrigins).(*schema.Set) + + CreatePoolOptions := sess.NewCreatePoolOptions(instanceID, poolname, expandPDNSGlbPoolOrigins(poolorigins)) if description, ok := d.GetOk(pdnsGlbPoolDescription); ok { CreatePoolOptions.SetDescription(description.(string)) @@ -206,9 +206,6 @@ func resourceIBMPrivateDNSGLBPoolCreate(d *schema.ResourceData, meta interface{} CreatePoolOptions.SetHealthcheckSubnets(flex.ExpandStringList(subnets.([]interface{}))) } - poolorigins := d.Get(pdnsGlbPoolOrigins).(*schema.Set) - CreatePoolOptions.SetOrigins(expandPDNSGlbPoolOrigins(poolorigins)) - result, resp, err := sess.CreatePool(CreatePoolOptions) if err != nil { log.Printf("create global load balancer pool failed %s", resp) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_permitted_network.go b/ibm/service/dnsservices/resource_ibm_private_dns_permitted_network.go index 43be78f08c..2856d8f557 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_permitted_network.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_permitted_network.go @@ -112,14 +112,12 @@ func resourceIBMPrivateDNSPermittedNetworkCreate(d *schema.ResourceData, meta in conns.IbmMutexKV.Lock(mk) defer conns.IbmMutexKV.Unlock(mk) - createPermittedNetworkOptions := sess.NewCreatePermittedNetworkOptions(instanceID, zoneID) permittedNetworkCrn, err := sess.NewPermittedNetworkVpc(vpcCRN) if err != nil { return err } + createPermittedNetworkOptions := sess.NewCreatePermittedNetworkOptions(instanceID, zoneID, nwType, permittedNetworkCrn) - createPermittedNetworkOptions.SetPermittedNetwork(permittedNetworkCrn) - createPermittedNetworkOptions.SetType(nwType) response, detail, err := sess.CreatePermittedNetwork(createPermittedNetworkOptions) if err != nil { return fmt.Errorf("[ERROR] Error creating pdns permitted network:%s\n%s", err, detail) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_resource_record.go b/ibm/service/dnsservices/resource_ibm_private_dns_resource_record.go index 4a0f4eb371..27bea25c40 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_resource_record.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_resource_record.go @@ -229,9 +229,8 @@ func resourceIBMPrivateDNSResourceRecordCreate(d *schema.ResourceData, meta inte ttl = v.(int) } - createResourceRecordOptions := sess.NewCreateResourceRecordOptions(instanceID, zoneID) + createResourceRecordOptions := sess.NewCreateResourceRecordOptions(instanceID, zoneID, recordType) createResourceRecordOptions.SetName(name) - createResourceRecordOptions.SetType(recordType) createResourceRecordOptions.SetTTL(int64(ttl)) switch recordType { @@ -395,7 +394,7 @@ func resourceIBMPrivateDNSResourceRecordUpdate(d *schema.ResourceData, meta inte conns.IbmMutexKV.Lock(mk) defer conns.IbmMutexKV.Unlock(mk) - updateResourceRecordOptions := sess.NewUpdateResourceRecordOptions(idSet[0], idSet[1], idSet[2]) + updateResourceRecordOptions := sess.NewUpdateResourceRecordOptions(idSet[0], idSet[1], idSet[2], "", nil) var rdata string diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_zones.go b/ibm/service/dnsservices/resource_ibm_private_dns_zones.go index cb1676fa9a..9972c28b53 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_zones.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_zones.go @@ -115,8 +115,7 @@ func resourceIBMPrivateDNSZoneCreate(d *schema.ResourceData, meta interface{}) e if v, ok := d.GetOk(pdnsZoneLabel); ok { zoneLabel = v.(string) } - createZoneOptions := sess.NewCreateDnszoneOptions(instanceID) - createZoneOptions.SetName(zoneName) + createZoneOptions := sess.NewCreateDnszoneOptions(instanceID, zoneName) createZoneOptions.SetDescription(zoneDescription) createZoneOptions.SetLabel(zoneLabel) response, detail, err := sess.CreateDnszone(createZoneOptions) diff --git a/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown b/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown index e2d7ef370d..5b6b41468b 100644 --- a/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown +++ b/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown @@ -12,10 +12,10 @@ Provides a read-only data source for forwarding rules. You can then reference th ## Example usage - +```terraform data "ibm_dns_custom_resolver_forwarding_rules" "test-fr" { - instance_id = ibm_dns_custom_resolver.test.instance_id - resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id + instance_id = ibm_dns_custom_resolver.test.instance_id + resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id } ``` @@ -32,14 +32,16 @@ In addition to the argument references list, you can access the following attrib - `forwarding_rules` (List) List of forwarding rules. - Nested scheme for `forwarding_rules`: - - `description` - (String) Descriptive text of the forwarding rule. - - `forward_to` - (String) The upstream DNS servers will be forwarded to. - - `match` - (String) The matching zone or hostname. - - `rule_id` - (String) Identifier of the forwarding rule. - - `type` - (String) Type of the forwarding rule. - - - - - + Nested scheme for `forwarding_rules`: + - `description` - (String) Descriptive text of the forwarding rule. + - `forward_to` - (List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. + - `match` - (String) The matching zone or hostname. + - `rule_id` - (String) Identifier of the forwarding rule. + - `type` - (String) Type of the forwarding rule. + - `views` (List) List of views attached to the custom resolver. + + Nested scheme for `views`: + - `name` - (String) Name of the view. + - `description` - (String) Description of the view. + - `expression` - (String) Expression of the view. + - `forward_to` - (List) List of upstream DNS servers that the matching DNS queries will be forwarded to. diff --git a/website/docs/d/dns_custom_resolvers.html.markdown b/website/docs/d/dns_custom_resolvers.html.markdown index a8948d6e4a..e5c3d10625 100644 --- a/website/docs/d/dns_custom_resolvers.html.markdown +++ b/website/docs/d/dns_custom_resolvers.html.markdown @@ -8,39 +8,41 @@ description: |- # ibm_dns_custom_resolvers -Provides a read-only data source for custom resolvers. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. For more information about custom resolver, refer to [List custom resolvers](https://cloud.ibm.com/apidocs/dns-svcs#list-custom-resolvers). - +Provides a read-only data source for custom resolvers. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. For more information about custom resolver, see [List custom resolvers](https://cloud.ibm.com/apidocs/dns-svcs#list-custom-resolvers). ## Example usage ```terraform data "ibm_dns_custom_resolvers" "test-cr" { - instance_id = ibm_dns_custom_resolver.test.instance_id + instance_id = ibm_dns_custom_resolver.test.instance_id } ``` ## Argument reference -Review the argument reference that you can specify for your data source. + +Review the argument reference that you can specify for your data source. - `instance_id` - (Required, String) The GUID of the private DNS service instance. ## Attribute reference -In addition to the argument references list, you can access the following attribute references after your data source is created. + +In addition to the argument references list, you can access the following attribute references after your data source is created. - `custom_resolvers` (List) List of all private DNS custom resolvers. - + Nested scheme for `custom_resolvers`: - - `custom_resolver_id` - (String) Identifier of the custom resolver. - - `description` - (String) Descriptive text of the custom resolver. - - `enabled` - (String) Whether custom resolver is enabled/disabled. - - `health`- (String) The status of DNS custom resolver's health. Supported values are `CRITICAL`, `DEGRADED`, `HEALTHY`. - - `name` - (String) Name of the custom resolver. - - `locations` (List) The list of locations within the custom resolver. - - Nested scheme for `locations`: - - `dns_server_ip`- (String) The DNS server IP. - - `enabled`- (String) Whether the location is enabled/disabled. - - `healthy`- (String) The health status. - - `location_id`- (String) The location ID. - - `subnet_crn` - (String) The subnet CRN. - + - `custom_resolver_id` - (String) Identifier of the custom resolver. + - `description` - (String) Descriptive text of the custom resolver. + - `enabled` - (String) Whether the custom resolver is enabled or disabled. + - `health`- (String) The status of DNS custom resolver's health. Supported values are `CRITICAL`, `DEGRADED`, `HEALTHY`. + - `name` - (String) Name of the custom resolver. + - `profile` - (String) The profile name of the custom resolver. Supported values are `ESSENTIAL`, `ADVANCED`, `PREMIER`. + - `allow_disruptive_updates` - (Boolean) Whether a disruptive update is allowed for the custom resolver. + - `locations` (List) The list of locations within the custom resolver. + + Nested scheme for `locations`: + - `dns_server_ip`- (String) The DNS server IP. + - `enabled`- (String) Whether the location is enabled or disabled. + - `healthy`- (String) The health status. + - `location_id`- (String) The location ID. + - `subnet_crn` - (String) The subnet CRN. diff --git a/website/docs/r/dns_custom_resolver.html.markdown b/website/docs/r/dns_custom_resolver.html.markdown index 5f948325b1..baa3900f2a 100644 --- a/website/docs/r/dns_custom_resolver.html.markdown +++ b/website/docs/r/dns_custom_resolver.html.markdown @@ -10,62 +10,64 @@ description: |- Provides a private DNS custom resolver resource. This allows DNS custom resolver to create, update, and delete. For more information, about customer resolver, see [create-custom-resolver](https://cloud.ibm.com/apidocs/dns-svcs#create-custom-resolver). - ## Example usage ```terraform - - data "ibm_resource_group" "rg" { - is_default = true - } - resource "ibm_is_vpc" "test-pdns-cr-vpc" { - name = "test-pdns-custom-resolver-vpc" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_is_subnet" "test-pdns-cr-subnet1" { - name = "test-pdns-cr-subnet1" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.0.0/24" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_is_subnet" "test-pdns-cr-subnet2" { - name = "test-pdns-cr-subnet2" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.64.0/24" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_resource_instance" "test-pdns-cr-instance" { - name = "test-pdns-cr-instance" - resource_group_id = data.ibm_resource_group.rg.id - location = "global" - service = "dns-svcs" - plan = "standard-dns" - } - resource "ibm_dns_custom_resolver" "test" { - name = "test-customresolver" - instance_id = ibm_resource_instance.test-pdns-cr-instance.guid - description = "new test CR - TF" - high_availability = true - enabled = true - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn - enabled = true - } - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn - enabled = true - } - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn - enabled = false - } - } + + data "ibm_resource_group" "rg" { + is_default = true + } + resource "ibm_is_vpc" "test-pdns-cr-vpc" { + name = "test-pdns-custom-resolver-vpc" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_is_subnet" "test-pdns-cr-subnet1" { + name = "test-pdns-cr-subnet1" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.0.0/24" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_is_subnet" "test-pdns-cr-subnet2" { + name = "test-pdns-cr-subnet2" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.64.0/24" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_resource_instance" "test-pdns-cr-instance" { + name = "test-pdns-cr-instance" + resource_group_id = data.ibm_resource_group.rg.id + location = "global" + service = "dns-svcs" + plan = "standard-dns" + } + resource "ibm_dns_custom_resolver" "test" { + name = "test-customresolver" + instance_id = ibm_resource_instance.test-pdns-cr-instance.guid + description = "new test CR - TF" + high_availability = true + enabled = true + profile = "essential" + allow_disruptive_updates = false + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn + enabled = true + } + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn + enabled = true + } + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn + enabled = false + } + } ``` ## Argument reference -Review the argument reference that you can specify for your resource. + +Review the argument reference that you can specify for your resource. - `instance_id` - (Required, String) The GUID of the private DNS service instance. - `name`- (Required, String) The name of the custom resolver. @@ -73,11 +75,14 @@ Review the argument reference that you can specify for your resource. - `description` - (Optional, String) Descriptive text of the custom resolver. - `high_availability` - (Optional, Bool) High Availability is enabled by Default. To meet high availability status, configure custom resolvers with a minimum of two resolver locations. - `locations`- (Optional, List) The list of locations where this custom resolver is deployed. A custom resolver can have a maximum of three locations, either within the same subnet or in different subnets. +- `profile` - (Optional, String) The profile name of the custom resolver. Supported values are `ESSENTIAL`, `ADVANCED`, `PREMIER`. Default value is `ESSENTIAL`. +- `allow_disruptive_updates` - (Optional, Boolean) Whether disruptive update is allowed for the custom resolver. Default value is false. ## Attribute reference -In addition to all argument reference list, you can access the following attribute references after your resource is created. -- `created_on` - (Timestamp) The time (created On) of the DNS Custom Resolver. +In addition to all argument reference list, you can access the following attribute references after your resource is created. + +- `created_on` - (Timestamp) The time (created On) of the DNS Custom Resolver. - `custom_resolver_id` - (String) The unique ID of the private DNS custom resolver. - `modified_on` - (Timestamp) The time (modified On) of the DNS Custom Resolver. - `health`- (String) The status of DNS Custom Resolver's health. Possible values are `DEGRADED`, `CRITICAL`, `HEALTHY`. @@ -89,23 +94,32 @@ In addition to all argument reference list, you can access the following attribu - `enabled`- (Bool) Whether the location is enabled. - `location_id`- (String) The location ID. - Nested scheme for `rules`: - - `rule_id` - (String) The rule ID is unique identifier of the custom resolver forwarding rule. - - `description`- (String) Descriptive text of the forwarding rule. - - `type` - (String) Type of the forwarding rule.Constraints: Allowable values are: `zone`, `hostname`. - - `match` - (String) The matching zone or hostname. - - `forward_to` - (List) The upstream DNS servers will be forwarded to. + Nested scheme for `rules`: + - `rule_id` - (String) The rule ID is unique identifier of the custom resolver forwarding rule. + - `description`- (String) Descriptive text of the forwarding rule. + - `type` - (String) Type of the forwarding rule. + - Constraints: Allowable values are: `zone`, `hostname`. + - `match` - (String) The matching zone or hostname. + - `forward_to` - (List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. + - `views` (List) List of views attached to the custom resolver. + + Nested scheme for `views`: + - `name` - (String) Name of the view. + - `description` - (String) Description of the view. + - `expression` - (String) Expression of the view. + - `forward_to` - (List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. ## Import + The `ibm_dns_custom_resolver` can be imported by using private DNS instance ID, Custom Resolver ID. The `id` property can be formed from `custom_resolver_id` and `instance_id` in the following format: -``` -: +```terraform +terraform import ibm_dns_custom_resolver.example : ``` -**Example** +### Example -``` -$ terraform import ibm_dns_custom_resolver.example 270edfad-8574-4ce0-86bf-5c158d3e38fe:345ca2c4-83bf-4c04-bb09-5d8ec4d425a8 +```terraform +terraform import ibm_dns_custom_resolver.example 270edfad-8574-4ce0-86bf-5c158d3e38fe:345ca2c4-83bf-4c04-bb09-5d8ec4d425a8 ``` diff --git a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown index 857289bf5e..4ab8e0f5f0 100644 --- a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown +++ b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown @@ -13,57 +13,62 @@ Provides a resource for ibm_dns_custom_resolver_forwarding_rule. This allows For ## Example usage ```terraform - - data "ibm_resource_group" "rg" { - is_default = true - } - resource "ibm_is_vpc" "test-pdns-cr-vpc" { - name = "test-pdns-custom-resolver-vpc" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_is_subnet" "test-pdns-cr-subnet1" { - name = "test-pdns-cr-subnet1" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.0.0/24" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_is_subnet" "test-pdns-cr-subnet2" { - name = "test-pdns-cr-subnet2" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.64.0/24" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_resource_instance" "test-pdns-cr-instance" { - name = "test-pdns-cr-instance" - resource_group_id = data.ibm_resource_group.rg.id - location = "global" - service = "dns-svcs" - plan = "standard-dns" - } - resource "ibm_dns_custom_resolver" "test" { - name = "test-customresolver" - instance_id = ibm_resource_instance.test-pdns-cr-instance.guid - description = "new test CR - TF" - enabled = true - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn - enabled = true - } - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn - enabled = true - } - } - resource "ibm_dns_custom_resolver_forwarding_rule" "dns_custom_resolver_forwarding_rule" { - instance_id = ibm_resource_instance.test-pdns-cr-instance.guid - resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id - description = "Test Fw Rule" - type = "zone" - match = "test.example.com" - forward_to = ["168.20.22.122"] - } + data "ibm_resource_group" "rg" { + is_default = true + } + resource "ibm_is_vpc" "test-pdns-cr-vpc" { + name = "test-pdns-custom-resolver-vpc" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_is_subnet" "test-pdns-cr-subnet1" { + name = "test-pdns-cr-subnet1" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.0.0/24" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_is_subnet" "test-pdns-cr-subnet2" { + name = "test-pdns-cr-subnet2" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.64.0/24" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_resource_instance" "test-pdns-cr-instance" { + name = "test-pdns-cr-instance" + resource_group_id = data.ibm_resource_group.rg.id + location = "global" + service = "dns-svcs" + plan = "standard-dns" + } + resource "ibm_dns_custom_resolver" "test" { + name = "test-customresolver" + instance_id = ibm_resource_instance.test-pdns-cr-instance.guid + description = "new test CR - TF" + enabled = true + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn + enabled = true + } + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn + enabled = true + } + } + resource "ibm_dns_custom_resolver_forwarding_rule" "dns_custom_resolver_forwarding_rule" { + instance_id = ibm_resource_instance.test-pdns-cr-instance.guid + resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id + description = "Test Fw Rule" + type = "zone" + match = "test.example.com" + forward_to = ["168.20.22.122"] + views { + name = "view-example-1" + description = "view example 1" + expression = "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" + forward_to = ["10.240.2.6","10.240.2.7"] + } + } ``` ## Argument reference @@ -74,9 +79,16 @@ Review the argument reference that you can specify for your resource. * `resolver_id` - (Required, String) The unique identifier of a custom resolver. * `description` - (Optional, String) Descriptive text of the forwarding rule. * `type` - (Optional, String) Type of the forwarding rule. - * Constraints: Allowable values is: zone. + * Constraints: Allowable values is: `zone`. * `match` - (Optional, String) The matching zone or hostname. -* `forward_to` - (Optional, List) The upstream DNS servers will be forwarded to. +* `forward_to` - (Optional, List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. +* `views` (Optional, List) List of views attached to the custom resolver. + + Nested scheme for `views`: + * `name` - (Required, String) Name of the view. + * `description` - (optional, String) Description of the view. + * `expression` - (Required, String) Expression of the view. + * `forward_to` - (Required, List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. ## Attribute reference @@ -92,13 +104,14 @@ In addition to all argument reference list, you can access the following attribu You can import the `ibm_dns_custom_resolver_forwarding_rule` resource by using `id`. The `id` property can be formed from `rule_id`, `resolver_id`, and `instance_id` in the following format: +```terraform +terraform import ibm_dns_custom_resolver_forwarding_rule.ibm_dns_custom_resolver_forwarding_rule :: ``` -:: -``` + * `rule_id`: A String. The unique identifier of a forwarding rule. * `resolver_id`: A String. The unique identifier of a custom resolver. * `instance_id`: A String. The GUID of the private DNS service instance. -``` -$ terraform import ibm_dns_custom_resolver_forwarding_rule.ibm_dns_custom_resolver_forwarding_rule :: +```terraform +terraform import ibm_dns_custom_resolver_forwarding_rule.ibm_dns_custom_resolver_forwarding_rule :: ```