Skip to content
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

EMR awssdkv2 migration #38233

Merged
merged 101 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
06fe8ec
emr: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
056c2e3
make gen
mattburgess Jul 2, 2024
2d86a7f
r/emr_block_public_access_configuration: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
54557c8
r/emr_cluster: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
b8398fa
r/emr_instance_fleet: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
0ff7b27
r/emr_instance_group: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
9e508a8
r/emr_managed_scaling_policy: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
5893523
d/emr_release_labels: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
5b3679d
r/emr_security_configuration: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
6f06992
r/emr_studio: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
5bd6c48
r/emr_studio_session_mapping: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
23cad66
emr sweepers: Migrate to AWS SDK v2
mattburgess Jul 2, 2024
5f33b93
Merge branch 'main' into HEAD
ewbankkit Aug 22, 2024
037204d
r/aws_emr_instance_group: Tidy up.
ewbankkit Aug 23, 2024
de118d5
r/aws_emr_instance_fleet: Tidy up.
ewbankkit Aug 23, 2024
4ec8b46
r/aws_emr_managed_scaling_policy: Tidy up.
ewbankkit Aug 23, 2024
271a0ff
r/aws_emr_cluster: Tidy up.
ewbankkit Aug 24, 2024
5682bcf
emr: Reduce error code constant visibility.
ewbankkit Aug 24, 2024
65d7a3c
r/aws_emr_studio_session_mapping: Tidy up.
ewbankkit Aug 24, 2024
5a06934
Fix golangci-lint 'unparam'.
ewbankkit Aug 24, 2024
4f2e5de
Merge branch 'main' into HEAD
ewbankkit Aug 24, 2024
dc5e24b
go get github.com/aws/aws-sdk-go-v2/config.
ewbankkit Aug 24, 2024
e44d152
go get github.com/aws/aws-sdk-go-v2/feature/s3/manager.
ewbankkit Aug 24, 2024
92b5ecd
go get github.com/aws/aws-sdk-go-v2/service/accessanalyzer.
ewbankkit Aug 24, 2024
95e1994
go get github.com/aws/aws-sdk-go-v2/service/acm.
ewbankkit Aug 24, 2024
1600bac
go get github.com/aws/aws-sdk-go-v2/service/acmpca.
ewbankkit Aug 24, 2024
8f4238c
go get github.com/aws/aws-sdk-go-v2/service/apigateway.
ewbankkit Aug 24, 2024
81f7bb2
go get github.com/aws/aws-sdk-go-v2/service/apigatewayv2.
ewbankkit Aug 24, 2024
c4f721a
go get github.com/aws/aws-sdk-go-v2/service/appconfig.
ewbankkit Aug 24, 2024
6e9d286
go get github.com/aws/aws-sdk-go-v2/service/applicationautoscaling.
ewbankkit Aug 24, 2024
b9f68f2
go get github.com/aws/aws-sdk-go-v2/service/autoscaling.
ewbankkit Aug 24, 2024
f5eea68
go get github.com/aws/aws-sdk-go-v2/service/batch.
ewbankkit Aug 24, 2024
dd9493c
go get github.com/aws/aws-sdk-go-v2/service/bedrock.
ewbankkit Aug 24, 2024
ae34112
go get github.com/aws/aws-sdk-go-v2/service/bedrockagent.
ewbankkit Aug 24, 2024
cff7670
go get github.com/aws/aws-sdk-go-v2/service/cloudcontrol.
ewbankkit Aug 24, 2024
dec9daa
go get github.com/aws/aws-sdk-go-v2/service/cloudformation.
ewbankkit Aug 24, 2024
9910adf
go get github.com/aws/aws-sdk-go-v2/service/cloudtrail.
ewbankkit Aug 24, 2024
ab18db5
go get github.com/aws/aws-sdk-go-v2/service/cloudwatch.
ewbankkit Aug 24, 2024
3a325c6
go get github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs.
ewbankkit Aug 24, 2024
7730cd9
go get github.com/aws/aws-sdk-go-v2/service/codebuild.
ewbankkit Aug 24, 2024
422660e
go get github.com/aws/aws-sdk-go-v2/service/codedeploy.
ewbankkit Aug 24, 2024
11cec4c
go get github.com/aws/aws-sdk-go-v2/service/configservice.
ewbankkit Aug 24, 2024
2f53471
go get github.com/aws/aws-sdk-go-v2/service/databasemigrationservice.
ewbankkit Aug 24, 2024
9e2da79
go get github.com/aws/aws-sdk-go-v2/service/datasync.
ewbankkit Aug 24, 2024
e86a47f
go get github.com/aws/aws-sdk-go-v2/service/datazone.
ewbankkit Aug 24, 2024
0f53733
go get github.com/aws/aws-sdk-go-v2/service/directconnect.
ewbankkit Aug 24, 2024
e6020a5
go get github.com/aws/aws-sdk-go-v2/service/dlm.
ewbankkit Aug 24, 2024
3229d98
go get github.com/aws/aws-sdk-go-v2/service/docdb.
ewbankkit Aug 24, 2024
0042167
go get github.com/aws/aws-sdk-go-v2/service/dynamodb.
ewbankkit Aug 24, 2024
83916ef
go get github.com/aws/aws-sdk-go-v2/service/ecr.
ewbankkit Aug 24, 2024
4cd91d6
go get github.com/aws/aws-sdk-go-v2/service/ecs.
ewbankkit Aug 24, 2024
71bc170
go get github.com/aws/aws-sdk-go-v2/service/eks.
ewbankkit Aug 24, 2024
0852abe
go get github.com/aws/aws-sdk-go-v2/service/elasticache.
ewbankkit Aug 24, 2024
df15174
go get github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing.
ewbankkit Aug 24, 2024
3454424
go get github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2.
ewbankkit Aug 24, 2024
4e7aa45
go get github.com/aws/aws-sdk-go-v2/service/elasticsearchservice.
ewbankkit Aug 24, 2024
5c21050
go get github.com/aws/aws-sdk-go-v2/service/emr.
ewbankkit Aug 24, 2024
6a9b3ff
go get github.com/aws/aws-sdk-go-v2/service/emrcontainers.
ewbankkit Aug 24, 2024
60e124a
go get github.com/aws/aws-sdk-go-v2/service/eventbridge.
ewbankkit Aug 24, 2024
7206734
go get github.com/aws/aws-sdk-go-v2/service/firehose.
ewbankkit Aug 24, 2024
e6459dc
go get github.com/aws/aws-sdk-go-v2/service/inspector2.
ewbankkit Aug 24, 2024
73fb4d3
go get github.com/aws/aws-sdk-go-v2/service/internetmonitor.
ewbankkit Aug 24, 2024
b3308f9
go get github.com/aws/aws-sdk-go-v2/service/kinesis.
ewbankkit Aug 24, 2024
241d8f1
go get github.com/aws/aws-sdk-go-v2/service/kms.
ewbankkit Aug 24, 2024
2854a16
go get github.com/aws/aws-sdk-go-v2/service/lambda.
ewbankkit Aug 24, 2024
dc2de53
go get github.com/aws/aws-sdk-go-v2/service/neptune.
ewbankkit Aug 24, 2024
c1208a1
go get github.com/aws/aws-sdk-go-v2/service/oam.
ewbankkit Aug 24, 2024
0ccdaf1
go get github.com/aws/aws-sdk-go-v2/service/opensearch.
ewbankkit Aug 24, 2024
10ef67b
go get github.com/aws/aws-sdk-go-v2/service/opensearchserverless.
ewbankkit Aug 24, 2024
164dceb
go get github.com/aws/aws-sdk-go-v2/service/organizations.
ewbankkit Aug 24, 2024
3d00ad4
go get github.com/aws/aws-sdk-go-v2/service/qbusiness.
ewbankkit Aug 24, 2024
7056772
go get github.com/aws/aws-sdk-go-v2/service/ram.
ewbankkit Aug 24, 2024
676b287
go get github.com/aws/aws-sdk-go-v2/service/rbin.
ewbankkit Aug 24, 2024
d1c9f6f
go get github.com/aws/aws-sdk-go-v2/service/rds.
ewbankkit Aug 24, 2024
e254878
go get github.com/aws/aws-sdk-go-v2/service/redshift.
ewbankkit Aug 24, 2024
d4e4f0e
go get github.com/aws/aws-sdk-go-v2/service/resourcegroups.
ewbankkit Aug 24, 2024
4411271
go get github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi.
ewbankkit Aug 24, 2024
00426b0
go get github.com/aws/aws-sdk-go-v2/service/route53.
ewbankkit Aug 24, 2024
8a1f2f8
go get github.com/aws/aws-sdk-go-v2/service/route53resolver.
ewbankkit Aug 24, 2024
618e4c7
go get github.com/aws/aws-sdk-go-v2/service/s3control.
ewbankkit Aug 24, 2024
a7bb4d0
go get github.com/aws/aws-sdk-go-v2/service/secretsmanager.
ewbankkit Aug 24, 2024
c4b5874
go get github.com/aws/aws-sdk-go-v2/service/servicediscovery.
ewbankkit Aug 24, 2024
12cc938
go get github.com/aws/aws-sdk-go-v2/service/servicequotas.
ewbankkit Aug 24, 2024
ab6c870
go get github.com/aws/aws-sdk-go-v2/service/sfn.
ewbankkit Aug 24, 2024
3a8b16e
go get github.com/aws/aws-sdk-go-v2/service/sns.
ewbankkit Aug 24, 2024
3acb6d9
go get github.com/aws/aws-sdk-go-v2/service/sqs.
ewbankkit Aug 24, 2024
630da4d
go get github.com/aws/aws-sdk-go-v2/service/ssm.
ewbankkit Aug 24, 2024
a7e9b78
go get github.com/aws/aws-sdk-go-v2/service/swf.
ewbankkit Aug 24, 2024
1783959
go get github.com/aws/aws-sdk-go-v2/service/synthetics.
ewbankkit Aug 24, 2024
7c7ec7a
go get github.com/aws/aws-sdk-go-v2/service/xray.
ewbankkit Aug 24, 2024
8e0a1ec
Run 'make clean-tidy'.
ewbankkit Aug 24, 2024
c3789b2
r/aws_emr_cluster: Tidy up Read.
ewbankkit Aug 25, 2024
4e904ea
r/aws_emr_block_public_access_configuration: Serialize acceptance tests.
ewbankkit Aug 25, 2024
063a458
r/aws_emr_studio: Tidy up.
ewbankkit Aug 25, 2024
3b7467d
r/aws_emr_studio_session_mapping: Tidy up.
ewbankkit Aug 25, 2024
1c8f723
r/aws_emr_managed_scaling_policy: Fixup acceptance tests.
ewbankkit Aug 25, 2024
7624c64
r/aws_emr_instance_group: Fixup acceptance tests.
ewbankkit Aug 25, 2024
01a7aa1
Fix 'TestAccEMRInstanceGroup_sJSON'.
ewbankkit Aug 26, 2024
21a5b87
Simplify 'flattenAutoScalingPolicyDescription'.
ewbankkit Aug 26, 2024
19fe2a6
Fix 'TestAccEMRInstanceGroup_autoScalingPolicy'.
ewbankkit Aug 26, 2024
af58e4f
r/aws_emr_cluster: ListSteps returns steps in reverse order (newest f…
ewbankkit Aug 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 72 additions & 72 deletions go.mod

Large diffs are not rendered by default.

288 changes: 144 additions & 144 deletions go.sum

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions internal/conns/awsclient_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

149 changes: 65 additions & 84 deletions internal/service/emr/block_public_access_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"context"
"log"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/emr"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/emr"
awstypes "github.com/aws/aws-sdk-go-v2/service/emr/types"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/create"
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
"github.com/hashicorp/terraform-provider-aws/names"
)

