Skip to content

Commit

Permalink
TestAccImageBuilderImage_basic: Enable Inspector ECR scanning.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Oct 23, 2023
1 parent 1547c50 commit 5a76c4f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion internal/service/imagebuilder/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
tfimagebuilder "github.com/hashicorp/terraform-provider-aws/internal/service/imagebuilder"
"github.com/hashicorp/terraform-provider-aws/names"
)

func TestAccImageBuilderImage_basic(t *testing.T) {
Expand Down Expand Up @@ -272,7 +273,12 @@ func TestAccImageBuilderImage_imageScanningConfiguration(t *testing.T) {
resourceName := "aws_imagebuilder_image.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
PreCheck: func() {
acctest.PreCheck(ctx, t)
acctest.PreCheckPartitionHasService(t, names.Inspector2EndpointID)
acctest.PreCheckInspector2(ctx, t)
acctest.PreCheckOrganizationManagementAccount(ctx, t)
},
ErrorCheck: acctest.ErrorCheck(t, imagebuilder.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckImageDestroy(ctx),
Expand Down Expand Up @@ -592,6 +598,10 @@ data "aws_partition" "current" {}
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"
tags = {
Name = %[1]q
}
}
resource "aws_default_route_table" "test" {
Expand Down Expand Up @@ -623,12 +633,20 @@ resource "aws_default_security_group" "test" {
resource "aws_internet_gateway" "test" {
vpc_id = aws_vpc.test.id
tags = {
Name = %[1]q
}
}
resource "aws_subnet" "test" {
cidr_block = cidrsubnet(aws_vpc.test.cidr_block, 8, 0)
map_public_ip_on_launch = true
vpc_id = aws_vpc.test.id
tags = {
Name = %[1]q
}
}
resource "aws_iam_role" "test" {
Expand Down Expand Up @@ -722,6 +740,13 @@ func testAccImageConfig_imageScanningConfigurationEnabled(rName string) string {
return acctest.ConfigCompose(
testAccImageConfig_containerRecipeBase(rName),
`
data "aws_caller_identity" "current" {}
resource "aws_inspector2_enabler" "test" {
account_ids = [data.aws_caller_identity.current.account_id]
resource_types = ["ECR"]
}
resource "aws_imagebuilder_image" "test" {
container_recipe_arn = aws_imagebuilder_container_recipe.test.arn
infrastructure_configuration_arn = aws_imagebuilder_infrastructure_configuration.test.arn
Expand All @@ -734,6 +759,8 @@ resource "aws_imagebuilder_image" "test" {
container_tags = ["foo", "bar"]
}
}
depends_on = [aws_inspector2_enabler.test]
}
`)
}

0 comments on commit 5a76c4f

Please sign in to comment.