File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
apps/infrastructure/src/modules/video_streaming Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " infrastructure " : patch
3+ ---
4+
5+ Assignt cors policy to the cloudfront distribution for video streaming
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ No modules.
2424| [ aws_acm_certificate_validation.cdn_cert_validation] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/acm_certificate_validation ) | resource |
2525| [ aws_cloudfront_distribution.s3_distribution] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution ) | resource |
2626| [ aws_cloudfront_origin_access_control.video_oac] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_origin_access_control ) | resource |
27+ | [ aws_cloudfront_response_headers_policy.cors_policy] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_response_headers_policy ) | resource |
2728| [ aws_iam_policy.ivs_recording_policy] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy ) | resource |
2829| [ aws_iam_role.ivs_recording_role] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role ) | resource |
2930| [ aws_iam_role_policy_attachment.ivs_recording_attach] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment ) | resource |
@@ -37,6 +38,7 @@ No modules.
3738| [ aws_s3_bucket_public_access_block.ivs_recordings_pac] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block ) | resource |
3839| [ random_id.suffix] ( https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id ) | resource |
3940| [ aws_ivs_stream_key.channels] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ivs_stream_key ) | data source |
41+ | [ aws_route53_zone.selected] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route53_zone ) | data source |
4042
4143## Inputs
4244
Original file line number Diff line number Diff line change @@ -132,6 +132,8 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
132132 min_ttl = 0
133133 default_ttl = 3600 # Cache objects for 1 hour by default
134134 max_ttl = 86400 # Cache objects for up to 24 hours
135+
136+ response_headers_policy_id = aws_cloudfront_response_headers_policy. cors_policy . id
135137 }
136138
137139 # Standard restrictions
@@ -157,6 +159,36 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
157159 }
158160}
159161
162+ data "aws_route53_zone" "selected" {
163+ zone_id = var. route53_zone_id
164+ }
165+
166+
167+ resource "aws_cloudfront_response_headers_policy" "cors_policy" {
168+ name = " cors-policy-video-streaming"
169+ comment = " Cors policy for video streaming."
170+
171+ cors_config {
172+ access_control_allow_credentials = false
173+
174+ access_control_allow_headers {
175+ items = [" *" ]
176+ }
177+
178+
179+ access_control_allow_methods {
180+ items = [" GET" , " HEAD" ]
181+ }
182+
183+
184+ access_control_allow_origins {
185+ items = [" https://${ data . aws_route53_zone . selected . name } " ]
186+ }
187+
188+ origin_override = true
189+ }
190+ }
191+
160192# Policy that allows CloudFront (via OAC) to read from the bucket
161193resource "aws_s3_bucket_policy" "allow_cloudfront_oac" {
162194 bucket = aws_s3_bucket. ivs_recordings . id
You can’t perform that action at this time.
0 commit comments