provider/aws: Update ElasticTranscoder to allow empty notifications, removing notifications, etc (#8207)
* provider/aws: Add failing ETC + notifications test * tidy up the docs some * provider/aws: Update ElasticTranscoder to allow empty notifications, removing notifications, etc
This commit is contained in:
parent
601c757f90
commit
72a81ff3ae
|
@ -233,18 +233,23 @@ func expandETNotifications(d *schema.ResourceData) *elastictranscoder.Notificati
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
s := set.(*schema.Set)
|
s := set.(*schema.Set).List()
|
||||||
if s == nil || s.Len() == 0 {
|
if s == nil || len(s) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
m := s.List()[0].(map[string]interface{})
|
if s[0] == nil {
|
||||||
|
log.Printf("[ERR] First element of Notifications set is nil")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
rN := s[0].(map[string]interface{})
|
||||||
|
|
||||||
return &elastictranscoder.Notifications{
|
return &elastictranscoder.Notifications{
|
||||||
Completed: getStringPtr(m, "completed"),
|
Completed: aws.String(rN["completed"].(string)),
|
||||||
Error: getStringPtr(m, "error"),
|
Error: aws.String(rN["error"].(string)),
|
||||||
Progressing: getStringPtr(m, "progressing"),
|
Progressing: aws.String(rN["progressing"].(string)),
|
||||||
Warning: getStringPtr(m, "warning"),
|
Warning: aws.String(rN["warning"].(string)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,14 @@ package aws
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/elastictranscoder"
|
"github.com/aws/aws-sdk-go/service/elastictranscoder"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -30,6 +33,71 @@ func TestAccAWSElasticTranscoderPipeline_basic(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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{
|
||||||
|
resource.TestStep{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAccAWSElasticTranscoderPipeline_withContentConfig(t *testing.T) {
|
func TestAccAWSElasticTranscoderPipeline_withContentConfig(t *testing.T) {
|
||||||
pipeline := &elastictranscoder.Pipeline{}
|
pipeline := &elastictranscoder.Pipeline{}
|
||||||
|
|
||||||
|
@ -326,3 +394,122 @@ resource "aws_s3_bucket" "content_bucket" {
|
||||||
acl = "private"
|
acl = "private"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
|
@ -66,20 +66,21 @@ The `content_config_permissions` object supports the following:
|
||||||
|
|
||||||
|
|
||||||
The `notifications` object supports the following:
|
The `notifications` object supports the following:
|
||||||
|
|
||||||
* `completed` - The topic ARN for the Amazon SNS topic that you want to notify when Elastic Transcoder has finished processing a job in this pipeline.
|
* `completed` - The topic ARN for the Amazon SNS topic that you want to notify when Elastic Transcoder has finished processing a job in this pipeline.
|
||||||
* `error` - The topic ARN for the Amazon SNS topic that you want to notify when Elastic Transcoder encounters an error condition while processing a job in this pipeline.
|
* `error` - The topic ARN for the Amazon SNS topic that you want to notify when Elastic Transcoder encounters an error condition while processing a job in this pipeline.
|
||||||
* `progressing` - The topic ARN for the Amazon Simple Notification Service (Amazon SNS) topic that you want to notify when Elastic Transcoder has started to process a job in this pipeline.
|
* `progressing` - The topic ARN for the Amazon Simple Notification Service (Amazon SNS) topic that you want to notify when Elastic Transcoder has started to process a job in this pipeline.
|
||||||
* `warning` - The topic ARN for the Amazon SNS topic that you want to notify when Elastic Transcoder encounters a warning condition while processing a job in this pipeline.
|
* `warning` - The topic ARN for the Amazon SNS topic that you want to notify when Elastic Transcoder encounters a warning condition while processing a job in this pipeline.
|
||||||
|
|
||||||
The thumbnail_config object specifies information about the Amazon S3 bucket in
|
The `thumbnail_config` object specifies information about the Amazon S3 bucket in
|
||||||
which you want Elastic Transcoder to save thumbnail files: which bucket to use,
|
which you want Elastic Transcoder to save thumbnail files: which bucket to use,
|
||||||
which users you want to have access to the files, the type of access you want
|
which users you want to have access to the files, the type of access you want
|
||||||
users to have, and the storage class that you want to assign to the files. If
|
users to have, and the storage class that you want to assign to the files. If
|
||||||
you specify values for ContentConfig, you must also specify values for
|
you specify values for `content_config`, you must also specify values for
|
||||||
ThumbnailConfig even if you don't want to create thumbnails. (You control
|
`thumbnail_config` even if you don't want to create thumbnails. (You control
|
||||||
whether to create thumbnails when you create a job. For more information, see
|
whether to create thumbnails when you create a job. For more information, see
|
||||||
ThumbnailPattern in the topic Create Job.) If you specify values for
|
ThumbnailPattern in the topic Create Job.) If you specify values for
|
||||||
ContentConfig and ThumbnailConfig, omit the OutputBucket object.
|
`content_config` and `thumbnail_config`, omit the OutputBucket object.
|
||||||
|
|
||||||
The `thumbnail_config` object supports the following:
|
The `thumbnail_config` object supports the following:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue