Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/44567.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_sagemaker_space: Add `space_settings.remote_access` argument
```
1 change: 1 addition & 0 deletions internal/service/sagemaker/sagemaker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func TestAccSageMaker_serial(t *testing.T) {
"codeEditorAppSettings": testAccSpace_codeEditorAppSettings,
"storageSettings": testAccSpace_storageSettings,
"customFileSystem": testAccSpace_customFileSystem,
"remoteAccess": testAccSpace_remoteAccess,
},
"UserProfile": {
acctest.CtBasic: testAccUserProfile_basic,
Expand Down
14 changes: 14 additions & 0 deletions internal/service/sagemaker/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ func resourceSpace() *schema.Resource {
},
},
},
"remote_access": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateDiagFunc: enum.Validate[awstypes.FeatureStatus](),
},
},
},
},
Expand Down Expand Up @@ -679,6 +685,10 @@ func expandSpaceSettings(l []any) *awstypes.SpaceSettings {
config.KernelGatewayAppSettings = expandDomainKernelGatewayAppSettings(v)
}

if v, ok := m["remote_access"].(string); ok {
config.RemoteAccess = awstypes.FeatureStatus(v)
}

if v, ok := m["space_storage_settings"].([]any); ok && len(v) > 0 {
config.SpaceStorageSettings = expandSpaceStorageSettings(v)
}
Expand Down Expand Up @@ -715,6 +725,10 @@ func flattenSpaceSettings(config *awstypes.SpaceSettings) []map[string]any {
m["kernel_gateway_app_settings"] = flattenDomainKernelGatewayAppSettings(config.KernelGatewayAppSettings)
}

if config.RemoteAccess != "" {
m["remote_access"] = config.RemoteAccess
}

if config.SpaceStorageSettings != nil {
m["space_storage_settings"] = flattenSpaceStorageSettings(config.SpaceStorageSettings)
}
Expand Down
81 changes: 81 additions & 0 deletions internal/service/sagemaker/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/YakDriver/regexache"
"github.com/aws/aws-sdk-go-v2/service/sagemaker"
awstypes "github.com/aws/aws-sdk-go-v2/service/sagemaker/types"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
Expand Down Expand Up @@ -408,6 +409,62 @@ func testAccSpace_jupyterServerAppSettings(t *testing.T) {
})
}

func testAccSpace_remoteAccess(t *testing.T) {
ctx := acctest.Context(t)
var domain sagemaker.DescribeSpaceOutput
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_sagemaker_space.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.SageMakerServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckSpaceDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccSpaceConfig_remoteAccess(rName, string(awstypes.FeatureStatusEnabled)),
Check: resource.ComposeTestCheckFunc(
testAccCheckSpaceExists(ctx, resourceName, &domain),
resource.TestCheckResourceAttr(resourceName, "space_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "space_settings.0.remote_access", string(awstypes.FeatureStatusEnabled)),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
// Set remote_access to DISABLED
Config: testAccSpaceConfig_remoteAccess(rName, string(awstypes.FeatureStatusDisabled)),
Check: resource.ComposeTestCheckFunc(
testAccCheckSpaceExists(ctx, resourceName, &domain),
resource.TestCheckResourceAttr(resourceName, "space_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "space_settings.0.remote_access", string(awstypes.FeatureStatusDisabled)),
),
},
{
// Set remote_access back to ENABLED
Config: testAccSpaceConfig_remoteAccess(rName, string(awstypes.FeatureStatusEnabled)),
Check: resource.ComposeTestCheckFunc(
testAccCheckSpaceExists(ctx, resourceName, &domain),
resource.TestCheckResourceAttr(resourceName, "space_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "space_settings.0.remote_access", string(awstypes.FeatureStatusEnabled)),
),
},
{
// Remove remote_access (inherit from the previous value)
Config: testAccSpaceConfig_spaceSettingsEmpty(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckSpaceExists(ctx, resourceName, &domain),
resource.TestCheckResourceAttr(resourceName, "space_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "space_settings.0.remote_access", string(awstypes.FeatureStatusEnabled)),
),
},
},
})
}

func testAccSpace_disappears(t *testing.T) {
ctx := acctest.Context(t)
var domain sagemaker.DescribeSpaceOutput
Expand Down Expand Up @@ -830,3 +887,27 @@ resource "aws_sagemaker_space" "test" {
}
`, rName, baseImage))
}

func testAccSpaceConfig_remoteAccess(rName, remoteAccess string) string {
return acctest.ConfigCompose(testAccSpaceConfig_base(rName), fmt.Sprintf(`
resource "aws_sagemaker_space" "test" {
domain_id = aws_sagemaker_domain.test.id
space_name = %[1]q

space_settings {
remote_access = %[2]q
}
}
`, rName, remoteAccess))
}

func testAccSpaceConfig_spaceSettingsEmpty(rName string) string {
return acctest.ConfigCompose(testAccSpaceConfig_base(rName), fmt.Sprintf(`
resource "aws_sagemaker_space" "test" {
domain_id = aws_sagemaker_domain.test.id
space_name = %[1]q

space_settings {}
}
`, rName))
}
1 change: 1 addition & 0 deletions website/docs/r/sagemaker_space.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The `space_settings` block supports the following arguments:
* `jupyter_lab_app_settings` - (Optional) The settings for the JupyterLab application. See [`jupyter_lab_app_settings` Block](#jupyter_lab_app_settings-block) below.
* `jupyter_server_app_settings` - (Optional) The Jupyter server's app settings. See [`jupyter_server_app_settings` Block](#jupyter_server_app_settings-block) below.
* `kernel_gateway_app_settings` - (Optional) The kernel gateway app settings. See [`kernel_gateway_app_settings` Block](#kernel_gateway_app_settings-block) below.
* `remote_access` - (Optional) Setting that enables or disables remote access for a SageMaker space. Valid values are `ENABLED` and `DISABLED`.
* `space_storage_settings` - (Optional) The storage settings. See [`space_storage_settings` Block](#space_storage_settings-block) below.

### `space_sharing_settings` Block
Expand Down
Loading