-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[BREAKING] 💥 remove compute environments from job queue #40751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
YakDriver
merged 14 commits into
hashicorp:release/6.0.0-beta
from
danquack:39568/migrate-compute-environment
Apr 29, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6bd0f91
:boom: remove compute environments from job queue
danquack 3dad91f
:memo: changelog
danquack bf8c04d
:wastebasket: remove dead code
danquack 0389eec
Fix merge conflicts
YakDriver ab1de2a
Fix places still using compute_environment_name
YakDriver 3247dcc
Add guidance to v6 upgrade guide
YakDriver c896f75
Add missing StateUpgrader for ce
YakDriver bdfb0dc
Move acctest to acctests
YakDriver 4161be6
Add copyright
YakDriver d651ca7
Fix constants
YakDriver 5760b0b
gofmt
YakDriver 7d33e91
The what?
YakDriver fb54d66
Update internal/service/batch/compute_environment_test.go
YakDriver 165deaa
Testing improvements
YakDriver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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:breaking-change | ||
resource/aws_batch_job_queue: Remove deprecated parameter `compute_environments` in place of `compute_environment_order` | ||
``` |
This file contains hidden or 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 hidden or 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 hidden or 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,247 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package batch | ||
|
||
import ( | ||
"context" | ||
|
||
awstypes "github.com/aws/aws-sdk-go-v2/service/batch/types" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-provider-aws/internal/sdkv2" | ||
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" | ||
"github.com/hashicorp/terraform-provider-aws/names" | ||
) | ||
|
||
func computeEnvironmentSchemaV0() *schema.Resource { | ||
return &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
names.AttrARN: { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"compute_environment_name": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, | ||
ConflictsWith: []string{"compute_environment_name_prefix"}, | ||
}, | ||
"compute_environment_name_prefix": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, | ||
ConflictsWith: []string{"compute_environment_name"}, | ||
}, | ||
"compute_resources": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
ForceNew: true, | ||
MinItems: 0, | ||
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"allocation_strategy": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
StateFunc: sdkv2.ToUpperSchemaStateFunc, | ||
}, | ||
"bid_percentage": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
}, | ||
"desired_vcpus": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Computed: true, | ||
}, | ||
"ec2_configuration": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, | ||
MaxItems: 2, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"image_id_override": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
}, | ||
"image_type": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"ec2_key_pair": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"image_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"instance_role": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
names.AttrInstanceType: { | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
names.AttrLaunchTemplate: { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
ForceNew: true, | ||
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"launch_template_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ConflictsWith: []string{"compute_resources.0.launch_template.0.launch_template_name"}, | ||
}, | ||
"launch_template_name": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ConflictsWith: []string{"compute_resources.0.launch_template.0.launch_template_id"}, | ||
}, | ||
names.AttrVersion: { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"max_vcpus": { | ||
Type: schema.TypeInt, | ||
Required: true, | ||
}, | ||
"min_vcpus": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
}, | ||
"placement_group": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
}, | ||
names.AttrSecurityGroupIDs: { | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
"spot_iam_fleet_role": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
}, | ||
names.AttrSubnets: { | ||
Type: schema.TypeSet, | ||
Required: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
names.AttrTags: tftags.TagsSchema(), | ||
names.AttrType: { | ||
Type: schema.TypeString, | ||
Required: true, | ||
StateFunc: sdkv2.ToUpperSchemaStateFunc, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"ecs_cluster_arn": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"eks_configuration": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
ForceNew: true, | ||
MinItems: 0, | ||
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"eks_cluster_arn": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
"kubernetes_namespace": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
names.AttrServiceRole: { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
}, | ||
names.AttrState: { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: awstypes.CEStateEnabled, | ||
StateFunc: sdkv2.ToUpperSchemaStateFunc, | ||
}, | ||
names.AttrStatus: { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
names.AttrStatusReason: { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
names.AttrTags: tftags.TagsSchema(), | ||
names.AttrTagsAll: tftags.TagsSchemaComputed(), | ||
names.AttrType: { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
StateFunc: sdkv2.ToUpperSchemaStateFunc, | ||
}, | ||
"update_policy": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"job_execution_timeout_minutes": { | ||
Type: schema.TypeInt, | ||
Required: true, | ||
}, | ||
"terminate_jobs_on_update": { | ||
Type: schema.TypeBool, | ||
Required: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func computeEnvironmentStateUpgradeV0(_ context.Context, rawState map[string]any, meta any) (map[string]any, error) { | ||
if rawState == nil { | ||
rawState = map[string]any{} | ||
} | ||
|
||
if v, ok := rawState["compute_environment_name"].(string); ok && v != "" { | ||
rawState[names.AttrName] = v | ||
delete(rawState, "compute_environment_name") | ||
} | ||
|
||
if v, ok := rawState["compute_environment_name_prefix"].(string); ok && v != "" { | ||
rawState[names.AttrNamePrefix] = v | ||
delete(rawState, "compute_environment_name_prefix") | ||
} | ||
|
||
return rawState, nil | ||
} |
94 changes: 94 additions & 0 deletions
94
internal/service/batch/compute_environment_migrate_test.go
This file contains hidden or 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,94 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package batch_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
tfbatch "github.com/hashicorp/terraform-provider-aws/internal/service/batch" | ||
"github.com/hashicorp/terraform-provider-aws/names" | ||
) | ||
|
||
func TestComputeEnvironmentStateUpgradeV0(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
rawState map[string]any | ||
expected map[string]any | ||
}{ | ||
{ | ||
name: "empty rawState", | ||
rawState: nil, | ||
expected: map[string]any{}, | ||
}, | ||
{ | ||
name: "only compute_environment_name", | ||
rawState: map[string]any{ | ||
"compute_environment_name": "test-environment", | ||
}, | ||
expected: map[string]any{ | ||
names.AttrName: "test-environment", | ||
}, | ||
}, | ||
{ | ||
name: "only compute_environment_name_prefix", | ||
rawState: map[string]any{ | ||
"compute_environment_name_prefix": "test-prefix", | ||
}, | ||
expected: map[string]any{ | ||
names.AttrNamePrefix: "test-prefix", | ||
}, | ||
}, | ||
{ | ||
name: "both compute_environment_name and compute_environment_name_prefix", | ||
rawState: map[string]any{ | ||
"compute_environment_name": "test-environment", | ||
"compute_environment_name_prefix": "test-prefix", | ||
}, | ||
expected: map[string]any{ | ||
names.AttrName: "test-environment", | ||
names.AttrNamePrefix: "test-prefix", | ||
}, | ||
}, | ||
{ | ||
name: "unrelated keys in rawState", | ||
rawState: map[string]any{ | ||
"compute_environment_name": "test-environment", | ||
"compute_environment_name_prefix": "test-prefix", | ||
"other_key": "other-value", | ||
}, | ||
expected: map[string]any{ | ||
names.AttrName: "test-environment", | ||
names.AttrNamePrefix: "test-prefix", | ||
"other_key": "other-value", | ||
}, | ||
}, | ||
{ | ||
name: "no compute_environment_name or compute_environment_name_prefix", | ||
rawState: map[string]any{ | ||
"other_key": "other-value", | ||
}, | ||
expected: map[string]any{ | ||
"other_key": "other-value", | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
result, err := tfbatch.ComputeEnvironmentStateUpgradeV0(context.Background(), tt.rawState, nil) | ||
if err != nil { | ||
t.Fatalf("unexpected error: %v", err) | ||
} | ||
if diff := cmp.Diff(tt.expected, result); diff != "" { | ||
t.Errorf("unexpected result (-want +got):\n%s", diff) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.