Skip to content

Commit

Permalink
Merge pull request #6388 from mbamber/f-aws-elastic-transcoder-imports
Browse files Browse the repository at this point in the history
Elastic Transcoder imports
  • Loading branch information
bflad authored Nov 12, 2018
2 parents 36a3598 + 2e49b7d commit 0767b04
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
3 changes: 3 additions & 0 deletions aws/resource_aws_elastic_transcoder_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func resourceAwsElasticTranscoderPipeline() *schema.Resource {
Read: resourceAwsElasticTranscoderPipelineRead,
Update: resourceAwsElasticTranscoderPipelineUpdate,
Delete: resourceAwsElasticTranscoderPipelineDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"arn": {
Expand Down
29 changes: 25 additions & 4 deletions aws/resource_aws_elastic_transcoder_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestAccAWSElasticTranscoderPipeline_basic(t *testing.T) {
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
Steps: []resource.TestStep{
{
Config: awsElasticTranscoderPipelineConfigBasic,
Config: fmt.Sprintf(awsElasticTranscoderPipelineConfigBasic, "basic"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", pipeline),
),
Expand Down Expand Up @@ -229,16 +229,37 @@ func testAccCheckElasticTranscoderPipelineDestroy(s *terraform.State) error {
return nil
}

func TestAccAWSElasticTranscoderPipeline_import(t *testing.T) {
resourceName := "aws_elastictranscoder_pipeline.bar"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(awsElasticTranscoderPipelineConfigBasic, "import"),
},

{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

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_"
name = "aws_ets_pipeline_tf_test_%[1]s"
role = "${aws_iam_role.test_role.arn}"
}
resource "aws_iam_role" "test_role" {
name = "aws_elastictranscoder_pipeline_tf_test_role_"
name = "aws_elastictranscoder_pipeline_tf_test_role_%[1]s"
assume_role_policy = <<EOF
{
Expand All @@ -258,7 +279,7 @@ EOF
}
resource "aws_s3_bucket" "test_bucket" {
bucket = "aws-elasticencoder-pipeline-tf-test-bucket"
bucket = "aws-elasticencoder-pipeline-tf-test-bucket-%[1]s"
acl = "private"
}
`
Expand Down
4 changes: 4 additions & 0 deletions aws/resource_aws_elastic_transcoder_preset.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func resourceAwsElasticTranscoderPreset() *schema.Resource {
Create: resourceAwsElasticTranscoderPresetCreate,
Read: resourceAwsElasticTranscoderPresetRead,
Delete: resourceAwsElasticTranscoderPresetDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"arn": {
Expand Down Expand Up @@ -500,6 +503,7 @@ func resourceAwsElasticTranscoderPresetRead(d *schema.ResourceData, meta interfa

d.Set("container", *preset.Container)
d.Set("name", *preset.Name)
d.Set("description", *preset.Description)

if preset.Thumbnails != nil {
err := d.Set("thumbnails", flattenETThumbnails(preset.Thumbnails))
Expand Down
21 changes: 21 additions & 0 deletions aws/resource_aws_elastic_transcoder_preset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ import (
"github.com/hashicorp/terraform/terraform"
)

func TestAccAWSElasticTranscoderPreset_import(t *testing.T) {
resourceName := "aws_elastictranscoder_preset.bar"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckElasticTranscoderPresetDestroy,
Steps: []resource.TestStep{
{
Config: awsElasticTranscoderPresetConfig,
},

{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSElasticTranscoderPreset_basic(t *testing.T) {
preset := &elastictranscoder.Preset{}
name := "aws_elastictranscoder_preset.bar"
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/elastic_transcoder_pipeline.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ The `thumbnail_config_permissions` object supports the following:
* `access` - The permission that you want to give to the AWS user that you specified in `thumbnail_config_permissions.grantee`.
* `grantee` - The AWS user or group that you want to have access to thumbnail files.
* `grantee_type` - Specify the type of value that appears in the `thumbnail_config_permissions.grantee` object.

## Import

Elastic Transcoder pipelines can be imported using the `id`, e.g.

```
$ terraform import aws_elastic_transcoder_pipeline.basic_pipeline 1407981661351-cttk8b
```
8 changes: 8 additions & 0 deletions website/docs/r/elastic_transcoder_preset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,11 @@ The `video_codec_options` map supports the following:
* `ColorSpaceConversion` - The color space conversion Elastic Transcoder applies to the output video. Valid values are `None`, `Bt709toBt601`, `Bt601toBt709`, and `Auto`. (Optional, H.264/MPEG2 Only)
* `ChromaSubsampling` - The sampling pattern for the chroma (color) channels of the output video. Valid values are `yuv420p` and `yuv422p`.
* `LoopCount` - The number of times you want the output gif to loop (Gif only)

## Import

Elastic Transcoder presets can be imported using the `id`, e.g.

```
$ terraform import aws_elastic_transcoder_preset.basic_preset 1407981661351-cttk8b
```

0 comments on commit 0767b04

Please sign in to comment.