C# Amazon.CDK.AWS.S3.Deployment: Source.Bucket does not expose an AssetOptions
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
Have a `BucketDeployment` with the `Source` populated via a `Source.Bucket` expose an `AssetOptions` such that `Include`/`Exclude` sematics can be applied to either include or ignore files from the zip file.
The `Source.Bucket` would be similar to `Source.Asset` n that it would include an additional parameter for AssetOptions that expose the `IFileCopyOptions` interface.
### Use Case
I have a build process that builds a website and zips the distribution to a zip file that is stages (per DevOps process) to a staging S3 container.
I want to be able to configure a pair of `S3.BucketDeployment`'s as part of a CloudFront Distribution:
- first that deploys the static assets with one set of `CacheControl` settings
- second that deploys the `index.html` with a different set of `CacheControl` settings
In this way I can specify the `AssetOptions` such than when the zip is extracted to the destination bucket the requite Exclude is applied to the files as extracted, such that the correct `CacheControl` settings are applied.
### Proposed Solution
```C#
new BucketDeployment(this, "FrontEndDeploymentWithCache", new BucketDeploymentProps
{
Sources = new[] { Source.Bucket(packageBucket, "Frontend.zip", new AssetOptions { Exclude = "index.html" } }, //<-- note AssetOptions
DestinationBucket = frontendBucket,
Distribution = distribution,
LogRetention = RetentionDays.ONE_DAY,
CacheControl = new [] { SetPublic(), MaxAge(Duration.Days(365)), FromString("immutable")},
Prune = true
});
new BucketDeployment(this, "FrontEndDeploymentNoCache", new BucketDeploymentProps
{
Sources = new[] { Source.Bucket(packageBucket, "Frontend.zip", new AssetOptions { Exclude = "!index.html" } ) }, // <-- note AssetOptions
DestinationBucket = frontendBucket,
Distribution = distribution,
LogRetention = RetentionDays.ONE_DAY,
CacheControl = new [] { SetPublic(), MaxAge(Duration.Seconds(0)), SMaxAge(Duration.Seconds(0))},
Prune = true
});
```
### Other Information
Alternate approach would be to be able to specify multiple `CacheControl`'s each with an Include/Exclude Glob such that various settings for various file sets can be deployed with a single Deployment.
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.50.0
### Environment details (OS name and version, etc.)
Mac OS 13
Contributor guide
Research direction
Start at the Source.Bucket and AssetOptions API definitions, then trace how BucketDeployment consumes sources and how Source.Asset handles options. Done means Source.Bucket can apply include and exclude patterns while extracting the zip, supporting the separate cache-control deployments described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, csharp, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100