Skip to content

Commit

Permalink
Merge pull request #41012 from acwwat/f-aws_media_convert_queue-add_c…
Browse files Browse the repository at this point in the history
…oncurrent_jobs_arg

feat: Add concurrent_jobs arg for aws_media_convert_queue
  • Loading branch information
ewbankkit authored Jan 23, 2025
2 parents f9f9043 + 357e6b8 commit 169b319
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/41012.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_media_convert_queue: Add `concurrent_jobs` argument
```
14 changes: 14 additions & 0 deletions internal/service/mediaconvert/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func resourceQueue() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"concurrent_jobs": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
names.AttrDescription: {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -107,6 +112,10 @@ func resourceQueueCreate(ctx context.Context, d *schema.ResourceData, meta inter
Tags: getTagsIn(ctx),
}

if v, ok := d.GetOk("concurrent_jobs"); ok {
input.ConcurrentJobs = aws.Int32(int32(v.(int)))
}

if v, ok := d.GetOk(names.AttrDescription); ok {
input.Description = aws.String(v.(string))
}
Expand Down Expand Up @@ -143,6 +152,7 @@ func resourceQueueRead(ctx context.Context, d *schema.ResourceData, meta interfa
}

d.Set(names.AttrARN, queue.Arn)
d.Set("concurrent_jobs", queue.ConcurrentJobs)
d.Set(names.AttrDescription, queue.Description)
d.Set(names.AttrName, queue.Name)
d.Set("pricing_plan", queue.PricingPlan)
Expand All @@ -168,6 +178,10 @@ func resourceQueueUpdate(ctx context.Context, d *schema.ResourceData, meta inter
Status: types.QueueStatus(d.Get(names.AttrStatus).(string)),
}

if v, ok := d.GetOk("concurrent_jobs"); ok {
input.ConcurrentJobs = aws.Int32(int32(v.(int)))
}

if v, ok := d.GetOk(names.AttrDescription); ok {
input.Description = aws.String(v.(string))
}
Expand Down
40 changes: 40 additions & 0 deletions internal/service/mediaconvert/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestAccMediaConvertQueue_basic(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckQueueExists(ctx, resourceName, &queue),
acctest.MatchResourceAttrRegionalARN(ctx, resourceName, names.AttrARN, "mediaconvert", regexache.MustCompile(`queues/.+`)),
resource.TestCheckResourceAttrSet(resourceName, "concurrent_jobs"),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rName),
resource.TestCheckResourceAttr(resourceName, "pricing_plan", string(types.PricingPlanOnDemand)),
resource.TestCheckResourceAttr(resourceName, "reservation_plan_settings.#", "0"),
Expand Down Expand Up @@ -234,6 +235,36 @@ func TestAccMediaConvertQueue_withDescription(t *testing.T) {
})
}

func TestAccMediaConvertQueue_withConcurrentJobs(t *testing.T) {
ctx := acctest.Context(t)
var queue types.Queue
resourceName := "aws_media_convert_queue.test"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.MediaConvertServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckQueueDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccQueueConfig_concurrentJobs(rName, 100),
Check: resource.ComposeTestCheckFunc(
testAccCheckQueueExists(ctx, resourceName, &queue),
resource.TestCheckResourceAttr(resourceName, "concurrent_jobs", "100"),
),
},
{
Config: testAccQueueConfig_concurrentJobs(rName, 5),
Check: resource.ComposeTestCheckFunc(
testAccCheckQueueExists(ctx, resourceName, &queue),
resource.TestCheckResourceAttr(resourceName, "concurrent_jobs", "5"),
),
},
},
})
}

func testAccCheckQueueDestroy(ctx context.Context) resource.TestCheckFunc {
return func(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
Expand Down Expand Up @@ -307,6 +338,15 @@ resource "aws_media_convert_queue" "test" {
`, rName, description)
}

func testAccQueueConfig_concurrentJobs(rName string, concurrentJobs int) string {
return fmt.Sprintf(`
resource "aws_media_convert_queue" "test" {
name = %[1]q
concurrent_jobs = %[2]d
}
`, rName, concurrentJobs)
}

func testAccQueueConfig_tags1(rName, tagKey1, tagValue1 string) string {
return fmt.Sprintf(`
resource "aws_media_convert_queue" "test" {
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/media_convert_queue.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ resource "aws_media_convert_queue" "test" {
This resource supports the following arguments:

* `name` - (Required) A unique identifier describing the queue
* `concurrent_jobs` - (Optional) The maximum number of jobs your queue can process concurrently. For on-demand queues, the value you enter is constrained by your service quotas for Maximum concurrent jobs, per on-demand queue and Maximum concurrent jobs, per account. For reserved queues, specify the number of jobs you can process concurrently in your reservation plan instead.
* `description` - (Optional) A description of the queue
* `pricing_plan` - (Optional) Specifies whether the pricing plan for the queue is on-demand or reserved. Valid values are `ON_DEMAND` or `RESERVED`. Default to `ON_DEMAND`.
* `reservation_plan_settings` - (Optional) A detail pricing plan of the reserved queue. See below.
Expand Down

0 comments on commit 169b319

Please sign in to comment.