// @SDKResource("aws_emr_block_public_access_configuration", name="Block Public Access Configuration")
Expand All @@ -41,12 +41,12 @@ func resourceBlockPublicAccessConfiguration() *schema.Resource {
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"min_range": {
"max_range": {
Type: schema.TypeInt,
Required: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.IsPortNumber),
},
"max_range": {
"min_range": {
Type: schema.TypeInt,
Required: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.IsPortNumber),
Expand All @@ -58,80 +58,77 @@ func resourceBlockPublicAccessConfiguration() *schema.Resource {
}
}

const (
ResNameBlockPublicAccessConfiguration = "Block Public Access Configuration"
dummyIDBlockPublicAccessConfiguration = "emr-block-public-access-configuration"
defaultPermittedPublicSecurityGroupRulePort = 22
)

func resourceBlockPublicAccessConfigurationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).EMRClient(ctx)

conn := meta.(*conns.AWSClient).EMRConn(ctx)

blockPublicAccessConfiguration := &emr.BlockPublicAccessConfiguration{}
blockPublicAccessConfiguration := &awstypes.BlockPublicAccessConfiguration{}

blockPublicSecurityGroupRules := d.Get("block_public_security_group_rules")
blockPublicAccessConfiguration.BlockPublicSecurityGroupRules = aws.Bool(blockPublicSecurityGroupRules.(bool))
if v, ok := d.GetOk("permitted_public_security_group_rule_range"); ok {
blockPublicAccessConfiguration.PermittedPublicSecurityGroupRuleRanges = expandPermittedPublicSecurityGroupRuleRanges(v.([]interface{}))
blockPublicAccessConfiguration.PermittedPublicSecurityGroupRuleRanges = expandPortRanges(v.([]interface{}))
}

