Skip to content

Commit

Permalink
Merge branch 'main' into td-docdb_v2_migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonaj committed Jun 7, 2024
2 parents ab64f95 + ea7ba2b commit da9258f
Show file tree
Hide file tree
Showing 36 changed files with 788 additions and 727 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.55.0
github.com/aws/aws-sdk-go-v2/service/s3control v1.44.12
github.com/aws/aws-sdk-go-v2/service/scheduler v1.8.9
github.com/aws/aws-sdk-go-v2/service/schemas v1.24.9
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.29.2
github.com/aws/aws-sdk-go-v2/service/securityhub v1.49.1
github.com/aws/aws-sdk-go-v2/service/securitylake v1.13.8
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ github.com/aws/aws-sdk-go-v2/service/s3control v1.44.12 h1:6F6JIv06AIJR7p+w9xjVY
github.com/aws/aws-sdk-go-v2/service/s3control v1.44.12/go.mod h1:vWJVDhTPJgkpHRjz/MMMVvqoAupZ1W9emLj5cfnkPzs=
github.com/aws/aws-sdk-go-v2/service/scheduler v1.8.9 h1:NH6WgOHc0dQlnKWUqVxHsfNC/ZVce94GSSMLBYBb5Rg=
github.com/aws/aws-sdk-go-v2/service/scheduler v1.8.9/go.mod h1:VHoM5NP6kQnC4az6zU5ES8quC+ze1RGyvLtPbRk23TI=
github.com/aws/aws-sdk-go-v2/service/schemas v1.24.9 h1:VbwQv2AcQib1nfsO4AE94fFSFjQ0+r8urRtph9QbSAs=
github.com/aws/aws-sdk-go-v2/service/schemas v1.24.9/go.mod h1:TKliQctpyxkDZLpLcSB/xwQTZ1FAlFh/iu7QdcQosHk=
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.29.2 h1:vnONgeMo5TuAtGjVNjieDyaI6tzMDNm0TuBgkKzqkX4=
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.29.2/go.mod h1:OR529kEc7Ty9nsqvMuDBBHq5AZVih/MYd5/G9TcL5bQ=
github.com/aws/aws-sdk-go-v2/service/securityhub v1.49.1 h1:Cvdok+6nG7oFCdi34QTfdy6OgFuNwOzR6sbqmTT3Kpg=
Expand Down
6 changes: 3 additions & 3 deletions internal/conns/awsclient_gen.go

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

