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
44 changes: 21 additions & 23 deletions internal/services/iot/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,13 @@ func ResourceRoute() *schema.Resource {
Description: "The Topic the route subscribes to (wildcards allowed)",
},
"database": {
Type: schema.TypeList,
MinItems: 1,
MaxItems: 1,
Optional: true,
ForceNew: true,
Description: "Database Route parameters",
ExactlyOneOf: []string{
iot.RouteRouteTypeDatabase.String(),
iot.RouteRouteTypeRest.String(),
iot.RouteRouteTypeS3.String(),
},
Type: schema.TypeList,
MinItems: 1,
MaxItems: 1,
Optional: true,
ForceNew: true,
Description: "Database Route parameters",
ConflictsWith: []string{"rest", "s3"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"query": {
Expand Down Expand Up @@ -105,12 +101,13 @@ func ResourceRoute() *schema.Resource {
},
},
"rest": {
Type: schema.TypeList,
MinItems: 1,
MaxItems: 1,
Optional: true,
ForceNew: true,
Description: "Rest Route parameters",
Type: schema.TypeList,
MinItems: 1,
MaxItems: 1,
Optional: true,
ForceNew: true,
Description: "Rest Route parameters",
ConflictsWith: []string{"database", "s3"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"verb": {
Expand Down Expand Up @@ -140,12 +137,13 @@ func ResourceRoute() *schema.Resource {
},
},
"s3": {
Type: schema.TypeList,
MinItems: 1,
MaxItems: 1,
Optional: true,
ForceNew: true,
Description: "S3 Route parameters",
Type: schema.TypeList,
MinItems: 1,
MaxItems: 1,
Optional: true,
ForceNew: true,
Description: "S3 Route parameters",
ConflictsWith: []string{"database", "rest"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"bucket_region": {
Expand Down
47 changes: 26 additions & 21 deletions internal/services/iot/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,35 @@ func TestAccRoute_S3(t *testing.T) {
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
resource "scaleway_object_bucket" "minimal" {
name = "%s"
}
locals {
bucket_region = "fr-par"
}

resource "scaleway_iot_hub" "minimal" {
name = "minimal"
product_plan = "plan_shared"
}
resource "scaleway_object_bucket" "minimal" {
name = "%s"
region = local.bucket_region
}

resource "scaleway_iot_route" "default" {
name = "default"
hub_id = scaleway_iot_hub.minimal.id
topic = "#"
resource "scaleway_iot_hub" "minimal" {
name = "minimal"
product_plan = "plan_shared"
}

s3 {
bucket_region = scaleway_object_bucket.minimal.region
bucket_name = scaleway_object_bucket.minimal.name
object_prefix = "foo"
strategy = "per_topic"
}

depends_on = [scaleway_object_bucket.minimal]
}
`, bucketName),
resource "scaleway_iot_route" "default" {
name = "default"
hub_id = scaleway_iot_hub.minimal.id
topic = "#"

s3 {
bucket_region = local.bucket_region
bucket_name = scaleway_object_bucket.minimal.name
object_prefix = "foo"
strategy = "per_topic"
}

depends_on = [scaleway_object_bucket.minimal]
}
`, bucketName),
Check: resource.ComposeTestCheckFunc(
objectchecks.CheckBucketExists(tt, "scaleway_object_bucket.minimal", true),
isHubPresent(tt, "scaleway_iot_hub.minimal"),
Expand Down
Loading
Loading