-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35149 from drewmullen/f-batch_job_definition-RM_F…
…orceNew batch job definition remove force new and increment revisions
- Loading branch information
Showing
6 changed files
with
513 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
resource/aws_batch_job_definition: Add update functions instead of ForceNew. Add `deregister_on_new_revision` to allow keeping prior versions ACTIVE when a new revision is published. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package batch | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/batch" | ||
"github.com/aws/aws-sdk-go-v2/service/batch/types" | ||
"github.com/hashicorp/terraform-provider-aws/internal/tfresource" | ||
) | ||
|
||
func FindJobDefinitionV2ByARN(ctx context.Context, conn *batch.Client, arn string) (*types.JobDefinition, error) { | ||
input := &batch.DescribeJobDefinitionsInput{ | ||
JobDefinitions: []string{arn}, | ||
} | ||
|
||
out, err := conn.DescribeJobDefinitions(ctx, input) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if out == nil || len(out.JobDefinitions) == 0 { | ||
return nil, tfresource.NewEmptyResultError(input) | ||
} | ||
|
||
if count := len(out.JobDefinitions); count > 1 { | ||
return nil, tfresource.NewTooManyResultsError(count, input) | ||
} | ||
|
||
return &out.JobDefinitions[0], nil | ||
} | ||
|
||
func ListJobDefinitionsV2ByNameWithStatus(ctx context.Context, conn *batch.Client, input *batch.DescribeJobDefinitionsInput) ([]types.JobDefinition, error) { | ||
var out []types.JobDefinition | ||
|
||
pages := batch.NewDescribeJobDefinitionsPaginator(conn, input) | ||
for pages.HasMorePages() { | ||
page, err := pages.NextPage(ctx) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
out = append(out, page.JobDefinitions...) | ||
} | ||
|
||
if len(out) == 0 { | ||
return nil, tfresource.NewEmptyResultError(input) | ||
} | ||
|
||
return out, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.