in := &emr.PutBlockPublicAccessConfigurationInput{
input := &emr.PutBlockPublicAccessConfigurationInput{
BlockPublicAccessConfiguration: blockPublicAccessConfiguration,
}

_, err := conn.PutBlockPublicAccessConfigurationWithContext(ctx, in)
_, err := conn.PutBlockPublicAccessConfiguration(ctx, input)

if err != nil {
return create.AppendDiagError(diags, names.EMR, create.ErrActionCreating, ResNameBlockPublicAccessConfiguration, d.Id(), err)
return sdkdiag.AppendErrorf(diags, "setting EMR Block Public Access Configuration: %s", err)
}
d.SetId(dummyIDBlockPublicAccessConfiguration)

d.SetId("emr-block-public-access-configuration")

return append(diags, resourceBlockPublicAccessConfigurationRead(ctx, d, meta)...)
}

func resourceBlockPublicAccessConfigurationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).EMRClient(ctx)

conn := meta.(*conns.AWSClient).EMRConn(ctx)
bpa, err := findBlockPublicAccessConfiguration(ctx, conn)

out, err := findBlockPublicAccessConfiguration(ctx, conn)
if !d.IsNewResource() && tfresource.NotFound(err) {
log.Printf("[WARN] EMR Block Public Access Configuration (%s) not found, removing from state", d.Id())
d.SetId("")
return diags
}

if err != nil {
return create.AppendDiagError(diags, names.EMR, create.ErrActionReading, ResNameBlockPublicAccessConfiguration, d.Id(), err)
return sdkdiag.AppendErrorf(diags, "reading EMR Block Public Access Configuration (%s): %s", d.Id(), err)
}

d.Set("block_public_security_group_rules", out.BlockPublicAccessConfiguration.BlockPublicSecurityGroupRules)
if err := d.Set("permitted_public_security_group_rule_range", flattenPermittedPublicSecurityGroupRuleRanges(out.BlockPublicAccessConfiguration.PermittedPublicSecurityGroupRuleRanges)); err != nil {
return create.AppendDiagError(diags, names.EMR, create.ErrActionSetting, ResNameBlockPublicAccessConfiguration, d.Id(), err)
d.Set("block_public_security_group_rules", bpa.BlockPublicSecurityGroupRules)
if err := d.Set("permitted_public_security_group_rule_range", flattenPortRanges(bpa.PermittedPublicSecurityGroupRuleRanges)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting permitted_public_security_group_rule_range: %s", err)
}

return diags
}

func resourceBlockPublicAccessConfigurationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).EMRClient(ctx)

conn := meta.(*conns.AWSClient).EMRConn(ctx)

log.Print("[INFO] Restoring EMR Block Public Access Configuration to default settings")

blockPublicAccessConfiguration := findDefaultBlockPublicAccessConfiguration()
in := &emr.PutBlockPublicAccessConfigurationInput{
BlockPublicAccessConfiguration: blockPublicAccessConfiguration,
}
log.Printf("[DEBUG] Deleting EMR Block Public Access Configuration: %s", d.Id())
_, err := conn.PutBlockPublicAccessConfiguration(ctx, &emr.PutBlockPublicAccessConfigurationInput{
BlockPublicAccessConfiguration: defaultBlockPublicAccessConfiguration(),
})

_, err := conn.PutBlockPublicAccessConfigurationWithContext(ctx, in)
if err != nil {
return create.AppendDiagError(diags, names.EMR, create.ErrActionDeleting, ResNameBlockPublicAccessConfiguration, d.Id(), err)
return sdkdiag.AppendErrorf(diags, "resetting EMR Block Public Access Configuration: %s", err)
}

return diags
}

func findBlockPublicAccessConfiguration(ctx context.Context, conn *emr.EMR) (*emr.GetBlockPublicAccessConfigurationOutput, error) {
func findBlockPublicAccessConfiguration(ctx context.Context, conn *emr.Client) (*awstypes.BlockPublicAccessConfiguration, error) {
input := &emr.GetBlockPublicAccessConfigurationInput{}
output, err := conn.GetBlockPublicAccessConfigurationWithContext(ctx, input)
output, err := conn.GetBlockPublicAccessConfiguration(ctx, input)

if err != nil {
return nil, err
}
Expand All @@ -140,89 +137,73 @@ func findBlockPublicAccessConfiguration(ctx context.Context, conn *emr.EMR) (*em
return nil, tfresource.NewEmptyResultError(input)
}

return output, nil
return output.BlockPublicAccessConfiguration, nil
}

func findDefaultBlockPublicAccessConfiguration() *emr.BlockPublicAccessConfiguration {
defaultPort := int64(defaultPermittedPublicSecurityGroupRulePort)
defaultPortPointer := &defaultPort
portRange := &emr.PortRange{MinRange: defaultPortPointer, MaxRange: defaultPortPointer}
permittedPublicSecurityGroupRuleRanges := []*emr.PortRange{portRange}
blockPublicAccessConfiguration := &emr.BlockPublicAccessConfiguration{
BlockPublicSecurityGroupRules: aws.Bool(true),
PermittedPublicSecurityGroupRuleRanges: permittedPublicSecurityGroupRuleRanges,
}
return blockPublicAccessConfiguration
}
func defaultBlockPublicAccessConfiguration() *awstypes.BlockPublicAccessConfiguration {
const port = 22

func flattenPermittedPublicSecurityGroupRuleRange(apiObject *emr.PortRange) map[string]interface{} {
if apiObject == nil {
return nil
return &awstypes.BlockPublicAccessConfiguration{
BlockPublicSecurityGroupRules: aws.Bool(true),
PermittedPublicSecurityGroupRuleRanges: []awstypes.PortRange{{
MinRange: aws.Int32(port),
MaxRange: aws.Int32(port),
}},
}
}

m := map[string]interface{}{}
func flattenPortRange(apiObject *awstypes.PortRange) map[string]interface{} {
tfMap := map[string]interface{}{}

if v := apiObject.MinRange; v != nil {
m["min_range"] = aws.Int64Value(v)
tfMap["min_range"] = aws.ToInt32(v)
}

if v := apiObject.MaxRange; v != nil {
m["max_range"] = aws.Int64Value(v)
tfMap["max_range"] = aws.ToInt32(v)
}

return m
return tfMap
}

func flattenPermittedPublicSecurityGroupRuleRanges(apiObjects []*emr.PortRange) []interface{} {
func flattenPortRanges(apiObjects []awstypes.PortRange) []interface{} {
if len(apiObjects) == 0 {
return nil
}

var l []interface{}
var tfMap []interface{}

for _, apiObject := range apiObjects {
if apiObject == nil {
continue
}

l = append(l, flattenPermittedPublicSecurityGroupRuleRange(apiObject))
tfMap = append(tfMap, flattenPortRange(&apiObject))
}

return l
return tfMap
}

func expandPermittedPublicSecurityGroupRuleRange(tfMap map[string]interface{}) *emr.PortRange {
a := &emr.PortRange{}

a.MinRange = aws.Int64(int64(tfMap["min_range"].(int)))
func expandPortRange(tfMap map[string]interface{}) *awstypes.PortRange {
apiObject := &awstypes.PortRange{}

a.MaxRange = aws.Int64(int64(tfMap["max_range"].(int)))
apiObject.MinRange = aws.Int32(int32(tfMap["min_range"].(int)))
apiObject.MaxRange = aws.Int32(int32(tfMap["max_range"].(int)))

return a
return apiObject
}

func expandPermittedPublicSecurityGroupRuleRanges(tfList []interface{}) []*emr.PortRange {
func expandPortRanges(tfList []interface{}) []awstypes.PortRange {
if len(tfList) == 0 {
return nil
}

var s []*emr.PortRange

for _, r := range tfList {
m, ok := r.(map[string]interface{})
var apiObjects []awstypes.PortRange

for _, tfMapRaw := range tfList {
tfMap, ok := tfMapRaw.(map[string]interface{})
if !ok {
continue
}

a := expandPermittedPublicSecurityGroupRuleRange(m)

if a == nil {
continue
}

s = append(s, a)
apiObjects = append(apiObjects, *expandPortRange(tfMap))
}

return s
return apiObjects
}
Loading
Loading