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

r/aws_bedrockagent_knowledge_base: Aurora Cluster is publicly accessible in acceptance tests #37109

Merged
merged 10 commits into from
Apr 26, 2024
41 changes: 41 additions & 0 deletions internal/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"log"
"net"
"os"
"os/exec"
"reflect"
"regexp"
"strconv"
Expand Down Expand Up @@ -2418,6 +2419,34 @@ resource "aws_subnet" "test" {
)
}

func ConfigVPCWithSubnetsEnableDNSHostnames(rName string, subnetCount int) string {
return ConfigCompose(
ConfigAvailableAZsNoOptInDefaultExclude(),
fmt.Sprintf(`
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true

tags = {
Name = %[1]q
}
}

resource "aws_subnet" "test" {
count = %[2]d

vpc_id = aws_vpc.test.id
availability_zone = data.aws_availability_zones.available.names[count.index]
cidr_block = cidrsubnet(aws_vpc.test.cidr_block, 8, count.index)

tags = {
Name = %[1]q
}
}
`, rName, subnetCount),
)
}

func ConfigVPCWithSubnetsIPv6(rName string, subnetCount int) string {
return ConfigCompose(
ConfigAvailableAZsNoOptInDefaultExclude(),
Expand Down Expand Up @@ -2588,6 +2617,18 @@ func SkipIfEnvVarNotSet(t *testing.T, key string) string {
return v
}

// SkipIfExeNotOnPath skips the current test if the specified executable is not found in the directories named by the PATH environment variable.
// The absolute path to the executable is returned.
func SkipIfExeNotOnPath(t *testing.T, file string) string {
t.Helper()

v, err := exec.LookPath(file)
if err != nil {
t.Skipf("File %s not found on PATH, skipping test: %s", v, err)
}
return v
}

// RunSerialTests1Level runs test cases in parallel, optionally sleeping between each.
func RunSerialTests1Level(t *testing.T, testCases map[string]func(*testing.T), d time.Duration) {
t.Helper()
Expand Down
5 changes: 5 additions & 0 deletions internal/framework/flex/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
)

func ExpandFrameworkStringList(ctx context.Context, v basetypes.ListValuable) []*string {
Expand Down Expand Up @@ -72,6 +73,10 @@ func FlattenFrameworkStringValueList[T ~string](ctx context.Context, v []T) type
return output
}

func FlattenFrameworkStringValueListOfString(ctx context.Context, vs []string) fwtypes.ListValueOf[basetypes.StringValue] {
return fwtypes.ListValueOf[basetypes.StringValue]{ListValue: FlattenFrameworkStringValueList(ctx, vs)}
}

// FlattenFrameworkStringValueListLegacy is the Plugin Framework variant of FlattenStringValueList.
// A nil slice is converted to an empty (non-null) List.
func FlattenFrameworkStringValueListLegacy[T ~string](_ context.Context, vs []T) types.List {
Expand Down
8 changes: 4 additions & 4 deletions internal/service/bedrockagent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ func (r *agentResource) Delete(ctx context.Context, request resource.DeleteReque
return
}

if _, err := waitAgentDeleted(ctx, conn, agentID, r.DeleteTimeout(ctx, data.Timeouts)); err != nil {
response.Diagnostics.AddError(fmt.Sprintf("waiting for Bedrock Agent (%s) delete", agentID), err.Error())
if err != nil {
response.Diagnostics.AddError(fmt.Sprintf("deleting Bedrock Agent (%s)", agentID), err.Error())

return
}

if err != nil {
response.Diagnostics.AddError(fmt.Sprintf("deleting Bedrock Agent (%s)", data.ID.ValueString()), err.Error())
if _, err := waitAgentDeleted(ctx, conn, agentID, r.DeleteTimeout(ctx, data.Timeouts)); err != nil {
response.Diagnostics.AddError(fmt.Sprintf("waiting for Bedrock Agent (%s) delete", agentID), err.Error())

return
}
Expand Down
10 changes: 5 additions & 5 deletions internal/service/bedrockagent/bedrockagent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ func TestAccBedrockAgent_serial(t *testing.T) {

testCases := map[string]map[string]func(t *testing.T){
"KnowledgeBase": {
"basic": testAccKnowledgeBase_basic,
"disappears": testAccKnowledgeBase_disappears,
"rds": testAccKnowledgeBase_rds,
"update": testAccKnowledgeBase_update,
"tags": testAccKnowledgeBase_tags,
"basicRDS": testAccKnowledgeBase_basicRDS,
"disappears": testAccKnowledgeBase_disappears,
"tags": testAccKnowledgeBase_tags,
"basicOpenSearch": testAccKnowledgeBase_basicOpenSearch,
"updateOpenSearch": testAccKnowledgeBase_updateOpenSearch,
},
}

Expand Down
Loading
Loading