29 changes: 27 additions & 2 deletions internal/service/devicefarm/device_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
awstypes "github.com/aws/aws-sdk-go-v2/service/devicefarm/types"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"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"
Expand All @@ -28,7 +29,7 @@ import (

// @SDKResource("aws_devicefarm_device_pool", name="Device Pool")
// @Tags(identifierAttribute="arn")
func ResourceDevicePool() *schema.Resource {
func resourceDevicePool() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceDevicePoolCreate,
ReadWithoutTimeout: resourceDevicePoolRead,
Expand Down Expand Up @@ -134,7 +135,7 @@ func resourceDevicePoolRead(ctx context.Context, d *schema.ResourceData, meta in
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).DeviceFarmClient(ctx)

devicePool, err := FindDevicePoolByARN(ctx, conn, d.Id())
devicePool, err := findDevicePoolByARN(ctx, conn, d.Id())

if !d.IsNewResource() && tfresource.NotFound(err) {
log.Printf("[WARN] DeviceFarm Device Pool (%s) not found, removing from state", d.Id())
Expand Down Expand Up @@ -225,6 +226,30 @@ func resourceDevicePoolDelete(ctx context.Context, d *schema.ResourceData, meta
return diags
}

func findDevicePoolByARN(ctx context.Context, conn *devicefarm.Client, arn string) (*awstypes.DevicePool, error) {
input := &devicefarm.GetDevicePoolInput{
Arn: aws.String(arn),
}
output, err := conn.GetDevicePool(ctx, input)

if errs.IsA[*awstypes.NotFoundException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: input,
}
}

if err != nil {
return nil, err
}

if output == nil || output.DevicePool == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return output.DevicePool, nil
}

func expandDevicePoolRules(s *schema.Set) []awstypes.Rule {
rules := make([]awstypes.Rule, 0)

Expand Down
21 changes: 21 additions & 0 deletions internal/service/devicefarm/exports_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package devicefarm

// Exports for use in tests only.
var (
ResourceDevicePool = resourceDevicePool
ResourceInstanceProfile = resourceInstanceProfile
ResourceNetworkProfile = resourceNetworkProfile
ResourceProject = resourceProject
ResourceTestGridProject = resourceTestGridProject
ResourceUpload = resourceUpload

FindDevicePoolByARN = findDevicePoolByARN
FindInstanceProfileByARN = findInstanceProfileByARN
FindNetworkProfileByARN = findNetworkProfileByARN
FindProjectByARN = findProjectByARN
FindTestGridProjectByARN = findTestGridProjectByARN
FindUploadByARN = findUploadByARN
)
159 changes: 0 additions & 159 deletions internal/service/devicefarm/find.go

This file was deleted.

29 changes: 27 additions & 2 deletions internal/service/devicefarm/instance_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/devicefarm"
awstypes "github.com/aws/aws-sdk-go-v2/service/devicefarm/types"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"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"
Expand All @@ -25,7 +26,7 @@ import (

// @SDKResource("aws_devicefarm_instance_profile", name="Instance Profile")
// @Tags(identifierAttribute="arn")
func ResourceInstanceProfile() *schema.Resource {
func resourceInstanceProfile() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceInstanceProfileCreate,
ReadWithoutTimeout: resourceInstanceProfileRead,
Expand Down Expand Up @@ -116,7 +117,7 @@ func resourceInstanceProfileRead(ctx context.Context, d *schema.ResourceData, me
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).DeviceFarmClient(ctx)

instanceProf, err := FindInstanceProfileByARN(ctx, conn, d.Id())
instanceProf, err := findInstanceProfileByARN(ctx, conn, d.Id())

if !d.IsNewResource() && tfresource.NotFound(err) {
log.Printf("[WARN] DeviceFarm Instance Profile (%s) not found, removing from state", d.Id())
Expand Down Expand Up @@ -197,3 +198,27 @@ func resourceInstanceProfileDelete(ctx context.Context, d *schema.ResourceData,

return diags
}

func findInstanceProfileByARN(ctx context.Context, conn *devicefarm.Client, arn string) (*awstypes.InstanceProfile, error) {
input := &devicefarm.GetInstanceProfileInput{
Arn: aws.String(arn),
}
output, err := conn.GetInstanceProfile(ctx, input)

if errs.IsA[*awstypes.NotFoundException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: input,
}
}

if err != nil {
return nil, err
}

if output == nil || output.InstanceProfile == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return output.InstanceProfile, nil
}
29 changes: 27 additions & 2 deletions internal/service/devicefarm/network_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/devicefarm"
awstypes "github.com/aws/aws-sdk-go-v2/service/devicefarm/types"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"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"
Expand All @@ -25,7 +26,7 @@ import (

// @SDKResource("aws_devicefarm_network_profile", name="Network Profile")
// @Tags(identifierAttribute="arn")
func ResourceNetworkProfile() *schema.Resource {
func resourceNetworkProfile() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceNetworkProfileCreate,
ReadWithoutTimeout: resourceNetworkProfileRead,
Expand Down Expand Up @@ -180,7 +181,7 @@ func resourceNetworkProfileRead(ctx context.Context, d *schema.ResourceData, met
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).DeviceFarmClient(ctx)

project, err := FindNetworkProfileByARN(ctx, conn, d.Id())
project, err := findNetworkProfileByARN(ctx, conn, d.Id())

if !d.IsNewResource() && tfresource.NotFound(err) {
log.Printf("[WARN] DeviceFarm Network Profile (%s) not found, removing from state", d.Id())
Expand Down Expand Up @@ -298,3 +299,27 @@ func resourceNetworkProfileDelete(ctx context.Context, d *schema.ResourceData, m

return diags
}

func findNetworkProfileByARN(ctx context.Context, conn *devicefarm.Client, arn string) (*awstypes.NetworkProfile, error) {
input := &devicefarm.GetNetworkProfileInput{
Arn: aws.String(arn),
}
output, err := conn.GetNetworkProfile(ctx, input)

if errs.IsA[*awstypes.NotFoundException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: input,
}
}

if err != nil {
return nil, err
}

if output == nil || output.NetworkProfile == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return output.NetworkProfile, nil
}
Loading

0 comments on commit da9258f

Please sign in to comment.