Skip to content

Fix cloud formation S3 CorsConfig#7866

Merged
pinzon merged 7 commits intolocalstack:masterfrom
deepak2431:fix-cfn_s3_cors_config
Mar 27, 2023
Merged

Fix cloud formation S3 CorsConfig#7866
pinzon merged 7 commits intolocalstack:masterfrom
deepak2431:fix-cfn_s3_cors_config

Conversation

@deepak2431
Copy link
Contributor

This PR is for issue #7836
No CORS configuration was implemented for S3 models if passed through the template. I have implemented the code to consider the CORSConfiguration, too while creating the bucket.

@pinzon You can review it!

Copy link
Member

@pinzon pinzon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty awesome, just need some small changes.

"AllowedHeaders": rule.get("AllowedHeaders"),
"AllowedMethods": rule.get("AllowedMethods"),
"AllowedOrigins": rule.get("AllowedOrigins"),
"ExposeHeaders": rule["ExposedHeaders"] if rule.get("ExposedHeaders") else None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dictionary.get("key") will return None if the there's no value

Suggested change
"ExposeHeaders": rule["ExposedHeaders"] if rule.get("ExposedHeaders") else None,
"ExposeHeaders": rule.get("ExposedHeaders"),

transformed_cors = cors_config.copy()
transformed_cors["CORSRules"] = [
{
"ID": rule["Id"] if rule["Id"] is not None else None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Suggested change
"ID": rule["Id"] if rule["Id"] is not None else None,
"ID": rule.get("Id"),

"AllowedMethods": rule.get("AllowedMethods"),
"AllowedOrigins": rule.get("AllowedOrigins"),
"ExposeHeaders": rule["ExposedHeaders"] if rule.get("ExposedHeaders") else None,
"MaxAgeSeconds": rule["MaxAge"] if rule.get("MaxAge") else None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"MaxAgeSeconds": rule["MaxAge"] if rule.get("MaxAge") else None,
"MaxAgeSeconds": rule.get("MaxAge"),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small nitpicks.

I have made all the requested changes.

Copy link
Member

@pinzon pinzon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small nitpicks.

@pinzon pinzon merged commit 5faafc9 into localstack:master Mar 27, 2023
@pinzon
Copy link
Member

pinzon commented Mar 27, 2023

Congrats @deepak2431 !! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants