2016-05-27 00:29:42 +02:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2016-08-16 20:41:12 +02:00
|
|
|
"reflect"
|
|
|
|
"sort"
|
2016-05-27 00:29:42 +02:00
|
|
|
"testing"
|
|
|
|
|
2017-02-03 17:40:33 +01:00
|
|
|
"regexp"
|
|
|
|
|
2016-05-27 00:29:42 +02:00
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
|
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
|
|
|
"github.com/aws/aws-sdk-go/service/elastictranscoder"
|
2016-08-16 20:41:12 +02:00
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
2016-05-27 00:29:42 +02:00
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAccAWSElasticTranscoderPipeline_basic(t *testing.T) {
|
|
|
|
pipeline := &elastictranscoder.Pipeline{}
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
IDRefreshName: "aws_elastictranscoder_pipeline.bar",
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2016-11-30 12:50:26 +01:00
|
|
|
{
|
2016-05-27 00:29:42 +02:00
|
|
|
Config: awsElasticTranscoderPipelineConfigBasic,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", pipeline),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-11-30 12:50:26 +01:00
|
|
|
func TestAccAWSElasticTranscoderPipeline_kmsKey(t *testing.T) {
|
|
|
|
pipeline := &elastictranscoder.Pipeline{}
|
|
|
|
ri := acctest.RandInt()
|
2017-02-03 17:40:33 +01:00
|
|
|
config := fmt.Sprintf(awsElasticTranscoderPipelineConfigKmsKey, ri, ri, ri)
|
2016-11-30 12:50:26 +01:00
|
|
|
keyRegex := regexp.MustCompile("^arn:aws:([a-zA-Z0-9\\-])+:([a-z]{2}-[a-z]+-\\d{1})?:(\\d{12})?:(.*)$")
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
IDRefreshName: "aws_elastictranscoder_pipeline.bar",
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
{
|
|
|
|
Config: config,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", pipeline),
|
|
|
|
resource.TestMatchResourceAttr("aws_elastictranscoder_pipeline.bar", "aws_kms_key_arn", keyRegex),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-08-16 20:41:12 +02:00
|
|
|
func TestAccAWSElasticTranscoderPipeline_notifications(t *testing.T) {
|
|
|
|
pipeline := elastictranscoder.Pipeline{}
|
|
|
|
|
|
|
|
rInt := acctest.RandInt()
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
IDRefreshName: "aws_elastictranscoder_pipeline.bar",
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2016-11-30 12:50:26 +01:00
|
|
|
{
|
2016-08-16 20:41:12 +02:00
|
|
|
Config: awsElasticTranscoderNotifications(rInt),
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", &pipeline),
|
|
|
|
testAccCheckAWSElasticTranscoderPipeline_notifications(&pipeline, []string{"warning", "completed"}),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
|
|
|
|
// update and check that we have 1 less notification
|
|
|
|
resource.TestStep{
|
|
|
|
Config: awsElasticTranscoderNotifications_update(rInt),
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", &pipeline),
|
|
|
|
testAccCheckAWSElasticTranscoderPipeline_notifications(&pipeline, []string{"completed"}),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// testAccCheckTags can be used to check the tags on a resource.
|
|
|
|
func testAccCheckAWSElasticTranscoderPipeline_notifications(
|
|
|
|
p *elastictranscoder.Pipeline, notifications []string) resource.TestCheckFunc {
|
|
|
|
return func(s *terraform.State) error {
|
|
|
|
|
|
|
|
var notes []string
|
|
|
|
if p.Notifications.Completed != nil && *p.Notifications.Completed != "" {
|
|
|
|
notes = append(notes, "completed")
|
|
|
|
}
|
|
|
|
if p.Notifications.Error != nil && *p.Notifications.Error != "" {
|
|
|
|
notes = append(notes, "error")
|
|
|
|
}
|
|
|
|
if p.Notifications.Progressing != nil && *p.Notifications.Progressing != "" {
|
|
|
|
notes = append(notes, "progressing")
|
|
|
|
}
|
|
|
|
if p.Notifications.Warning != nil && *p.Notifications.Warning != "" {
|
|
|
|
notes = append(notes, "warning")
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(notes) != len(notifications) {
|
|
|
|
return fmt.Errorf("ETC notifications didn't match:\n\texpected: %#v\n\tgot: %#v\n\n", notifications, notes)
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Strings(notes)
|
|
|
|
sort.Strings(notifications)
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(notes, notifications) {
|
|
|
|
return fmt.Errorf("ETC notifications were not equal:\n\texpected: %#v\n\tgot: %#v\n\n", notifications, notes)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-27 00:29:42 +02:00
|
|
|
func TestAccAWSElasticTranscoderPipeline_withContentConfig(t *testing.T) {
|
|
|
|
pipeline := &elastictranscoder.Pipeline{}
|
|
|
|
|
2017-02-03 17:40:33 +01:00
|
|
|
rInt := acctest.RandInt()
|
|
|
|
|
2016-05-27 00:29:42 +02:00
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
IDRefreshName: "aws_elastictranscoder_pipeline.bar",
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2016-11-30 12:50:26 +01:00
|
|
|
{
|
2017-02-03 17:40:33 +01:00
|
|
|
Config: awsElasticTranscoderPipelineWithContentConfig(rInt),
|
2016-05-27 00:29:42 +02:00
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", pipeline),
|
|
|
|
),
|
|
|
|
},
|
2016-11-30 12:50:26 +01:00
|
|
|
{
|
2017-02-03 17:40:33 +01:00
|
|
|
Config: awsElasticTranscoderPipelineWithContentConfigUpdate(rInt),
|
2016-05-27 00:29:42 +02:00
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", pipeline),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAccAWSElasticTranscoderPipeline_withPermissions(t *testing.T) {
|
|
|
|
pipeline := &elastictranscoder.Pipeline{}
|
|
|
|
|
2017-02-03 17:40:33 +01:00
|
|
|
rInt := acctest.RandInt()
|
|
|
|
|
2016-05-27 00:29:42 +02:00
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
IDRefreshName: "aws_elastictranscoder_pipeline.baz",
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2016-11-30 12:50:26 +01:00
|
|
|
{
|
2017-02-03 17:40:33 +01:00
|
|
|
Config: awsElasticTranscoderPipelineWithPerms(rInt),
|
2016-05-27 00:29:42 +02:00
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.baz", pipeline),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func testAccCheckAWSElasticTranscoderPipelineExists(n string, res *elastictranscoder.Pipeline) resource.TestCheckFunc {
|
|
|
|
return func(s *terraform.State) error {
|
|
|
|
rs, ok := s.RootModule().Resources[n]
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Not found: %s", n)
|
|
|
|
}
|
|
|
|
|
|
|
|
if rs.Primary.ID == "" {
|
|
|
|
return fmt.Errorf("No Pipeline ID is set")
|
|
|
|
}
|
|
|
|
|
|
|
|
conn := testAccProvider.Meta().(*AWSClient).elastictranscoderconn
|
|
|
|
|
|
|
|
out, err := conn.ReadPipeline(&elastictranscoder.ReadPipelineInput{
|
|
|
|
Id: aws.String(rs.Primary.ID),
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*res = *out.Pipeline
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testAccCheckElasticTranscoderPipelineDestroy(s *terraform.State) error {
|
|
|
|
conn := testAccProvider.Meta().(*AWSClient).elastictranscoderconn
|
|
|
|
|
|
|
|
for _, rs := range s.RootModule().Resources {
|
|
|
|
if rs.Type != "aws_elastictranscoder_pipline" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
out, err := conn.ReadPipeline(&elastictranscoder.ReadPipelineInput{
|
|
|
|
Id: aws.String(rs.Primary.ID),
|
|
|
|
})
|
|
|
|
|
|
|
|
if err == nil {
|
|
|
|
if out.Pipeline != nil && *out.Pipeline.Id == rs.Primary.ID {
|
|
|
|
return fmt.Errorf("Elastic Transcoder Pipeline still exists")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
awsErr, ok := err.(awserr.Error)
|
|
|
|
if !ok {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if awsErr.Code() != "ResourceNotFoundException" {
|
|
|
|
return fmt.Errorf("unexpected error: %s", awsErr)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const awsElasticTranscoderPipelineConfigBasic = `
|
|
|
|
resource "aws_elastictranscoder_pipeline" "bar" {
|
|
|
|
input_bucket = "${aws_s3_bucket.test_bucket.bucket}"
|
|
|
|
output_bucket = "${aws_s3_bucket.test_bucket.bucket}"
|
|
|
|
name = "aws_elastictranscoder_pipeline_tf_test_"
|
|
|
|
role = "${aws_iam_role.test_role.arn}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_iam_role" "test_role" {
|
|
|
|
name = "aws_elastictranscoder_pipeline_tf_test_role_"
|
|
|
|
|
|
|
|
assume_role_policy = <<EOF
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Action": "sts:AssumeRole",
|
|
|
|
"Principal": {
|
|
|
|
"Service": "ec2.amazonaws.com"
|
|
|
|
},
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Sid": ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2016-11-30 12:50:26 +01:00
|
|
|
resource "aws_s3_bucket" "test_bucket" {
|
|
|
|
bucket = "aws-elasticencoder-pipeline-tf-test-bucket"
|
|
|
|
acl = "private"
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
const awsElasticTranscoderPipelineConfigKmsKey = `
|
|
|
|
resource "aws_kms_key" "foo" {
|
|
|
|
description = "Terraform acc test %d"
|
|
|
|
policy = <<POLICY
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Id": "kms-tf-1",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Sid": "Enable IAM User Permissions",
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Principal": {
|
|
|
|
"AWS": "*"
|
|
|
|
},
|
|
|
|
"Action": "kms:*",
|
|
|
|
"Resource": "*"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
POLICY
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_elastictranscoder_pipeline" "bar" {
|
|
|
|
input_bucket = "${aws_s3_bucket.test_bucket.bucket}"
|
|
|
|
output_bucket = "${aws_s3_bucket.test_bucket.bucket}"
|
|
|
|
name = "aws_elastictranscoder_pipeline_tf_test_"
|
|
|
|
role = "${aws_iam_role.test_role.arn}"
|
|
|
|
aws_kms_key_arn = "${aws_kms_key.foo.arn}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_iam_role" "test_role" {
|
2017-02-03 17:40:33 +01:00
|
|
|
name = "tf_test_elastictranscoder_pipeline_%d"
|
2016-11-30 12:50:26 +01:00
|
|
|
|
|
|
|
assume_role_policy = <<EOF
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Action": "sts:AssumeRole",
|
|
|
|
"Principal": {
|
|
|
|
"Service": "ec2.amazonaws.com"
|
|
|
|
},
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Sid": ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2016-05-27 00:29:42 +02:00
|
|
|
resource "aws_s3_bucket" "test_bucket" {
|
2017-02-03 17:40:33 +01:00
|
|
|
bucket = "tf-test-aws-elasticencoder-pipeline-%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
acl = "private"
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2017-02-03 17:40:33 +01:00
|
|
|
func awsElasticTranscoderPipelineWithContentConfig(rInt int) string {
|
|
|
|
return fmt.Sprintf(`
|
2016-05-27 00:29:42 +02:00
|
|
|
resource "aws_elastictranscoder_pipeline" "bar" {
|
|
|
|
input_bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
2017-02-03 17:40:33 +01:00
|
|
|
name = "tf_test_pipeline_%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
role = "${aws_iam_role.test_role.arn}"
|
|
|
|
|
2016-06-07 23:06:25 +02:00
|
|
|
content_config {
|
2016-05-27 00:29:42 +02:00
|
|
|
bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
|
|
|
storage_class = "Standard"
|
|
|
|
}
|
|
|
|
|
2016-06-07 23:06:25 +02:00
|
|
|
thumbnail_config {
|
2016-05-27 00:29:42 +02:00
|
|
|
bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
|
|
|
storage_class = "Standard"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_iam_role" "test_role" {
|
2017-02-03 17:40:33 +01:00
|
|
|
name = "tf_pipeline_role_%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
|
|
|
|
assume_role_policy = <<EOF
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Action": "sts:AssumeRole",
|
|
|
|
"Principal": {
|
|
|
|
"Service": "ec2.amazonaws.com"
|
|
|
|
},
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Sid": ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "content_bucket" {
|
2017-02-03 17:40:33 +01:00
|
|
|
bucket = "tf-pipeline-content-%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
acl = "private"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "input_bucket" {
|
2017-02-03 17:40:33 +01:00
|
|
|
bucket = "tf-pipeline-input-%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
acl = "private"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "thumb_bucket" {
|
2017-02-03 17:40:33 +01:00
|
|
|
bucket = "tf-pipeline-thumb-%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
acl = "private"
|
2017-02-03 17:40:33 +01:00
|
|
|
}`, rInt, rInt, rInt, rInt, rInt)
|
2016-05-27 00:29:42 +02:00
|
|
|
}
|
|
|
|
|
2017-02-03 17:40:33 +01:00
|
|
|
func awsElasticTranscoderPipelineWithContentConfigUpdate(rInt int) string {
|
|
|
|
return fmt.Sprintf(`
|
2016-05-27 00:29:42 +02:00
|
|
|
resource "aws_elastictranscoder_pipeline" "bar" {
|
|
|
|
input_bucket = "${aws_s3_bucket.input_bucket.bucket}"
|
2017-02-03 17:40:33 +01:00
|
|
|
name = "tf_test_pipeline_%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
role = "${aws_iam_role.test_role.arn}"
|
|
|
|
|
2016-06-07 23:06:25 +02:00
|
|
|
content_config {
|
2016-05-27 00:29:42 +02:00
|
|
|
bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
|
|
|
storage_class = "Standard"
|
|
|
|
}
|
|
|
|
|
2016-06-07 23:06:25 +02:00
|
|
|
thumbnail_config {
|
2016-05-27 00:29:42 +02:00
|
|
|
bucket = "${aws_s3_bucket.thumb_bucket.bucket}"
|
|
|
|
storage_class = "Standard"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_iam_role" "test_role" {
|
2017-02-03 17:40:33 +01:00
|
|
|
name = "tf_pipeline_role_%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
|
|
|
|
assume_role_policy = <<EOF
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Action": "sts:AssumeRole",
|
|
|
|
"Principal": {
|
|
|
|
"Service": "ec2.amazonaws.com"
|
|
|
|
},
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Sid": ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "content_bucket" {
|
2017-02-03 17:40:33 +01:00
|
|
|
bucket = "tf-pipeline-content-%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
acl = "private"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "input_bucket" {
|
2017-02-03 17:40:33 +01:00
|
|
|
bucket = "tf-pipeline-input-%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
acl = "private"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "thumb_bucket" {
|
2017-02-03 17:40:33 +01:00
|
|
|
bucket = "tf-pipeline-thumb-%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
acl = "private"
|
2017-02-03 17:40:33 +01:00
|
|
|
}`, rInt, rInt, rInt, rInt, rInt)
|
2016-05-27 00:29:42 +02:00
|
|
|
}
|
|
|
|
|
2017-02-03 17:40:33 +01:00
|
|
|
func awsElasticTranscoderPipelineWithPerms(rInt int) string {
|
|
|
|
return fmt.Sprintf(`
|
2016-05-27 00:29:42 +02:00
|
|
|
resource "aws_elastictranscoder_pipeline" "baz" {
|
|
|
|
input_bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
2017-02-03 17:40:33 +01:00
|
|
|
name = "tf_test_pipeline_%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
role = "${aws_iam_role.test_role.arn}"
|
|
|
|
|
2016-06-07 23:06:25 +02:00
|
|
|
content_config {
|
2016-05-27 00:29:42 +02:00
|
|
|
bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
|
|
|
storage_class = "Standard"
|
|
|
|
}
|
|
|
|
|
|
|
|
content_config_permissions = {
|
|
|
|
grantee_type = "Group"
|
|
|
|
grantee = "AuthenticatedUsers"
|
|
|
|
access = ["FullControl"]
|
|
|
|
}
|
|
|
|
|
2016-06-07 23:06:25 +02:00
|
|
|
thumbnail_config {
|
2016-05-27 00:29:42 +02:00
|
|
|
bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
|
|
|
storage_class = "Standard"
|
|
|
|
}
|
|
|
|
|
|
|
|
thumbnail_config_permissions = {
|
|
|
|
grantee_type = "Group"
|
|
|
|
grantee = "AuthenticatedUsers"
|
|
|
|
access = ["FullControl"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_iam_role" "test_role" {
|
2017-02-03 17:40:33 +01:00
|
|
|
name = "tf_pipeline_role_%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
|
|
|
|
assume_role_policy = <<EOF
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Action": "sts:AssumeRole",
|
|
|
|
"Principal": {
|
|
|
|
"Service": "ec2.amazonaws.com"
|
|
|
|
},
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Sid": ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "content_bucket" {
|
2017-02-03 17:40:33 +01:00
|
|
|
bucket = "tf-transcoding-pipe-%d"
|
2016-05-27 00:29:42 +02:00
|
|
|
acl = "private"
|
2017-02-03 17:40:33 +01:00
|
|
|
}`, rInt, rInt, rInt)
|
2016-05-27 00:29:42 +02:00
|
|
|
}
|
2016-08-16 20:41:12 +02:00
|
|
|
|
|
|
|
func awsElasticTranscoderNotifications(r int) string {
|
|
|
|
return fmt.Sprintf(`
|
|
|
|
resource "aws_elastictranscoder_pipeline" "bar" {
|
|
|
|
input_bucket = "${aws_s3_bucket.test_bucket.bucket}"
|
|
|
|
output_bucket = "${aws_s3_bucket.test_bucket.bucket}"
|
|
|
|
name = "tf-transcoder-%d"
|
|
|
|
role = "${aws_iam_role.test_role.arn}"
|
|
|
|
|
|
|
|
notifications {
|
|
|
|
completed = "${aws_sns_topic.topic_example.arn}"
|
|
|
|
warning = "${aws_sns_topic.topic_example.arn}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_iam_role" "test_role" {
|
|
|
|
name = "tf-transcoder-%d"
|
|
|
|
|
|
|
|
assume_role_policy = <<EOF
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Action": "sts:AssumeRole",
|
|
|
|
"Principal": {
|
|
|
|
"Service": "ec2.amazonaws.com"
|
|
|
|
},
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Sid": ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "test_bucket" {
|
|
|
|
bucket = "tf-transcoder-%d"
|
|
|
|
acl = "private"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_sns_topic" "topic_example" {
|
|
|
|
name = "tf-transcoder-%d"
|
|
|
|
|
|
|
|
policy = <<EOF
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Id": "AWSAccountTopicAccess",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Sid": "*",
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Principal": "*",
|
|
|
|
"Action": "sns:Publish",
|
|
|
|
"Resource": "*"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}`, r, r, r, r)
|
|
|
|
}
|
|
|
|
|
|
|
|
func awsElasticTranscoderNotifications_update(r int) string {
|
|
|
|
return fmt.Sprintf(`
|
|
|
|
resource "aws_elastictranscoder_pipeline" "bar" {
|
|
|
|
input_bucket = "${aws_s3_bucket.test_bucket.bucket}"
|
|
|
|
output_bucket = "${aws_s3_bucket.test_bucket.bucket}"
|
|
|
|
name = "tf-transcoder-%d"
|
|
|
|
role = "${aws_iam_role.test_role.arn}"
|
|
|
|
|
|
|
|
notifications {
|
|
|
|
completed = "${aws_sns_topic.topic_example.arn}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_iam_role" "test_role" {
|
|
|
|
name = "tf-transcoder-%d"
|
|
|
|
|
|
|
|
assume_role_policy = <<EOF
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Action": "sts:AssumeRole",
|
|
|
|
"Principal": {
|
|
|
|
"Service": "ec2.amazonaws.com"
|
|
|
|
},
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Sid": ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "test_bucket" {
|
|
|
|
bucket = "tf-transcoder-%d"
|
|
|
|
acl = "private"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_sns_topic" "topic_example" {
|
|
|
|
name = "tf-transcoder-%d"
|
|
|
|
|
|
|
|
policy = <<EOF
|
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Id": "AWSAccountTopicAccess",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Sid": "*",
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Principal": "*",
|
|
|
|
"Action": "sns:Publish",
|
|
|
|
"Resource": "*"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}`, r, r, r, r)
|
|
|
|
}
|