aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap
CloudFormation adds `AWS::S3::Bucket CorsRule` optional properties when not specified
- Dominant language
- No language data
- Stars
- 1.1k
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
### Name of the resource
AWS::S3::Bucket
### Resource Name
_No response_
### Issue Description
Adding the following CORS Policy from the S3 AWS Console is valid:
```json
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD",
"POST"
],
"AllowedOrigins": [
"*"
]
}
]
```
Yet, if you try to apply the exact same configuration through CloudFormation:
```yaml
S3Bucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
BucketName: "MyBucket"
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- "*"
AllowedMethods:
- GET
- HEAD
- POST
AllowedOrigins:
- "*"
```
This is what you would end up with:
```json
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD",
"POST"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [],
"MaxAgeSeconds": 0
}
]
```
### Expected Behavior
I expected CloudFormation to honor the provided configuration, without adding any extra properties that are optional.
### Observed Behavior
CloudFormation reserved the right to automatically append additional properties to your S3 CORS policy, despite them being optional.
Although the inclusion of `"ExposeHeaders": []` might be considered harmless, the same cannot be said for `"MaxAgeSeconds": 0`.
This setting prevents the browser from caching, as opposed to when the property is not specified, allowing the browser to default to its standard caching period.
### Test Cases
See above.
### Other Details
_No response_
Contributor guide
Research direction
Start by applying the supplied CloudFormation YAML for AWS::S3::Bucket and compare the resulting CORS policy with the console configuration. Confirm whether omitted optional properties are appended, especially ExposeHeaders and MaxAgeSeconds; done means the behavior matches the requested configuration without unintended defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100