winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.06k stars 198 forks source link

feat(sdk)!: `cloud.Bucket` supports CORS by default #7104

Closed Chriscbr closed 2 months ago

Chriscbr commented 2 months ago

Closes #7058 Closes #7048

Currently, signed URLs created with cloud.Bucket can't be used by web applications in Wing since CORS options aren't configurable. CORS (Cross-Origin Resource Sharing) affects how the browser can access other domains. To solve this, we add two new fields, cors and corsOptions to the props of cloud.Bucket.

We've configured cors: true as the default so that these kinds of use cases for using signed URLs will work out of the box. If the bucket is private, CORS settings still apply, but they only come into effect when the bucket's objects are accessed through a signed URL or by authenticated users.

BREAKING CHANGE: cloud.Bucket now is synthesized with CORS configuration by default (currently only supported on AWS). If your bucket is public or you are using signed URLs extensively, you may want to consider configuring the corsOptions on the bucket or disabling CORS based on your application's needs.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

github-actions[bot] commented 2 months ago

Thanks for opening this pull request! :tada: Please consult the contributing guidelines for details on how to contribute to this project. If you need any assistance, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and standard library @chriscbr
Wing Console @skyrpex
Wing compiler and language design @chriscbr
VSCode extension and language server @chriscbr
Wing CLI @chriscbr
Documentation @boyney123
Examples @boyney123
Wing Playground @skyrpex
monadabot commented 2 months ago

Console preview environment is available at https://wing-console-pr-7104.fly.dev :rocket:

Last Updated (UTC) 2024-09-10 23:29
monadabot commented 2 months ago

Benchmarks

Comparison to Baseline ⬜🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜ | Benchmark | Before | After | Change | | :-- | --: | --: | --: | | version | 58ms±0.9 | 58ms±0.52 | 0ms (-0.7%)⬜ | | functions_10.test.w -t sim | 496ms±16.15 | 523ms±17.15 | +27ms (+5.4%)🟥 | | functions_10.test.w -t tf-aws | 2208ms±15.54 | 2200ms±16.99 | -8ms (-0.37%)⬜ | | jsii_small.test.w -t sim | 382ms±4.58 | 378ms±4.07 | -4ms (-1.02%)⬜ | | jsii_small.test.w -t tf-aws | 609ms±3.89 | 609ms±5.92 | 0ms (-0.06%)⬜ | | functions_1.test.w -t sim | 414ms±4.61 | 411ms±5.01 | -3ms (-0.78%)⬜ | | functions_1.test.w -t tf-aws | 851ms±6.23 | 840ms±6.27 | -11ms (-1.29%)⬜ | | empty.test.w -t sim | 377ms±2.17 | 373ms±4.96 | -4ms (-1.01%)⬜ | | empty.test.w -t tf-aws | 603ms±6.46 | 598ms±5.22 | -6ms (-0.92%)⬜ | | hello_world.test.w -t sim | 414ms±5.66 | 415ms±5.8 | +1ms (+0.32%)⬜ | | hello_world.test.w -t tf-aws | 1499ms±4.49 | 1473ms±11.19 | -26ms (-1.74%)⬜ | | jsii_big.test.w -t sim | 2970ms±20.2 | 2972ms±23.01 | +3ms (+0.09%)⬜ | | jsii_big.test.w -t tf-aws | 3195ms±12.77 | 3175ms±24.86 | -20ms (-0.63%)⬜ | ⬜ Within 1.5 standard deviations 🟩 Faster, Above 1.5 standard deviations 🟥 Slower, Above 1.5 standard deviations _Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI._
Results |name|mean|min|max|moe|sd| |----|----|----|----|----|----| |version|58ms|57ms|59ms|1ms|1ms| |functions_10.test.w -t sim|523ms|494ms|559ms|17ms|24ms| |functions_10.test.w -t tf-aws|2200ms|2145ms|2229ms|17ms|24ms| |jsii_small.test.w -t sim|378ms|369ms|387ms|4ms|6ms| |jsii_small.test.w -t tf-aws|609ms|594ms|623ms|6ms|8ms| |functions_1.test.w -t sim|411ms|403ms|425ms|5ms|7ms| |functions_1.test.w -t tf-aws|840ms|827ms|858ms|6ms|9ms| |empty.test.w -t sim|373ms|361ms|384ms|5ms|7ms| |empty.test.w -t tf-aws|598ms|589ms|608ms|5ms|7ms| |hello_world.test.w -t sim|415ms|399ms|425ms|6ms|8ms| |hello_world.test.w -t tf-aws|1473ms|1450ms|1510ms|11ms|16ms| |jsii_big.test.w -t sim|2972ms|2917ms|3035ms|23ms|32ms| |jsii_big.test.w -t tf-aws|3175ms|3095ms|3209ms|25ms|35ms|
Last Updated (UTC) 2024-09-10 23:34
mergify[bot] commented 2 months ago

Thanks for contributing, @Chriscbr! This PR will now be added to the merge queue, or immediately merged if rybickic/bucket-cors is up-to-date with main and the queue is empty.

monadabot commented 2 months ago

Congrats! :rocket: This was released in Wing 0.85.0.