Skip to content

Commit

Permalink
Merge pull request #38567 from deepakbshetty/f-aws_sagemaker_user_pro…
Browse files Browse the repository at this point in the history
…file-studio_web_portal_settings

r/aws_sagemaker_user_profile: add studio_web_portal_settings
  • Loading branch information
ewbankkit authored Sep 9, 2024
2 parents 2eae23d + 8260e9b commit f14ae23
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 115 deletions.
3 changes: 3 additions & 0 deletions .changelog/38567.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_sagemaker_user_profile: Add `user_settings.studio_web_portal_settings` configuration block
```
46 changes: 46 additions & 0 deletions internal/service/sagemaker/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,10 @@ func expandUserSettings(l []interface{}) *awstypes.UserSettings {
config.RStudioServerProAppSettings = expandRStudioServerProAppSettings(v)
}

if v, ok := m["studio_web_portal_settings"].([]interface{}); ok && len(v) > 0 {
config.StudioWebPortalSettings = expandStudioWebPortalSettings(v)
}

return config
}

Expand Down Expand Up @@ -1839,6 +1843,26 @@ func expandDomainCustomImages(l []interface{}) []awstypes.CustomImage {
return images
}

func expandStudioWebPortalSettings(l []interface{}) *awstypes.StudioWebPortalSettings {
if len(l) == 0 || l[0] == nil {
return nil
}

m := l[0].(map[string]interface{})

config := &awstypes.StudioWebPortalSettings{}

if v, ok := m["hidden_app_types"].(*schema.Set); ok && v.Len() > 0 {
config.HiddenAppTypes = flex.ExpandStringyValueSet[awstypes.AppType](v)
}

if v, ok := m["hidden_ml_tools"].(*schema.Set); ok && v.Len() > 0 {
config.HiddenMlTools = flex.ExpandStringyValueSet[awstypes.MlTools](v)
}

return config
}

func flattenUserSettings(config *awstypes.UserSettings) []map[string]interface{} {
if config == nil {
return []map[string]interface{}{}
Expand Down Expand Up @@ -1908,6 +1932,10 @@ func flattenUserSettings(config *awstypes.UserSettings) []map[string]interface{}
m["r_studio_server_pro_app_settings"] = flattenRStudioServerProAppSettings(config.RStudioServerProAppSettings)
}

if config.StudioWebPortalSettings != nil {
m["studio_web_portal_settings"] = flattenStudioWebPortalSettings(config.StudioWebPortalSettings)
}

return []map[string]interface{}{m}
}

Expand Down Expand Up @@ -2508,3 +2536,21 @@ func flattenEFSFileSystemConfig(apiObject awstypes.EFSFileSystemConfig) []map[st

return []map[string]interface{}{tfMap}
}

func flattenStudioWebPortalSettings(config *awstypes.StudioWebPortalSettings) []map[string]interface{} {
if config == nil {
return []map[string]interface{}{}
}

m := map[string]interface{}{}

if config.HiddenAppTypes != nil {
m["hidden_app_types"] = flex.FlattenStringyValueSet[awstypes.AppType](config.HiddenAppTypes)
}

if config.HiddenMlTools != nil {
m["hidden_ml_tools"] = flex.FlattenStringyValueSet[awstypes.MlTools](config.HiddenMlTools)
}

return []map[string]interface{}{m}
}
2 changes: 2 additions & 0 deletions internal/service/sagemaker/sagemaker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ func TestAccSageMaker_serial(t *testing.T) {
"kernelGatewayAppSettings_imageConfig": testAccUserProfile_kernelGatewayAppSettings_imageconfig,
"codeEditorAppSettings_customImage": testAccUserProfile_codeEditorAppSettings_customImage,
"jupyterServerAppSettings": testAccUserProfile_jupyterServerAppSettings,
"studioWebPortalSettings_hiddenAppTypes": testAccUserProfile_studioWebPortalSettings_hiddenAppTypes,
"studioWebPortalSettings_hiddenMlTools": testAccUserProfile_studioWebPortalSettings_hiddenMlTools,
},
"Workforce": {
acctest.CtDisappears: testAccWorkforce_disappears,
Expand Down
16 changes: 0 additions & 16 deletions internal/service/sagemaker/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,6 @@ func statusFlowDefinition(ctx context.Context, conn *sagemaker.Client, name stri
}
}

func statusUserProfile(ctx context.Context, conn *sagemaker.Client, domainID, userProfileName string) retry.StateRefreshFunc {
return func() (interface{}, string, error) {
output, err := findUserProfileByName(ctx, conn, domainID, userProfileName)

if tfresource.NotFound(err) {
return nil, "", nil
}

if err != nil {
return nil, "", err
}

return output, string(output.Status), nil
}
}

func statusApp(ctx context.Context, conn *sagemaker.Client, domainID, userProfileOrSpaceName, appType, appName string) retry.StateRefreshFunc {
return func() (interface{}, string, error) {
output, err := findAppByName(ctx, conn, domainID, userProfileOrSpaceName, appType, appName)
Expand Down
Loading

0 comments on commit f14ae23

Please sign in to comment.