From 0236adec2b0e91ab7c1692852738c078a6d4244f Mon Sep 17 00:00:00 2001 From: michaeljneely Date: Mon, 29 Apr 2024 13:38:26 +0100 Subject: [PATCH 1/8] code editor custom image in sagemaker_domain --- internal/service/sagemaker/domain.go | 21 +++ internal/service/sagemaker/domain_test.go | 168 ++++++++++++++++++ .../python/r/sagemaker_domain.html.markdown | 3 +- .../r/sagemaker_domain.html.markdown | 3 +- website/docs/r/sagemaker_domain.html.markdown | 1 + 5 files changed, 194 insertions(+), 2 deletions(-) diff --git a/internal/service/sagemaker/domain.go b/internal/service/sagemaker/domain.go index 450c49b15fe..0b5de37eaeb 100644 --- a/internal/service/sagemaker/domain.go +++ b/internal/service/sagemaker/domain.go @@ -389,6 +389,27 @@ func ResourceDomain() *schema.Resource { ValidateFunc: verify.ValidARN, }, }, + "custom_image": { + Type: schema.TypeList, + Optional: true, + MaxItems: 200, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "app_image_config_name": { + Type: schema.TypeString, + Required: true, + }, + "image_name": { + Type: schema.TypeString, + Required: true, + }, + "image_version_number": { + Type: schema.TypeInt, + Optional: true, + }, + }, + }, + }, }, }, }, diff --git a/internal/service/sagemaker/domain_test.go b/internal/service/sagemaker/domain_test.go index b4091e2cb13..f95a1ce8a5f 100644 --- a/internal/service/sagemaker/domain_test.go +++ b/internal/service/sagemaker/domain_test.go @@ -654,6 +654,85 @@ func testAccDomain_codeEditorAppSettings(t *testing.T) { }) } +func testAccDomain_codeEditorAppSettings_customImage(t *testing.T) { + ctx := acctest.Context(t) + if os.Getenv("SAGEMAKER_IMAGE_VERSION_BASE_IMAGE") == "" { + t.Skip("Environment variable SAGEMAKER_IMAGE_VERSION_BASE_IMAGE is not set") + } + + var domain sagemaker.DescribeDomainOutput + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_sagemaker_domain.test" + baseImage := os.Getenv("SAGEMAKER_IMAGE_VERSION_BASE_IMAGE") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, names.SageMakerServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckDomainDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccDomainConfig_codeEditorAppSettingsCustomImage(rName, baseImage), + Check: resource.ComposeTestCheckFunc( + testAccCheckDomainExists(ctx, resourceName, &domain), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", "1"), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.#", "1"), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.default_resource_spec.#", "0"), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.#", "1"), + resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.0.app_image_config_name", "aws_sagemaker_app_image_config.test", "app_image_config_name"), + resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.0.image_name", "aws_sagemaker_image.test", "image_name"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"retention_policy"}, + }, + }, + }) +} + +func testAccDomain_codeEditorAppSettings_defaultResourceSpecAndCustomImage(t *testing.T) { + ctx := acctest.Context(t) + if os.Getenv("SAGEMAKER_IMAGE_VERSION_BASE_IMAGE") == "" { + t.Skip("Environment variable SAGEMAKER_IMAGE_VERSION_BASE_IMAGE is not set") + } + + var domain sagemaker.DescribeDomainOutput + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_sagemaker_domain.test" + baseImage := os.Getenv("SAGEMAKER_IMAGE_VERSION_BASE_IMAGE") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, names.SageMakerServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckDomainDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccDomainConfig_codeEditorAppSettingsDefaultResourceSpecAndCustomImage(rName, baseImage), + Check: resource.ComposeTestCheckFunc( + testAccCheckDomainExists(ctx, resourceName, &domain), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", "1"), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.#", "1"), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.default_resource_spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.#", "1"), + resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.default_resource_spec.0.sagemaker_image_version_arn", "aws_sagemaker_image_version.test", "arn"), + resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.0.app_image_config_name", "aws_sagemaker_app_image_config.test", "app_image_config_name"), + resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.0.image_name", "aws_sagemaker_image.test", "image_name"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"retention_policy"}, + }, + }, + }) +} + func testAccDomain_jupyterLabAppSettings(t *testing.T) { ctx := acctest.Context(t) var domain sagemaker.DescribeDomainOutput @@ -1765,6 +1844,95 @@ resource "aws_sagemaker_domain" "test" { `, rName)) } +func testAccDomainConfig_codeEditorAppSettingsCustomImage(rName, baseImage string) string { + return acctest.ConfigCompose(testAccDomainConfig_base(rName), fmt.Sprintf(` +resource "aws_sagemaker_image" "test" { + image_name = %[1]q + role_arn = aws_iam_role.test.arn + + depends_on = [aws_iam_role_policy_attachment.test] +} + +resource "aws_sagemaker_app_image_config" "test" { + app_image_config_name = %[1]q +} + +resource "aws_sagemaker_image_version" "test" { + image_name = aws_sagemaker_image.test.id + base_image = %[2]q +} + +resource "aws_sagemaker_domain" "test" { + domain_name = %[1]q + auth_mode = "IAM" + vpc_id = aws_vpc.test.id + subnet_ids = aws_subnet.test[*].id + + default_user_settings { + execution_role = aws_iam_role.test.arn + + code_editor_app_settings { + custom_image { + app_image_config_name = aws_sagemaker_app_image_config.test.app_image_config_name + image_name = aws_sagemaker_image_version.test.image_name + } + } + } + + retention_policy { + home_efs_file_system = "Delete" + } +} +`, rName, baseImage)) +} + +func testAccDomainConfig_codeEditorAppSettingsDefaultResourceSpecAndCustomImage(rName, baseImage string) string { + return acctest.ConfigCompose(testAccDomainConfig_base(rName), fmt.Sprintf(` +resource "aws_sagemaker_image" "test" { + image_name = %[1]q + role_arn = aws_iam_role.test.arn + + depends_on = [aws_iam_role_policy_attachment.test] +} + +resource "aws_sagemaker_app_image_config" "test" { + app_image_config_name = %[1]q +} + +resource "aws_sagemaker_image_version" "test" { + image_name = aws_sagemaker_image.test.id + base_image = %[2]q +} + +resource "aws_sagemaker_domain" "test" { + domain_name = %[1]q + auth_mode = "IAM" + vpc_id = aws_vpc.test.id + subnet_ids = aws_subnet.test[*].id + + default_user_settings { + execution_role = aws_iam_role.test.arn + + code_editor_app_settings { + default_resource_spec { + instance_type = "ml.t3.micro" + sagemaker_image_version_arn = aws_sagemaker_image_version.test.arn + } + + custom_image { + app_image_config_name = aws_sagemaker_app_image_config.test.app_image_config_name + image_name = aws_sagemaker_image_version.test.image_name + } + } + } + + retention_policy { + home_efs_file_system = "Delete" + } +} +`, rName, baseImage)) +} + func testAccDomainConfig_kernelGatewayAppSettings(rName string) string { return acctest.ConfigCompose(testAccDomainConfig_base(rName), fmt.Sprintf(` resource "aws_sagemaker_domain" "test" { diff --git a/website/docs/cdktf/python/r/sagemaker_domain.html.markdown b/website/docs/cdktf/python/r/sagemaker_domain.html.markdown index 748c096aaf2..f751002aa29 100644 --- a/website/docs/cdktf/python/r/sagemaker_domain.html.markdown +++ b/website/docs/cdktf/python/r/sagemaker_domain.html.markdown @@ -253,6 +253,7 @@ The following arguments are optional: * `default_resource_spec` - (Optional) The default instance type and the Amazon Resource Name (ARN) of the SageMaker image created on the instance. see [`default_resource_spec` Block](#default_resource_spec-block) below. * `lifecycle_config_arns` - (Optional) The Amazon Resource Name (ARN) of the Lifecycle Configurations. +* `custom_image` - (Optional) A list of custom SageMaker images that are configured to run as a CodeEditor app. see [`custom_image` Block](#custom_image-block) below. ##### `code_repository` Block @@ -342,4 +343,4 @@ Using `terraform import`, import SageMaker Domains using the `id`. For example: % terraform import aws_sagemaker_domain.test_domain d-8jgsjtilstu8 ``` - \ No newline at end of file + diff --git a/website/docs/cdktf/typescript/r/sagemaker_domain.html.markdown b/website/docs/cdktf/typescript/r/sagemaker_domain.html.markdown index 66e8ca0bb13..3597a04a946 100644 --- a/website/docs/cdktf/typescript/r/sagemaker_domain.html.markdown +++ b/website/docs/cdktf/typescript/r/sagemaker_domain.html.markdown @@ -268,6 +268,7 @@ The following arguments are optional: * `defaultResourceSpec` - (Optional) The default instance type and the Amazon Resource Name (ARN) of the SageMaker image created on the instance. see [`defaultResourceSpec` Block](#default_resource_spec-block) below. * `lifecycleConfigArns` - (Optional) The Amazon Resource Name (ARN) of the Lifecycle Configurations. +* `customImage` - (Optional) A list of custom SageMaker images that are configured to run as a CodeEditor app. see [`customImage` Block](#custom_image-block) below. ##### `codeRepository` Block @@ -364,4 +365,4 @@ Using `terraform import`, import SageMaker Domains using the `id`. For example: % terraform import aws_sagemaker_domain.test_domain d-8jgsjtilstu8 ``` - \ No newline at end of file + diff --git a/website/docs/r/sagemaker_domain.html.markdown b/website/docs/r/sagemaker_domain.html.markdown index 2ac14e33afd..2b94d3793a7 100644 --- a/website/docs/r/sagemaker_domain.html.markdown +++ b/website/docs/r/sagemaker_domain.html.markdown @@ -221,6 +221,7 @@ The following arguments are optional: * `default_resource_spec` - (Optional) The default instance type and the Amazon Resource Name (ARN) of the SageMaker image created on the instance. see [`default_resource_spec` Block](#default_resource_spec-block) below. * `lifecycle_config_arns` - (Optional) The Amazon Resource Name (ARN) of the Lifecycle Configurations. +* `custom_image` - (Optional) A list of custom SageMaker images that are configured to run as a CodeEditor app. see [`custom_image` Block](#custom_image-block) below. ##### `code_repository` Block From 174114b08092256ef3116c6304f3871f6a9978a7 Mon Sep 17 00:00:00 2001 From: michaeljneely Date: Mon, 29 Apr 2024 13:44:03 +0100 Subject: [PATCH 2/8] code editor custom image in sagemaker user profile --- internal/service/sagemaker/user_profile.go | 21 +++++ .../service/sagemaker/user_profile_test.go | 82 +++++++++++++++++++ .../r/sagemaker_user_profile.html.markdown | 3 +- .../r/sagemaker_user_profile.html.markdown | 3 +- .../r/sagemaker_user_profile.html.markdown | 1 + 5 files changed, 108 insertions(+), 2 deletions(-) diff --git a/internal/service/sagemaker/user_profile.go b/internal/service/sagemaker/user_profile.go index 56f826ce9b0..f48f8aea661 100644 --- a/internal/service/sagemaker/user_profile.go +++ b/internal/service/sagemaker/user_profile.go @@ -239,6 +239,27 @@ func ResourceUserProfile() *schema.Resource { ValidateFunc: verify.ValidARN, }, }, + "custom_image": { + Type: schema.TypeList, + Optional: true, + MaxItems: 200, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "app_image_config_name": { + Type: schema.TypeString, + Required: true, + }, + "image_name": { + Type: schema.TypeString, + Required: true, + }, + "image_version_number": { + Type: schema.TypeInt, + Optional: true, + }, + }, + }, + }, }, }, }, diff --git a/internal/service/sagemaker/user_profile_test.go b/internal/service/sagemaker/user_profile_test.go index 8538cfbc2d0..aa79f0cd7da 100644 --- a/internal/service/sagemaker/user_profile_test.go +++ b/internal/service/sagemaker/user_profile_test.go @@ -277,6 +277,44 @@ func testAccUserProfile_kernelGatewayAppSettings_imageconfig(t *testing.T) { }) } +func testAccUserProfile_codeEditorAppSettings_imageconfig(t *testing.T) { + ctx := acctest.Context(t) + if os.Getenv("SAGEMAKER_IMAGE_VERSION_BASE_IMAGE") == "" { + t.Skip("Environment variable SAGEMAKER_IMAGE_VERSION_BASE_IMAGE is not set") + } + + var domain sagemaker.DescribeUserProfileOutput + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_sagemaker_user_profile.test" + baseImage := os.Getenv("SAGEMAKER_IMAGE_VERSION_BASE_IMAGE") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, names.SageMakerServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckUserProfileDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccUserProfileConfig_codeEditorAppSettingsImage(rName, baseImage), + Check: resource.ComposeTestCheckFunc( + testAccCheckUserProfileExists(ctx, resourceName, &domain), + resource.TestCheckResourceAttr(resourceName, "user_settings.#", "1"), + resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.#", "1"), + resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.0.lifecycle_config_arns.#", "1"), + resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.0.default_resource_spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.0.default_resource_spec.0.instance_type", "ml.t3.micro"), + resource.TestCheckResourceAttrPair(resourceName, "user_settings.0.code_editor_app_settings.0.default_resource_spec.0.sagemaker_image_version_arn", "aws_sagemaker_image_version.test", "arn"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccUserProfile_jupyterServerAppSettings(t *testing.T) { ctx := acctest.Context(t) var domain sagemaker.DescribeUserProfileOutput @@ -615,3 +653,47 @@ resource "aws_sagemaker_user_profile" "test" { } `, rName, baseImage)) } + + +func testAccUserProfileConfig_codeEditorAppSettingsImage(rName, baseImage string) string { + return acctest.ConfigCompose(testAccUserProfileConfig_base(rName), fmt.Sprintf(` +data "aws_partition" "current" {} + +resource "aws_iam_role_policy_attachment" "test" { + role = aws_iam_role.test.name + policy_arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonSageMakerFullAccess" +} + +resource "aws_sagemaker_image" "test" { + image_name = %[1]q + role_arn = aws_image_role.test.arn + + depends_on = [aws_iam_role_policy_attachment.test] +} + +resource "aws_sagemaker_image_version" "test" { + image_name = aws_sagemaker_image.test.id + base_image = %[2]q + + depends_on = [aws_iam_role_policy_attachment.test] +} + +resource "aws_sagemaker_user_profile" "test" { + domain_id = aws_sagemaker_domain.test.id + user_profile_name = %[1]q + + user_settings { + execution_role = aws_iam_role.test.arn + + code_editor_app_settings { + default_resource_spec { + instance_type = "ml.t3.micro" + sagemaker_image_version_arn = aws_sagemaker_image_version.test.arn + } + } + } + + depends_on = [aws_iam_role_policy_attachment.test] +} +`, rName, baseImage)) +} diff --git a/website/docs/cdktf/python/r/sagemaker_user_profile.html.markdown b/website/docs/cdktf/python/r/sagemaker_user_profile.html.markdown index 2b86374b85b..b65016ac40e 100644 --- a/website/docs/cdktf/python/r/sagemaker_user_profile.html.markdown +++ b/website/docs/cdktf/python/r/sagemaker_user_profile.html.markdown @@ -105,6 +105,7 @@ This resource supports the following arguments: * `default_resource_spec` - (Optional) The default instance type and the Amazon Resource Name (ARN) of the SageMaker image created on the instance. see [Default Resource Spec](#default_resource_spec) below. * `lifecycle_config_arns` - (Optional) The Amazon Resource Name (ARN) of the Lifecycle Configurations. +* `custom_image` - (Optional) A list of custom SageMaker images that are configured to run as a CodeEditor app. see [Custom Image](#custom_image) below. #### r_session_app_settings @@ -232,4 +233,4 @@ Using `terraform import`, import SageMaker User Profiles using the `arn`. For ex % terraform import aws_sagemaker_user_profile.test_user_profile arn:aws:sagemaker:us-west-2:123456789012:user-profile/domain-id/profile-name ``` - \ No newline at end of file + diff --git a/website/docs/cdktf/typescript/r/sagemaker_user_profile.html.markdown b/website/docs/cdktf/typescript/r/sagemaker_user_profile.html.markdown index 44c9c3d87bc..d7cc2c0659c 100644 --- a/website/docs/cdktf/typescript/r/sagemaker_user_profile.html.markdown +++ b/website/docs/cdktf/typescript/r/sagemaker_user_profile.html.markdown @@ -108,6 +108,7 @@ This resource supports the following arguments: * `defaultResourceSpec` - (Optional) The default instance type and the Amazon Resource Name (ARN) of the SageMaker image created on the instance. see [Default Resource Spec](#default_resource_spec) below. * `lifecycleConfigArns` - (Optional) The Amazon Resource Name (ARN) of the Lifecycle Configurations. +* `customImage` - (Optional) A list of custom SageMaker images that are configured to run as a CodeEditor app. see [Custom Image](#custom_image) below. #### r_session_app_settings @@ -242,4 +243,4 @@ Using `terraform import`, import SageMaker User Profiles using the `arn`. For ex % terraform import aws_sagemaker_user_profile.test_user_profile arn:aws:sagemaker:us-west-2:123456789012:user-profile/domain-id/profile-name ``` - \ No newline at end of file + diff --git a/website/docs/r/sagemaker_user_profile.html.markdown b/website/docs/r/sagemaker_user_profile.html.markdown index d06dfecbec1..c062db7b8ca 100644 --- a/website/docs/r/sagemaker_user_profile.html.markdown +++ b/website/docs/r/sagemaker_user_profile.html.markdown @@ -92,6 +92,7 @@ This resource supports the following arguments: * `default_resource_spec` - (Optional) The default instance type and the Amazon Resource Name (ARN) of the SageMaker image created on the instance. see [Default Resource Spec](#default_resource_spec) below. * `lifecycle_config_arns` - (Optional) The Amazon Resource Name (ARN) of the Lifecycle Configurations. +* `custom_image` - (Optional) A list of custom SageMaker images that are configured to run as a CodeEditor app. see [Custom Image](#custom_image) below. #### r_session_app_settings From 7d0063124f8b2fdeca5b2312d9c3836024a02018 Mon Sep 17 00:00:00 2001 From: michaeljneely Date: Mon, 29 Apr 2024 13:46:18 +0100 Subject: [PATCH 3/8] changelog --- .changelog/37153.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changelog/37153.txt diff --git a/.changelog/37153.txt b/.changelog/37153.txt new file mode 100644 index 00000000000..f6d78bc3228 --- /dev/null +++ b/.changelog/37153.txt @@ -0,0 +1,5 @@ + +```release-note:enhancement +resource/aws_sagemaker_domain: Add `custom_image` argument to `default_user_settings.code_editor_app_settings` +resource/aws_sagemaker_user_profile: Add `custom_image` argument to `user_settings.code_editor_app_settings` +``` From 48b2c85757028b5f97e936508f78fe212daba7e5 Mon Sep 17 00:00:00 2001 From: michaeljneely Date: Fri, 10 May 2024 16:50:59 +0100 Subject: [PATCH 4/8] add custom_image to flatten and expand DomainCodeEditorAppSettings --- internal/service/sagemaker/domain.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/service/sagemaker/domain.go b/internal/service/sagemaker/domain.go index 0b5de37eaeb..373fcde9374 100644 --- a/internal/service/sagemaker/domain.go +++ b/internal/service/sagemaker/domain.go @@ -1394,6 +1394,10 @@ func expandDomainCodeEditorAppSettings(l []interface{}) *sagemaker.CodeEditorApp config := &sagemaker.CodeEditorAppSettings{} + if v, ok := m["custom_image"].([]interface{}); ok && len(v) > 0 { + config.CustomImages = expandDomainCustomImages(v) + } + if v, ok := m["default_resource_spec"].([]interface{}); ok && len(v) > 0 { config.DefaultResourceSpec = expandResourceSpec(v) } @@ -1970,6 +1974,10 @@ func flattenDomainCodeEditorAppSettings(config *sagemaker.CodeEditorAppSettings) m := map[string]interface{}{} + if config.CustomImages != nil { + m["custom_image"] = flattenDomainCustomImages(config.CustomImages) + } + if config.DefaultResourceSpec != nil { m["default_resource_spec"] = flattenResourceSpec(config.DefaultResourceSpec) } From 3165f81baefc4da03a32bc60e315772f8671ca85 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 21 Jun 2024 14:53:04 -0400 Subject: [PATCH 5/8] Tweak CHANGELOG entries. --- .changelog/37153.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.changelog/37153.txt b/.changelog/37153.txt index f6d78bc3228..5af39c665fe 100644 --- a/.changelog/37153.txt +++ b/.changelog/37153.txt @@ -1,5 +1,8 @@ ```release-note:enhancement -resource/aws_sagemaker_domain: Add `custom_image` argument to `default_user_settings.code_editor_app_settings` -resource/aws_sagemaker_user_profile: Add `custom_image` argument to `user_settings.code_editor_app_settings` +resource/aws_sagemaker_domain: Add `default_user_settings.code_editor_app_settings.custom_image` configuration block +``` + +```release-note:enhancement +resource/aws_sagemaker_user_profile: Add `user_settings.code_editor_app_settings.custom_image` configuration block ``` From 319f0566364fe8a886ae9732230e8a970ba4faa9 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 21 Jun 2024 15:05:48 -0400 Subject: [PATCH 6/8] Hook up new acceptance tests. --- internal/service/sagemaker/sagemaker_test.go | 2 ++ internal/service/sagemaker/user_profile_test.go | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/service/sagemaker/sagemaker_test.go b/internal/service/sagemaker/sagemaker_test.go index aef052b01f0..4bc8b3ce350 100644 --- a/internal/service/sagemaker/sagemaker_test.go +++ b/internal/service/sagemaker/sagemaker_test.go @@ -49,6 +49,7 @@ func TestAccSageMaker_serial(t *testing.T) { "kernelGatewayAppSettings_defaultResourceAndCustomImage": testAccDomain_kernelGatewayAppSettings_defaultResourceSpecAndCustomImage, "jupyterServerAppSettings": testAccDomain_jupyterServerAppSettings, "codeEditorAppSettings": testAccDomain_codeEditorAppSettings, + "codeEditorAppSettings_customImage": testAccDomain_codeEditorAppSettings_customImage, "jupyterLabAppSettings": testAccDomain_jupyterLabAppSettings, "kms": testAccDomain_kms, "securityGroup": testAccDomain_securityGroup, @@ -98,6 +99,7 @@ func TestAccSageMaker_serial(t *testing.T) { "kernelGatewayAppSettings": testAccUserProfile_kernelGatewayAppSettings, "kernelGatewayAppSettings_lifecycleConfig": testAccUserProfile_kernelGatewayAppSettings_lifecycleconfig, "kernelGatewayAppSettings_imageConfig": testAccUserProfile_kernelGatewayAppSettings_imageconfig, + "codeEditorAppSettings_customImage": testAccUserProfile_codeEditorAppSettings_customImage, "jupyterServerAppSettings": testAccUserProfile_jupyterServerAppSettings, }, "Workforce": { diff --git a/internal/service/sagemaker/user_profile_test.go b/internal/service/sagemaker/user_profile_test.go index af5860314f3..353ad9a4985 100644 --- a/internal/service/sagemaker/user_profile_test.go +++ b/internal/service/sagemaker/user_profile_test.go @@ -277,7 +277,7 @@ func testAccUserProfile_kernelGatewayAppSettings_imageconfig(t *testing.T) { }) } -func testAccUserProfile_codeEditorAppSettings_imageconfig(t *testing.T) { +func testAccUserProfile_codeEditorAppSettings_customImage(t *testing.T) { ctx := acctest.Context(t) if os.Getenv("SAGEMAKER_IMAGE_VERSION_BASE_IMAGE") == "" { t.Skip("Environment variable SAGEMAKER_IMAGE_VERSION_BASE_IMAGE is not set") @@ -654,7 +654,6 @@ resource "aws_sagemaker_user_profile" "test" { `, rName, baseImage)) } - func testAccUserProfileConfig_codeEditorAppSettingsImage(rName, baseImage string) string { return acctest.ConfigCompose(testAccUserProfileConfig_base(rName), fmt.Sprintf(` data "aws_partition" "current" {} From 325bf846470191c19f0a788abebaa76e9d419694 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 21 Jun 2024 15:24:47 -0400 Subject: [PATCH 7/8] Run 'make fix-constants PKG=sagemaker'. --- internal/service/sagemaker/domain_test.go | 18 +++++++++--------- .../service/sagemaker/user_profile_test.go | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/service/sagemaker/domain_test.go b/internal/service/sagemaker/domain_test.go index 5d942b6b6f0..f8431a3a142 100644 --- a/internal/service/sagemaker/domain_test.go +++ b/internal/service/sagemaker/domain_test.go @@ -675,10 +675,10 @@ func testAccDomain_codeEditorAppSettings_customImage(t *testing.T) { Config: testAccDomainConfig_codeEditorAppSettingsCustomImage(rName, baseImage), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, resourceName, &domain), - resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", "1"), - resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.#", "1"), - resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.default_resource_spec.#", "0"), - resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.#", "1"), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.#", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.default_resource_spec.#", acctest.Ct0), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.#", acctest.Ct1), resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.0.app_image_config_name", "aws_sagemaker_app_image_config.test", "app_image_config_name"), resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.0.image_name", "aws_sagemaker_image.test", "image_name"), ), @@ -714,11 +714,11 @@ func testAccDomain_codeEditorAppSettings_defaultResourceSpecAndCustomImage(t *te Config: testAccDomainConfig_codeEditorAppSettingsDefaultResourceSpecAndCustomImage(rName, baseImage), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, resourceName, &domain), - resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", "1"), - resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.#", "1"), - resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.default_resource_spec.#", "1"), - resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.#", "1"), - resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.default_resource_spec.0.sagemaker_image_version_arn", "aws_sagemaker_image_version.test", "arn"), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.#", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.default_resource_spec.#", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.#", acctest.Ct1), + resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.default_resource_spec.0.sagemaker_image_version_arn", "aws_sagemaker_image_version.test", names.AttrARN), resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.0.app_image_config_name", "aws_sagemaker_app_image_config.test", "app_image_config_name"), resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.code_editor_app_settings.0.custom_image.0.image_name", "aws_sagemaker_image.test", "image_name"), ), diff --git a/internal/service/sagemaker/user_profile_test.go b/internal/service/sagemaker/user_profile_test.go index 353ad9a4985..2ece32de952 100644 --- a/internal/service/sagemaker/user_profile_test.go +++ b/internal/service/sagemaker/user_profile_test.go @@ -298,12 +298,12 @@ func testAccUserProfile_codeEditorAppSettings_customImage(t *testing.T) { Config: testAccUserProfileConfig_codeEditorAppSettingsImage(rName, baseImage), Check: resource.ComposeTestCheckFunc( testAccCheckUserProfileExists(ctx, resourceName, &domain), - resource.TestCheckResourceAttr(resourceName, "user_settings.#", "1"), - resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.#", "1"), - resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.0.lifecycle_config_arns.#", "1"), - resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.0.default_resource_spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "user_settings.#", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.#", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.0.lifecycle_config_arns.#", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.0.default_resource_spec.#", acctest.Ct1), resource.TestCheckResourceAttr(resourceName, "user_settings.0.code_editor_app_settings.0.default_resource_spec.0.instance_type", "ml.t3.micro"), - resource.TestCheckResourceAttrPair(resourceName, "user_settings.0.code_editor_app_settings.0.default_resource_spec.0.sagemaker_image_version_arn", "aws_sagemaker_image_version.test", "arn"), + resource.TestCheckResourceAttrPair(resourceName, "user_settings.0.code_editor_app_settings.0.default_resource_spec.0.sagemaker_image_version_arn", "aws_sagemaker_image_version.test", names.AttrARN), ), }, { From e1ddcfb3545ed8722296970e9e97bd9ce96c06b9 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 21 Jun 2024 15:47:20 -0400 Subject: [PATCH 8/8] Hook up another new acceptance test. --- internal/service/sagemaker/sagemaker_test.go | 47 ++++++++++---------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/internal/service/sagemaker/sagemaker_test.go b/internal/service/sagemaker/sagemaker_test.go index 4bc8b3ce350..09d08777656 100644 --- a/internal/service/sagemaker/sagemaker_test.go +++ b/internal/service/sagemaker/sagemaker_test.go @@ -46,29 +46,30 @@ func TestAccSageMaker_serial(t *testing.T) { "kernelGatewayAppSettings": testAccDomain_kernelGatewayAppSettings, "kernelGatewayAppSettings_customImage": testAccDomain_kernelGatewayAppSettings_customImage, "kernelGatewayAppSettings_lifecycleConfig": testAccDomain_kernelGatewayAppSettings_lifecycleConfig, - "kernelGatewayAppSettings_defaultResourceAndCustomImage": testAccDomain_kernelGatewayAppSettings_defaultResourceSpecAndCustomImage, - "jupyterServerAppSettings": testAccDomain_jupyterServerAppSettings, - "codeEditorAppSettings": testAccDomain_codeEditorAppSettings, - "codeEditorAppSettings_customImage": testAccDomain_codeEditorAppSettings_customImage, - "jupyterLabAppSettings": testAccDomain_jupyterLabAppSettings, - "kms": testAccDomain_kms, - "securityGroup": testAccDomain_securityGroup, - "sharingSettings": testAccDomain_sharingSettings, - "defaultUserSettingsUpdated": testAccDomain_defaultUserSettingsUpdated, - "canvas": testAccDomain_canvasAppSettings, - "modelRegisterSettings": testAccDomain_modelRegisterSettings, - "identityProviderOauthSettings": testAccDomain_identityProviderOAuthSettings, - "directDeploySettings": testAccDomain_directDeploySettings, - "kendraSettings": testAccDomain_kendraSettings, - "workspaceSettings": testAccDomain_workspaceSettings, - "domainSettings": testAccDomain_domainSettings, - "rSessionAppSettings": testAccDomain_rSessionAppSettings, - "rStudioServerProAppSettings": testAccDomain_rStudioServerProAppSettings, - "spaceSettingsKernelGatewayAppSettings": testAccDomain_spaceSettingsKernelGatewayAppSettings, - "code": testAccDomain_jupyterServerAppSettings_code, - "efs": testAccDomain_efs, - "posix": testAccDomain_posix, - "spaceStorageSettings": testAccDomain_spaceStorageSettings, + "kernelGatewayAppSettings_defaultResourceAndCustomImage": testAccDomain_kernelGatewayAppSettings_defaultResourceSpecAndCustomImage, + "jupyterServerAppSettings": testAccDomain_jupyterServerAppSettings, + "codeEditorAppSettings": testAccDomain_codeEditorAppSettings, + "codeEditorAppSettings_customImage": testAccDomain_codeEditorAppSettings_customImage, + "codeEditorAppSettings_defaultResourceSpecAndCustomImage": testAccDomain_codeEditorAppSettings_defaultResourceSpecAndCustomImage, + "jupyterLabAppSettings": testAccDomain_jupyterLabAppSettings, + "kms": testAccDomain_kms, + "securityGroup": testAccDomain_securityGroup, + "sharingSettings": testAccDomain_sharingSettings, + "defaultUserSettingsUpdated": testAccDomain_defaultUserSettingsUpdated, + "canvas": testAccDomain_canvasAppSettings, + "modelRegisterSettings": testAccDomain_modelRegisterSettings, + "identityProviderOauthSettings": testAccDomain_identityProviderOAuthSettings, + "directDeploySettings": testAccDomain_directDeploySettings, + "kendraSettings": testAccDomain_kendraSettings, + "workspaceSettings": testAccDomain_workspaceSettings, + "domainSettings": testAccDomain_domainSettings, + "rSessionAppSettings": testAccDomain_rSessionAppSettings, + "rStudioServerProAppSettings": testAccDomain_rStudioServerProAppSettings, + "spaceSettingsKernelGatewayAppSettings": testAccDomain_spaceSettingsKernelGatewayAppSettings, + "code": testAccDomain_jupyterServerAppSettings_code, + "efs": testAccDomain_efs, + "posix": testAccDomain_posix, + "spaceStorageSettings": testAccDomain_spaceStorageSettings, }, "FlowDefinition": { acctest.CtBasic: testAccFlowDefinition_basic,