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
1 change: 1 addition & 0 deletions docs/resources/edge_services_cache_stage.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ resource "scaleway_edge_services_cache_stage" "main" {
- `waf_stage_id` - (Optional) The WAF stage ID the cache stage will be linked to. Only one of `backend_stage_id`, `route_stage_id` and `waf_stage_id` should be specified.
- `fallback_ttl` - (Optional) The Time To Live (TTL) in seconds. Defines how long content is cached.
- `refresh_cache` - (Optional) Trigger a refresh of the cache by changing this field's value.
- `include_cookies` - (Optional) Defines whether responses to requests with cookies must be stored in the cache.
- `purge_requests` - (Optional) The Scaleway Object Storage origin bucket (S3) linked to the backend stage.
- `pipeline_id` - The pipeline ID in which the purge request will be created.
- `assets` - The list of asserts to purge.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/nats-io/jwt/v2 v2.7.4
github.com/nats-io/nats.go v1.38.0
github.com/robfig/cron/v3 v3.0.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250613133518-6987cd48643b
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250625143510-4421125d41b9
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.38.0
gopkg.in/dnaeon/go-vcr.v3 v3.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250613133518-6987cd48643b h1:7V7T9XzUl+B/6zHeNxyX0DV3OVjCSedA0stHo0BNKZw=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250613133518-6987cd48643b/go.mod h1:zFWiHphneiey3s8HOtAEnGrRlWivNaxW5T6d5Xfco7g=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250625143510-4421125d41b9 h1:9twhtdDBC2hYdNk6dhdOUWyx+quP0MTsMyub8r6K86U=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250625143510-4421125d41b9/go.mod h1:zFWiHphneiey3s8HOtAEnGrRlWivNaxW5T6d5Xfco7g=
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
12 changes: 12 additions & 0 deletions internal/services/edgeservices/cache_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func ResourceCacheStage() *schema.Resource {
Optional: true,
Description: "Trigger a refresh of the cache by changing this field's value",
},
"include_cookies": {
Type: schema.TypeBool,
Optional: true,
Description: "Defines whether responses to requests with cookies must be stored in the cache",
},
"created_at": {
Type: schema.TypeString,
Computed: true,
Expand All @@ -110,6 +115,7 @@ func ResourceCacheStageCreate(ctx context.Context, d *schema.ResourceData, m any
RouteStageID: types.ExpandStringPtr(d.Get("route_stage_id").(string)),
WafStageID: types.ExpandStringPtr(d.Get("waf_stage_id").(string)),
FallbackTTL: &scw.Duration{Seconds: int64(d.Get("fallback_ttl").(int))},
IncludeCookies: types.ExpandBoolPtr(d.Get("include_cookies").(bool)),
}, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down Expand Up @@ -143,6 +149,7 @@ func ResourceCacheStageRead(ctx context.Context, d *schema.ResourceData, m any)
_ = d.Set("route_stage_id", types.FlattenStringPtr(cacheStage.RouteStageID))
_ = d.Set("waf_stage_id", types.FlattenStringPtr(cacheStage.WafStageID))
_ = d.Set("fallback_ttl", cacheStage.FallbackTTL.Seconds)
_ = d.Set("include_cookies", cacheStage.IncludeCookies)

return nil
}
Expand Down Expand Up @@ -176,6 +183,11 @@ func ResourceCacheStageUpdate(ctx context.Context, d *schema.ResourceData, m any
hasChanged = true
}

if d.HasChange("include_cookies") {
updateRequest.IncludeCookies = types.ExpandBoolPtr(d.Get("include_cookies").(bool))
hasChanged = true
}

if hasChanged {
_, err := api.UpdateCacheStage(updateRequest, scw.WithContext(ctx))
if err != nil {
Expand Down
25 changes: 25 additions & 0 deletions internal/services/edgeservices/cache_stage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ func TestAccEdgeServicesCache_Basic(t *testing.T) {
"scaleway_edge_services_pipeline.main", "id",
"scaleway_edge_services_cache_stage.main", "pipeline_id"),
resource.TestCheckResourceAttr("scaleway_edge_services_cache_stage.main", "fallback_ttl", "3600"),
resource.TestCheckResourceAttr("scaleway_edge_services_cache_stage.main", "include_cookies", "false"),
resource.TestCheckResourceAttrSet("scaleway_edge_services_cache_stage.main", "created_at"),
resource.TestCheckResourceAttrSet("scaleway_edge_services_cache_stage.main", "updated_at"),
),
},
{
Config: `
resource "scaleway_edge_services_pipeline" "main" {
name = "my-edge_services-pipeline"
description = "pipeline description"
}

resource "scaleway_edge_services_cache_stage" "main" {
pipeline_id = scaleway_edge_services_pipeline.main.id
include_cookies = true
fallback_ttl = 7200
}
`,
Check: resource.ComposeTestCheckFunc(
edgeservicestestfuncs.CheckEdgeServicesCacheExists(tt, "scaleway_edge_services_cache_stage.main"),
resource.TestCheckResourceAttrPair(
"scaleway_edge_services_pipeline.main", "id",
"scaleway_edge_services_cache_stage.main", "pipeline_id"),
resource.TestCheckResourceAttr("scaleway_edge_services_cache_stage.main", "fallback_ttl", "7200"),
resource.TestCheckResourceAttr("scaleway_edge_services_cache_stage.main", "include_cookies", "true"),
resource.TestCheckResourceAttrSet("scaleway_edge_services_cache_stage.main", "created_at"),
resource.TestCheckResourceAttrSet("scaleway_edge_services_cache_stage.main", "updated_at"),
),
Expand Down
Loading
Loading