Skip to content

Commit

Permalink
Merge pull request hashicorp#37726 from nikhil-goenka/t/aws_sagemaker…
Browse files Browse the repository at this point in the history
…_endpoint_configuration

aws_sagemaker_endpoint_configuration: supports inputandoutput
  • Loading branch information
ewbankkit authored Jun 28, 2024
2 parents f5803ec + bdcf4aa commit 361584a
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/37726.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_sagemaker_endpoint_configuration: Add support for `InputAndOutput` in `capture_mode`
```
68 changes: 68 additions & 0 deletions internal/service/sagemaker/endpoint_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,39 @@ func TestAccSageMakerEndpointConfiguration_dataCapture(t *testing.T) {
})
}

func TestAccSageMakerEndpointConfiguration_dataCapture_inputAndOutput(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_sagemaker_endpoint_configuration.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.SageMakerServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckEndpointConfigurationDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccEndpointConfigurationConfig_dataCapture_inputAndOutput(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckEndpointConfigurationExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "data_capture_config.#", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, "data_capture_config.0.enable_capture", acctest.CtTrue),
resource.TestCheckResourceAttr(resourceName, "data_capture_config.0.initial_sampling_percentage", "50"),
resource.TestCheckResourceAttr(resourceName, "data_capture_config.0.destination_s3_uri", fmt.Sprintf("s3://%s/", rName)),
resource.TestCheckResourceAttr(resourceName, "data_capture_config.0.capture_options.0.capture_mode", "InputAndOutput"),
resource.TestCheckResourceAttr(resourceName, "data_capture_config.0.capture_content_type_header.0.json_content_types.#", acctest.Ct1),
resource.TestCheckTypeSetElemAttr(resourceName, "data_capture_config.0.capture_content_type_header.0.json_content_types.*", "application/json"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccSageMakerEndpointConfiguration_disappears(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
Expand Down Expand Up @@ -1034,6 +1067,41 @@ resource "aws_sagemaker_endpoint_configuration" "test" {
`, rName))
}

func testAccEndpointConfigurationConfig_dataCapture_inputAndOutput(rName string) string {
return acctest.ConfigCompose(testAccEndpointConfigurationConfig_base(rName), fmt.Sprintf(`
resource "aws_s3_bucket" "test" {
bucket = %[1]q
force_destroy = true
}
resource "aws_sagemaker_endpoint_configuration" "test" {
name = %[1]q
production_variants {
variant_name = "variant-1"
model_name = aws_sagemaker_model.test.name
initial_instance_count = 2
instance_type = "ml.t2.medium"
initial_variant_weight = 1
}
data_capture_config {
enable_capture = true
initial_sampling_percentage = 50
destination_s3_uri = "s3://${aws_s3_bucket.test.bucket}/"
capture_options {
capture_mode = "InputAndOutput"
}
capture_content_type_header {
json_content_types = ["application/json"]
}
}
}
`, rName))
}

func testAccEndpointConfigurationConfig_asyncKMS(rName string) string {
return acctest.ConfigCompose(testAccEndpointConfigurationConfig_base(rName), fmt.Sprintf(`
resource "aws_s3_bucket" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ This resource supports the following arguments:

#### capture_options

* `capture_mode` - (Required) Specifies the data to be captured. Should be one of `Input` or `Output`.
* `capture_mode` - (Required) Specifies the data to be captured. Should be one of `Input`, `Output` or `InputAndOutput`.

#### capture_content_type_header

Expand Down

0 comments on commit 361584a

Please sign in to comment.