Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/resources/tem_domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ resource "scaleway_tem_domain" "main" {
resource "scaleway_domain_record" "spf" {
dns_zone = var.domain_name
type = "TXT"
data = "v=spf1 ${scaleway_tem_domain.main.spf_config} -all"
data = scaleway_tem_domain.main.spf_value
}

resource "scaleway_domain_record" "dkim" {
dns_zone = var.domain_name
name = "${scaleway_tem_domain.main.project_id}._domainkey"
name = scaleway_tem_domain.main.dkim_name
type = "TXT"
data = scaleway_tem_domain.main.dkim_config
}

resource "scaleway_domain_record" "mx" {
dns_zone = var.domain_name
type = "MX"
data = "."
data = scaleway_tem_domain.main.mx_config
}

resource "scaleway_domain_record" "dmarc" {
Expand Down Expand Up @@ -147,6 +147,12 @@ In addition to all arguments above, the following attributes are exported:

- `dmarc_config` - DMARC record for the domain, as should be recorded in the DNS zone.

- `dkim_name` - DKIM name for the domain, as should be recorded in the DNS zone.

- `spf_value` - Complete SPF record value for the domain, as should be recorded in the DNS zone.

- `mx_config` - MX record configuration for the domain blackhole.

- `smtp_host` - The SMTP host to use to send emails.

- `smtp_port_unsecure` - The SMTP port to use to send emails.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/nats-io/jwt/v2 v2.8.0
github.com/nats-io/nats.go v1.46.1
github.com/robfig/cron/v3 v3.0.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20250929150437-c65b49480cff
github.com/stretchr/testify v1.11.1
golang.org/x/crypto v0.42.0
golang.org/x/sync v0.17.0
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
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/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk=
github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
github.com/docker/docker v28.4.0+incompatible h1:KVC7bz5zJY/4AZe/78BIvCnPsLaC9T/zh72xnlrTTOk=
Expand Down Expand Up @@ -203,6 +201,8 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
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/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -456,8 +456,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35 h1:8xfn1RzeI9yoCUuEwDy08F+No6PcKZGEDOQ6hrRyLts=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35/go.mod h1:47B1d/YXmSAxlJxUJxClzHR6b3T4M1WyCvwENPQNBWc=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20250929150437-c65b49480cff h1:1XC8rVPK4hr2lHdHajSurEV2Orp8eMGQ42vqh4hVX7M=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20250929150437-c65b49480cff/go.mod h1:DVB9HV7nK7TdTRqlpdxw6T0Wxg+aB9xPBEpO3aM2iqQ=
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=
Expand Down Expand Up @@ -895,6 +895,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/dnaeon/go-vcr.v3 v3.2.0 h1:Rltp0Vf+Aq0u4rQXgmXgtgoRDStTnFN83cWgSGSoRzM=
gopkg.in/dnaeon/go-vcr.v3 v3.2.0/go.mod h1:2IMOnnlx9I6u9x+YBsM3tAMx6AlOxnJ0pWxQAzZ79Ag=
gopkg.in/dnaeon/go-vcr.v4 v4.0.5 h1:I0hpTIvD5rII+8LgYGrHMA2d4SQPoL6u7ZvJakWKsiA=
gopkg.in/dnaeon/go-vcr.v4 v4.0.5/go.mod h1:dRos81TkW9C1WJt6tTaE+uV2Lo8qJT3AG2b35+CB/nQ=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4=
gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
Expand Down
51 changes: 45 additions & 6 deletions internal/services/tem/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ func ResourceDomain() *schema.Resource {
Computed: true,
Description: "DMARC record for the domain, as should be recorded in the DNS zone",
},
"dkim_name": {
Type: schema.TypeString,
Computed: true,
Description: "DKIM name for the domain, as should be recorded in the DNS zone",
},
"spf_value": {
Type: schema.TypeString,
Computed: true,
Description: "Complete SPF record value for the domain, as should be recorded in the DNS zone",
},
"mx_config": {
Type: schema.TypeString,
Computed: true,
Description: "MX record configuration for the domain blackhole",
},
"smtp_host": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -243,12 +258,36 @@ func ResourceDomainRead(ctx context.Context, d *schema.ResourceData, m any) diag
_ = d.Set("spf_config", domain.SpfConfig)
_ = d.Set("dkim_config", domain.DkimConfig)

if domain.Records != nil && domain.Records.Dmarc != nil {
_ = d.Set("dmarc_name", domain.Records.Dmarc.Name)
_ = d.Set("dmarc_config", domain.Records.Dmarc.Value)
} else {
_ = d.Set("dmarc_name", "")
_ = d.Set("dmarc_config", "")
if domain.Records != nil {
// DMARC
if domain.Records.Dmarc != nil {
_ = d.Set("dmarc_name", domain.Records.Dmarc.Name)
_ = d.Set("dmarc_config", domain.Records.Dmarc.Value)
} else {
_ = d.Set("dmarc_name", "")
_ = d.Set("dmarc_config", "")
}

// DKIM
if domain.Records.Dkim != nil {
_ = d.Set("dkim_name", domain.Records.Dkim.Name)
} else {
_ = d.Set("dkim_name", "")
}

// SPF
if domain.Records.Spf != nil {
_ = d.Set("spf_value", domain.Records.Spf.Value)
} else {
_ = d.Set("spf_value", "")
}

// MX
if domain.Records.Mx != nil {
_ = d.Set("mx_config", domain.Records.Mx.Value)
} else {
_ = d.Set("mx_config", "")
}
}

_ = d.Set("smtp_host", tem.SMTPHost)
Expand Down
21 changes: 15 additions & 6 deletions internal/services/tem/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ func TestAccDomain_Basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
isDomainPresent(tt, "scaleway_tem_domain.cr01"),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "name", domainName),
resource.TestCheckResourceAttrSet("scaleway_tem_domain.cr01", "dmarc_config"),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "dmarc_name", "_dmarc.terraform-rs"),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "dmarc_config", "v=DMARC1; p=none"),
resource.TestMatchResourceAttr("scaleway_tem_domain.cr01", "dmarc_name", regexp.MustCompile(`^_dmarc\.terraform-rs\.test\.local\.$`)),
resource.TestMatchResourceAttr("scaleway_tem_domain.cr01", "dkim_name", regexp.MustCompile(`^[a-f0-9-]+\._domainkey\.terraform-rs\.test\.local\.$`)),
resource.TestMatchResourceAttr("scaleway_tem_domain.cr01", "spf_value", regexp.MustCompile(`^v=spf1 include:terraform-rs\.test\.local -all$`)),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "mx_config", "10 blackhole.tem.scaleway.com."),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "last_error", ""), // last_error is deprecated
acctest.CheckResourceAttrUUID("scaleway_tem_domain.cr01", "id"),
),
Expand Down Expand Up @@ -106,8 +109,11 @@ func TestAccDomain_Autoconfig(t *testing.T) {
isDomainPresent(tt, "scaleway_tem_domain.cr01"),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "name", subDomainName+"."+domainNameValidation),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "autoconfig", "true"),
resource.TestCheckResourceAttrSet("scaleway_tem_domain.cr01", "dmarc_config"),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "dmarc_name", "_dmarc"+"."+subDomainName),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "dmarc_config", "v=DMARC1; p=none"),
resource.TestMatchResourceAttr("scaleway_tem_domain.cr01", "dmarc_name", regexp.MustCompile(`^_dmarc\.`+regexp.QuoteMeta(subDomainName+"."+domainNameValidation)+`\.$`)),
resource.TestMatchResourceAttr("scaleway_tem_domain.cr01", "dkim_name", regexp.MustCompile(`^[a-f0-9-]+\._domainkey\.`+regexp.QuoteMeta(subDomainName+"."+domainNameValidation)+`\.$`)),
resource.TestMatchResourceAttr("scaleway_tem_domain.cr01", "spf_value", regexp.MustCompile(`^v=spf1 include:`+regexp.QuoteMeta(subDomainName+"."+domainNameValidation)+` -all$`)),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "mx_config", "10 blackhole.tem.scaleway.com."),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "last_error", ""), // last_error is deprecated
acctest.CheckResourceAttrUUID("scaleway_tem_domain.cr01", "id"),
resource.TestCheckResourceAttr("scaleway_tem_domain_validation.valid", "validated", "true"),
Expand Down Expand Up @@ -146,8 +152,11 @@ func TestAccDomain_AutoconfigUpdate(t *testing.T) {
isDomainPresent(tt, "scaleway_tem_domain.cr01"),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "name", subDomainName+"."+domainNameValidation),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "autoconfig", "false"),
resource.TestCheckResourceAttrSet("scaleway_tem_domain.cr01", "dmarc_config"),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "dmarc_name", "_dmarc"+"."+subDomainName),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "dmarc_config", "v=DMARC1; p=none"),
resource.TestMatchResourceAttr("scaleway_tem_domain.cr01", "dmarc_name", regexp.MustCompile(`^_dmarc\.`+regexp.QuoteMeta(subDomainName+"."+domainNameValidation)+`\.$`)),
resource.TestMatchResourceAttr("scaleway_tem_domain.cr01", "dkim_name", regexp.MustCompile(`^[a-f0-9-]+\._domainkey\.`+regexp.QuoteMeta(subDomainName+"."+domainNameValidation)+`\.$`)),
resource.TestMatchResourceAttr("scaleway_tem_domain.cr01", "spf_value", regexp.MustCompile(`^v=spf1 include:`+regexp.QuoteMeta(subDomainName+"."+domainNameValidation)+` -all$`)),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "mx_config", "10 blackhole.tem.scaleway.com."),
resource.TestCheckResourceAttr("scaleway_tem_domain.cr01", "last_error", ""), // last_error is deprecated
acctest.CheckResourceAttrUUID("scaleway_tem_domain.cr01", "id"),
),
Expand Down
Loading
Loading