diff --git a/transcoder_job_basic/backing_file.tf b/transcoder_job_basic/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/transcoder_job_basic/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/transcoder_job_basic/main.tf b/transcoder_job_basic/main.tf new file mode 100644 index 00000000..7dac2d15 --- /dev/null +++ b/transcoder_job_basic/main.tf @@ -0,0 +1,108 @@ +resource "google_storage_bucket" "default" { + name = "transcoder-job-${local.name_suffix}" + location = "US" + force_destroy = true + + uniform_bucket_level_access = true + public_access_prevention = "enforced" +} + +resource "google_storage_bucket_object" "example_mp4" { + name = "example.mp4" + source = "./test-fixtures/example.mp4" + bucket = google_storage_bucket.default.name +} + +resource "google_transcoder_job" "default" { + template_id = google_transcoder_job_template.default.name + location = "us-central1" + + labels = { + "label" = "key" + } +} + +resource "google_transcoder_job_template" "default" { + job_template_id = "example-job-template-${local.name_suffix}" + location = "us-central1" + config { + inputs { + key = "input0" + uri = "gs://${google_storage_bucket.default.name}/${google_storage_bucket_object.example_mp4.name}" + } + output { + uri = "gs://${google_storage_bucket.default.name}/outputs/" + } + edit_list { + key = "atom0" + inputs = ["input0"] + start_time_offset = "0s" + } + elementary_streams { + key = "video-stream0" + video_stream { + h264 { + width_pixels = 640 + height_pixels = 360 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 550000 + vbv_fullness_bits = 495000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + + } + } + } + elementary_streams { + key = "video-stream1" + video_stream { + h264 { + width_pixels = 1280 + height_pixels = 720 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 2500000 + vbv_fullness_bits = 2250000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + } + } + } + elementary_streams { + key = "audio-stream0" + audio_stream { + codec = "aac" + bitrate_bps = 64000 + channel_count = 2 + channel_layout = ["fl", "fr"] + sample_rate_hertz = 48000 + } + } + mux_streams { + key = "sd" + file_name = "sd.mp4" + container = "mp4" + elementary_streams = ["video-stream0", "audio-stream0"] + } + mux_streams { + key = "hd" + file_name = "hd.mp4" + container = "mp4" + elementary_streams = ["video-stream1", "audio-stream0"] + } + } + labels = { + "label" = "key" + } +} diff --git a/transcoder_job_basic/motd b/transcoder_job_basic/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/transcoder_job_basic/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/transcoder_job_basic/tutorial.md b/transcoder_job_basic/tutorial.md new file mode 100644 index 00000000..c5f4e6db --- /dev/null +++ b/transcoder_job_basic/tutorial.md @@ -0,0 +1,79 @@ +# Transcoder Job Basic - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +``` diff --git a/transcoder_job_manifests/backing_file.tf b/transcoder_job_manifests/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/transcoder_job_manifests/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/transcoder_job_manifests/main.tf b/transcoder_job_manifests/main.tf new file mode 100644 index 00000000..a89073b4 --- /dev/null +++ b/transcoder_job_manifests/main.tf @@ -0,0 +1,157 @@ +resource "google_storage_bucket" "default" { + name = "transcoder-job-${local.name_suffix}" + location = "US" + force_destroy = true + + uniform_bucket_level_access = true + public_access_prevention = "enforced" +} + +resource "google_storage_bucket_object" "example_mp4" { + name = "example.mp4" + source = "./test-fixtures/example.mp4" + bucket = google_storage_bucket.default.name +} + +resource "google_transcoder_job" "default" { + location = "us-central1" + + config { + inputs { + key = "input0" + uri = "gs://${google_storage_bucket.default.name}/${google_storage_bucket_object.example_mp4.name}" + } + + edit_list { + key = "atom0" + start_time_offset = "0s" + inputs = ["input0"] + } + + ad_breaks { + start_time_offset = "3.500s" + } + + elementary_streams { + key = "video-stream0" + video_stream { + h264 { + width_pixels = 640 + height_pixels = 360 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 550000 + vbv_fullness_bits = 495000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + + } + } + } + + elementary_streams { + key = "video-stream1" + video_stream { + h264 { + width_pixels = 1280 + height_pixels = 720 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 2500000 + vbv_fullness_bits = 2250000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + } + } + } + + elementary_streams { + key = "audio-stream0" + audio_stream { + codec = "aac" + bitrate_bps = 64000 + channel_count = 2 + channel_layout = ["fl", "fr"] + sample_rate_hertz = 48000 + } + } + + mux_streams { + key = "sd" + file_name = "sd.mp4" + container = "mp4" + elementary_streams = ["video-stream0", "audio-stream0"] + } + + mux_streams { + key = "hd" + file_name = "hd.mp4" + container = "mp4" + elementary_streams = ["video-stream1", "audio-stream0"] + } + + mux_streams { + key = "media-sd" + file_name = "media-sd.ts" + container = "ts" + elementary_streams = ["video-stream0", "audio-stream0"] + } + + mux_streams { + key = "media-hd" + file_name = "media-hd.ts" + container = "ts" + elementary_streams = ["video-stream1", "audio-stream0"] + } + + mux_streams { + key = "video-only-sd" + file_name = "video-only-sd.m4s" + container = "fmp4" + elementary_streams = ["video-stream0"] + } + + mux_streams { + key = "video-only-hd" + file_name = "video-only-hd.m4s" + container = "fmp4" + elementary_streams = ["video-stream1"] + } + + mux_streams { + key = "audio-only" + file_name = "audio-only.m4s" + container = "fmp4" + elementary_streams = ["audio-stream0"] + } + + manifests { + file_name = "manifest.m3u8" + type = "HLS" + mux_streams = ["media-sd", "media-hd"] + } + + manifests { + file_name = "manifest.mpd" + type = "DASH" + mux_streams = ["video-only-sd", "video-only-hd", "audio-only"] + } + + output { + uri = "gs://${google_storage_bucket.default.name}/outputs/" + } + } + labels = { + "label" = "key" + } +} diff --git a/transcoder_job_manifests/motd b/transcoder_job_manifests/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/transcoder_job_manifests/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/transcoder_job_manifests/tutorial.md b/transcoder_job_manifests/tutorial.md new file mode 100644 index 00000000..4325a65b --- /dev/null +++ b/transcoder_job_manifests/tutorial.md @@ -0,0 +1,79 @@ +# Transcoder Job Manifests - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +``` diff --git a/transcoder_job_overlays/backing_file.tf b/transcoder_job_overlays/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/transcoder_job_overlays/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/transcoder_job_overlays/main.tf b/transcoder_job_overlays/main.tf new file mode 100644 index 00000000..2d6b3737 --- /dev/null +++ b/transcoder_job_overlays/main.tf @@ -0,0 +1,124 @@ +resource "google_storage_bucket" "default" { + name = "transcoder-job-${local.name_suffix}" + location = "US" + force_destroy = true + + uniform_bucket_level_access = true + public_access_prevention = "enforced" +} + +resource "google_storage_bucket_object" "example_mp4" { + name = "example.mp4" + source = "./test-fixtures/example.mp4" + bucket = google_storage_bucket.default.name +} + +resource "google_storage_bucket_object" "overlay_png" { + name = "overlay.png" + source = "./test-fixtures/overlay.png" + bucket = google_storage_bucket.default.name +} + +resource "google_transcoder_job" "default" { + location = "us-central1" + + config { + inputs { + key = "input0" + uri = "gs://${google_storage_bucket.default.name}/${google_storage_bucket_object.example_mp4.name}" + } + edit_list { + key = "atom0" + inputs = ["input0"] + start_time_offset = "0s" + } + ad_breaks { + start_time_offset = "3.500s" + } + overlays { + animations { + animation_fade { + fade_type = "FADE_IN" + start_time_offset = "1.500s" + end_time_offset = "3.500s" + xy { + x = 1 + y = 0.5 + } + } + } + image { + uri = "gs://${google_storage_bucket.default.name}/${google_storage_bucket_object.overlay_png.name}" + } + } + elementary_streams { + key = "video-stream0" + video_stream { + h264 { + width_pixels = 640 + height_pixels = 360 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 550000 + vbv_fullness_bits = 495000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + + } + } + } + elementary_streams { + key = "video-stream1" + video_stream { + h264 { + width_pixels = 1280 + height_pixels = 720 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 2500000 + vbv_fullness_bits = 2250000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + } + } + } + elementary_streams { + key = "audio-stream0" + audio_stream { + codec = "aac" + bitrate_bps = 64000 + channel_count = 2 + channel_layout = ["fl", "fr"] + sample_rate_hertz = 48000 + } + } + mux_streams { + key = "sd" + file_name = "sd.mp4" + container = "mp4" + elementary_streams = ["video-stream0", "audio-stream0"] + } + mux_streams { + key = "hd" + file_name = "hd.mp4" + container = "mp4" + elementary_streams = ["video-stream1", "audio-stream0"] + } + output { + uri = "gs://${google_storage_bucket.default.name}/outputs/" + } + } + labels = { + "label" = "key" + } +} diff --git a/transcoder_job_overlays/motd b/transcoder_job_overlays/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/transcoder_job_overlays/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/transcoder_job_overlays/tutorial.md b/transcoder_job_overlays/tutorial.md new file mode 100644 index 00000000..3a8fc464 --- /dev/null +++ b/transcoder_job_overlays/tutorial.md @@ -0,0 +1,79 @@ +# Transcoder Job Overlays - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +``` diff --git a/transcoder_job_pubsub/backing_file.tf b/transcoder_job_pubsub/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/transcoder_job_pubsub/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/transcoder_job_pubsub/main.tf b/transcoder_job_pubsub/main.tf new file mode 100644 index 00000000..e26dedb9 --- /dev/null +++ b/transcoder_job_pubsub/main.tf @@ -0,0 +1,109 @@ +resource "google_storage_bucket" "default" { + name = "transcoder-job-${local.name_suffix}" + location = "US" + force_destroy = true + + uniform_bucket_level_access = true + public_access_prevention = "enforced" +} + +resource "google_storage_bucket_object" "example_mp4" { + name = "example.mp4" + source = "./test-fixtures/example.mp4" + bucket = google_storage_bucket.default.name +} + +resource "google_pubsub_topic" "transcoder_notifications" { + name = "transcoder-notifications-${local.name_suffix}" +} + +resource "google_transcoder_job" "default" { + location = "us-central1" + + config { + inputs { + key = "input0" + uri = "gs://${google_storage_bucket.default.name}/${google_storage_bucket_object.example_mp4.name}" + } + edit_list { + key = "atom0" + inputs = ["input0"] + start_time_offset = "0s" + } + ad_breaks { + start_time_offset = "3.500s" + } + elementary_streams { + key = "video-stream0" + video_stream { + h264 { + width_pixels = 640 + height_pixels = 360 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 550000 + vbv_fullness_bits = 495000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + + } + } + } + elementary_streams { + key = "video-stream1" + video_stream { + h264 { + width_pixels = 1280 + height_pixels = 720 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 2500000 + vbv_fullness_bits = 2250000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + } + } + } + elementary_streams { + key = "audio-stream0" + audio_stream { + codec = "aac" + bitrate_bps = 64000 + channel_count = 2 + channel_layout = ["fl", "fr"] + sample_rate_hertz = 48000 + } + } + mux_streams { + key = "sd" + file_name = "sd.mp4" + container = "mp4" + elementary_streams = ["video-stream0", "audio-stream0"] + } + mux_streams { + key = "hd" + file_name = "hd.mp4" + container = "mp4" + elementary_streams = ["video-stream1", "audio-stream0"] + } + pubsub_destination { + topic = google_pubsub_topic.transcoder_notifications.id + } + output { + uri = "gs://${google_storage_bucket.default.name}/outputs/" + } + } + labels = { + "label" = "key" + } +} diff --git a/transcoder_job_pubsub/motd b/transcoder_job_pubsub/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/transcoder_job_pubsub/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/transcoder_job_pubsub/tutorial.md b/transcoder_job_pubsub/tutorial.md new file mode 100644 index 00000000..02217d03 --- /dev/null +++ b/transcoder_job_pubsub/tutorial.md @@ -0,0 +1,79 @@ +# Transcoder Job Pubsub - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +``` diff --git a/transcoder_job_template_basic/backing_file.tf b/transcoder_job_template_basic/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/transcoder_job_template_basic/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/transcoder_job_template_basic/main.tf b/transcoder_job_template_basic/main.tf new file mode 100644 index 00000000..45df72d7 --- /dev/null +++ b/transcoder_job_template_basic/main.tf @@ -0,0 +1,84 @@ +resource "google_transcoder_job_template" "default" { + job_template_id = "example-job-template-${local.name_suffix}" + location = "us-central1" + + config { + inputs { + key = "input0" + } + edit_list { + key = "atom0" + inputs = ["input0"] + start_time_offset = "0s" + } + ad_breaks { + start_time_offset = "3.500s" + } + elementary_streams { + key = "video-stream0" + video_stream { + h264 { + width_pixels = 640 + height_pixels = 360 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 550000 + vbv_fullness_bits = 495000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + } + } + } + elementary_streams { + key = "video-stream1" + video_stream { + h264 { + width_pixels = 1280 + height_pixels = 720 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 2500000 + vbv_fullness_bits = 2250000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + + } + } + } + elementary_streams { + key = "audio-stream0" + audio_stream { + codec = "aac" + bitrate_bps = 64000 + channel_count = 2 + channel_layout = ["fl", "fr"] + sample_rate_hertz = 48000 + } + } + mux_streams { + key = "sd" + file_name = "sd.mp4" + container = "mp4" + elementary_streams = ["video-stream0", "audio-stream0"] + } + mux_streams { + key = "hd" + file_name = "hd.mp4" + container = "mp4" + elementary_streams = ["video-stream1", "audio-stream0"] + } + } + labels = { + "label" = "key" + } +} diff --git a/transcoder_job_template_basic/motd b/transcoder_job_template_basic/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/transcoder_job_template_basic/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/transcoder_job_template_basic/tutorial.md b/transcoder_job_template_basic/tutorial.md new file mode 100644 index 00000000..40921678 --- /dev/null +++ b/transcoder_job_template_basic/tutorial.md @@ -0,0 +1,79 @@ +# Transcoder Job Template Basic - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +``` diff --git a/transcoder_job_template_encryptions/backing_file.tf b/transcoder_job_template_encryptions/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/transcoder_job_template_encryptions/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/transcoder_job_template_encryptions/main.tf b/transcoder_job_template_encryptions/main.tf new file mode 100644 index 00000000..65347a00 --- /dev/null +++ b/transcoder_job_template_encryptions/main.tf @@ -0,0 +1,148 @@ +resource "google_secret_manager_secret" "encryption_key" { + secret_id = "transcoder-encryption-key-${local.name_suffix}" + replication { + auto {} + } +} + +resource "google_secret_manager_secret_version" "encryption_key" { + secret = google_secret_manager_secret.encryption_key.name + secret_data = "4A67F2C1B8E93A4F6D3E7890A1BC23DF" +} + +resource "google_transcoder_job_template" "default" { + job_template_id = "example-job-template-${local.name_suffix}" + location = "us-central1" + + config { + elementary_streams { + key = "es_video" + video_stream { + h264 { + profile = "main" + height_pixels = 600 + width_pixels = 800 + bitrate_bps = 1000000 + frame_rate = 60 + } + } + } + + elementary_streams { + key = "es_audio" + audio_stream { + codec = "aac" + channel_count = 2 + bitrate_bps = 160000 + } + } + + encryptions { + id = "aes-128" + secret_manager_key_source { + secret_version = google_secret_manager_secret_version.encryption_key.name + } + drm_systems { + clearkey {} + } + aes128 {} + } + + encryptions { + id = "cenc" + secret_manager_key_source { + secret_version = google_secret_manager_secret_version.encryption_key.name + } + drm_systems { + widevine {} + } + mpeg_cenc { + scheme = "cenc" + } + } + + encryptions { + id = "cbcs" + secret_manager_key_source { + secret_version = google_secret_manager_secret_version.encryption_key.name + } + drm_systems { + widevine {} + } + mpeg_cenc { + scheme = "cbcs" + } + } + + mux_streams { + key = "ts_aes128" + container = "ts" + elementary_streams = ["es_video", "es_audio"] + segment_settings { + segment_duration = "6s" + } + encryption_id = "aes-128" + } + + mux_streams { + key = "fmp4_cenc_video" + container = "fmp4" + elementary_streams = ["es_video"] + segment_settings { + segment_duration = "6s" + } + encryption_id = "cenc" + } + + mux_streams { + key = "fmp4_cenc_audio" + container = "fmp4" + elementary_streams = ["es_audio"] + segment_settings { + segment_duration = "6s" + } + encryption_id = "cenc" + } + + mux_streams { + key = "fmp4_cbcs_video" + container = "fmp4" + elementary_streams = ["es_video"] + segment_settings { + segment_duration = "6s" + } + encryption_id = "cbcs" + } + + mux_streams { + key = "fmp4_cbcs_audio" + container = "fmp4" + elementary_streams = ["es_audio"] + segment_settings { + segment_duration = "6s" + } + encryption_id = "cbcs" + } + + manifests { + file_name = "manifest_aes128.m3u8" + type = "HLS" + mux_streams = ["ts_aes128"] + } + + manifests { + file_name = "manifest_cenc.mpd" + type = "DASH" + mux_streams = ["fmp4_cenc_video", "fmp4_cenc_audio"] + } + + manifests { + file_name = "manifest_cbcs.mpd" + type = "DASH" + mux_streams = ["fmp4_cbcs_video", "fmp4_cbcs_audio"] + } + } + labels = { + "label" = "key" + } +} diff --git a/transcoder_job_template_encryptions/motd b/transcoder_job_template_encryptions/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/transcoder_job_template_encryptions/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/transcoder_job_template_encryptions/tutorial.md b/transcoder_job_template_encryptions/tutorial.md new file mode 100644 index 00000000..82ca70f5 --- /dev/null +++ b/transcoder_job_template_encryptions/tutorial.md @@ -0,0 +1,79 @@ +# Transcoder Job Template Encryptions - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +``` diff --git a/transcoder_job_template_overlays/backing_file.tf b/transcoder_job_template_overlays/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/transcoder_job_template_overlays/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/transcoder_job_template_overlays/main.tf b/transcoder_job_template_overlays/main.tf new file mode 100644 index 00000000..66308571 --- /dev/null +++ b/transcoder_job_template_overlays/main.tf @@ -0,0 +1,103 @@ +resource "google_transcoder_job_template" "default" { + job_template_id = "example-job-template-${local.name_suffix}" + location = "us-central1" + config { + inputs { + key = "input0" + uri = "gs://example/example.mp4" + } + output { + uri = "gs://example/outputs/" + } + edit_list { + key = "atom0" + inputs = ["input0"] + start_time_offset = "0s" + } + ad_breaks { + start_time_offset = "3.500s" + } + overlays { + animations { + animation_fade { + fade_type = "FADE_IN" + start_time_offset = "1.500s" + end_time_offset = "3.500s" + xy { + x = 1 + y = 0.5 + } + } + } + image { + uri = "gs://example/overlay.png" + } + } + elementary_streams { + key = "video-stream0" + video_stream { + h264 { + width_pixels = 640 + height_pixels = 360 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 550000 + vbv_fullness_bits = 495000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + + } + } + } + elementary_streams { + key = "video-stream1" + video_stream { + h264 { + width_pixels = 1280 + height_pixels = 720 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 2500000 + vbv_fullness_bits = 2250000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + } + } + } + elementary_streams { + key = "audio-stream0" + audio_stream { + codec = "aac" + bitrate_bps = 64000 + channel_count = 2 + channel_layout = ["fl", "fr"] + sample_rate_hertz = 48000 + } + } + mux_streams { + key = "sd" + file_name = "sd.mp4" + container = "mp4" + elementary_streams = ["video-stream0", "audio-stream0"] + } + mux_streams { + key = "hd" + file_name = "hd.mp4" + container = "mp4" + elementary_streams = ["video-stream1", "audio-stream0"] + } + } + labels = { + "label" = "key" + } +} diff --git a/transcoder_job_template_overlays/motd b/transcoder_job_template_overlays/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/transcoder_job_template_overlays/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/transcoder_job_template_overlays/tutorial.md b/transcoder_job_template_overlays/tutorial.md new file mode 100644 index 00000000..40601692 --- /dev/null +++ b/transcoder_job_template_overlays/tutorial.md @@ -0,0 +1,79 @@ +# Transcoder Job Template Overlays - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +``` diff --git a/transcoder_job_template_pubsub/backing_file.tf b/transcoder_job_template_pubsub/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/transcoder_job_template_pubsub/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/transcoder_job_template_pubsub/main.tf b/transcoder_job_template_pubsub/main.tf new file mode 100644 index 00000000..0446db4f --- /dev/null +++ b/transcoder_job_template_pubsub/main.tf @@ -0,0 +1,94 @@ +resource "google_pubsub_topic" "transcoder_notifications" { + name = "transcoder-notifications-${local.name_suffix}" +} + +resource "google_transcoder_job_template" "default" { + job_template_id = "example-job-template-${local.name_suffix}" + location = "us-central1" + config { + inputs { + key = "input0" + uri = "gs://example/example.mp4" + } + output { + uri = "gs://example/outputs/" + } + edit_list { + key = "atom0" + inputs = ["input0"] + start_time_offset = "0s" + } + ad_breaks { + start_time_offset = "3.500s" + } + elementary_streams { + key = "video-stream0" + video_stream { + h264 { + width_pixels = 640 + height_pixels = 360 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 550000 + vbv_fullness_bits = 495000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + + } + } + } + elementary_streams { + key = "video-stream1" + video_stream { + h264 { + width_pixels = 1280 + height_pixels = 720 + bitrate_bps = 550000 + frame_rate = 60 + pixel_format = "yuv420p" + rate_control_mode = "vbr" + crf_level = 21 + gop_duration = "3s" + vbv_size_bits = 2500000 + vbv_fullness_bits = 2250000 + entropy_coder = "cabac" + profile = "high" + preset = "veryfast" + } + } + } + elementary_streams { + key = "audio-stream0" + audio_stream { + codec = "aac" + bitrate_bps = 64000 + channel_count = 2 + channel_layout = ["fl", "fr"] + sample_rate_hertz = 48000 + } + } + mux_streams { + key = "sd" + file_name = "sd.mp4" + container = "mp4" + elementary_streams = ["video-stream0", "audio-stream0"] + } + mux_streams { + key = "hd" + file_name = "hd.mp4" + container = "mp4" + elementary_streams = ["video-stream1", "audio-stream0"] + } + pubsub_destination { + topic = google_pubsub_topic.transcoder_notifications.id + } + } + labels = { + "label" = "key" + } +} diff --git a/transcoder_job_template_pubsub/motd b/transcoder_job_template_pubsub/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/transcoder_job_template_pubsub/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/transcoder_job_template_pubsub/tutorial.md b/transcoder_job_template_pubsub/tutorial.md new file mode 100644 index 00000000..705e633d --- /dev/null +++ b/transcoder_job_template_pubsub/tutorial.md @@ -0,0 +1,79 @@ +# Transcoder Job Template Pubsub - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +```