@@ -720,6 +720,97 @@ func testAccCheckScalewayDomainRecordExists(tt *TestTools, n string) resource.Te
720720 }
721721}
722722
723+ func TestAccScalewayDomainRecord_CNAME (t * testing.T ) {
724+ tt := NewTestTools (t )
725+ defer tt .Cleanup ()
726+
727+ testDNSZone := fmt .Sprintf ("test-basic.%s" , testDomain )
728+ l .Debugf ("TestAccScalewayDomainRecord_Basic: test dns zone: %s" , testDNSZone )
729+
730+ name := "tf"
731+ recordType := "CNAME"
732+ data := "xxx.scw.cloud"
733+ dataUpdated := "yyy.scw.cloud"
734+ ttl := 3600
735+ ttlUpdated := 43200
736+ priority := 0
737+ priorityUpdated := 10
738+
739+ resource .ParallelTest (t , resource.TestCase {
740+ PreCheck : func () { testAccPreCheck (t ) },
741+ ProviderFactories : tt .ProviderFactories ,
742+ CheckDestroy : testAccCheckScalewayDomainRecordDestroy (tt ),
743+ Steps : []resource.TestStep {
744+ {
745+ Config : fmt .Sprintf (`
746+ resource "scaleway_domain_record" "tf_CNAME" {
747+ dns_zone = "%s"
748+ name = "%s"
749+ type = "%s"
750+ data = "%s"
751+ ttl = %d
752+ priority = %d
753+ }
754+ ` , testDNSZone , name , recordType , data , ttl , priority ),
755+ Check : resource .ComposeTestCheckFunc (
756+ testAccCheckScalewayDomainRecordExists (tt , "scaleway_domain_record.tf_CNAME" ),
757+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "dns_zone" , testDNSZone ),
758+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "name" , name ),
759+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "type" , recordType ),
760+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "data" , data ),
761+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "ttl" , fmt .Sprint (ttl )),
762+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "priority" , fmt .Sprint (priority )),
763+ testCheckResourceAttrUUID ("scaleway_domain_record.tf_CNAME" , "id" ),
764+ ),
765+ },
766+ {
767+ Config : fmt .Sprintf (`
768+ resource "scaleway_domain_record" "tf_CNAME" {
769+ dns_zone = "%s"
770+ name = "%s"
771+ type = "%s"
772+ data = "%s"
773+ ttl = %d
774+ priority = %d
775+ }
776+ ` , testDNSZone , name , recordType , dataUpdated , ttl , priority ),
777+ Check : resource .ComposeTestCheckFunc (
778+ testAccCheckScalewayDomainRecordExists (tt , "scaleway_domain_record.tf_CNAME" ),
779+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "dns_zone" , testDNSZone ),
780+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "name" , name ),
781+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "type" , recordType ),
782+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "data" , dataUpdated ),
783+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "ttl" , fmt .Sprint (ttl )),
784+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "priority" , fmt .Sprint (priority )),
785+ testCheckResourceAttrUUID ("scaleway_domain_record.tf_CNAME" , "id" ),
786+ ),
787+ },
788+ {
789+ Config : fmt .Sprintf (`
790+ resource "scaleway_domain_record" "tf_CNAME" {
791+ dns_zone = "%s"
792+ name = "%s"
793+ type = "%s"
794+ data = "%s"
795+ ttl = %d
796+ priority = %d
797+ }
798+ ` , testDNSZone , name , recordType , dataUpdated , ttlUpdated , priorityUpdated ),
799+ Check : resource .ComposeTestCheckFunc (
800+ testAccCheckScalewayDomainRecordExists (tt , "scaleway_domain_record.tf_CNAME" ),
801+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "dns_zone" , testDNSZone ),
802+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "name" , name ),
803+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "type" , recordType ),
804+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "data" , dataUpdated ),
805+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "ttl" , fmt .Sprint (ttlUpdated )),
806+ resource .TestCheckResourceAttr ("scaleway_domain_record.tf_CNAME" , "priority" , fmt .Sprint (priorityUpdated )),
807+ testCheckResourceAttrUUID ("scaleway_domain_record.tf_CNAME" , "id" ),
808+ ),
809+ },
810+ },
811+ })
812+ }
813+
723814func testAccCheckScalewayDomainRecordDestroy (tt * TestTools ) resource.TestCheckFunc {
724815 return func (state * terraform.State ) error {
725816 for _ , rs := range state .RootModule ().Resources {
0 commit comments