Skip to content

Commit

Permalink
r/aws_sagemaker_domain: add studio_web_portal_settings and default_sp…
Browse files Browse the repository at this point in the history
…ace_settings additional blocks
  • Loading branch information
deepakbshetty committed Aug 31, 2024
1 parent d1934f9 commit 9297a9f
Show file tree
Hide file tree
Showing 5 changed files with 800 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changelog/38457.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_sagemaker_domain: Add `default_user_settings.studio_web_portal_settings` block
resource/aws_sagemaker_domain: Add `default_space_settings.jupyter_lab_app_settings` block
resource/aws_sagemaker_domain: Add `default_space_settings.space_storage_settings` block
resource/aws_sagemaker_domain: Add `default_space_settings.custom_posix_user_config` block
resource/aws_sagemaker_domain: Add `default_space_settings.custom_file_system_config` block
```
275 changes: 275 additions & 0 deletions internal/service/sagemaker/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,162 @@ func resourceDomain() *schema.Resource {
MaxItems: 5,
Elem: &schema.Schema{Type: schema.TypeString},
},
"jupyter_lab_app_settings": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"code_repository": {
Type: schema.TypeSet,
Optional: true,
MaxItems: 10,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"repository_url": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringLenBetween(1, 1024),
},
},
},
},
"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,
},
},
},
},
"default_resource_spec": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
names.AttrInstanceType: {
Type: schema.TypeString,
Optional: true,
ValidateDiagFunc: enum.Validate[awstypes.AppInstanceType](),
},
"lifecycle_config_arn": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: verify.ValidARN,
},
"sagemaker_image_arn": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: verify.ValidARN,
},
"sagemaker_image_version_alias": {
Type: schema.TypeString,
Optional: true,
},
"sagemaker_image_version_arn": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: verify.ValidARN,
},
},
},
},
"lifecycle_config_arns": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: verify.ValidARN,
},
},
},
},
},
"space_storage_settings": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"default_ebs_storage_settings": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"default_ebs_volume_size_in_gb": {
Type: schema.TypeInt,
Required: true,
},
"maximum_ebs_volume_size_in_gb": {
Type: schema.TypeInt,
Required: true,
},
},
},
},
},
},
},
"custom_file_system_config": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"efs_file_system_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
names.AttrFileSystemID: {
Type: schema.TypeString,
Required: true,
},
"file_system_path": {
Type: schema.TypeString,
Required: true,
},
},
},
},
},
},
},
"custom_posix_user_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"gid": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(1001),
},
"uid": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(10000),
},
},
},
},
},
},
},
Expand Down Expand Up @@ -891,6 +1047,31 @@ func resourceDomain() *schema.Resource {
},
},
},
"studio_web_portal_settings": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"hidden_app_types": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateDiagFunc: enum.Validate[awstypes.AppType](),
},
},
"hidden_ml_tools": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateDiagFunc: enum.Validate[awstypes.MlTools](),
},
},
},
},
},
},
},
},
Expand Down Expand Up @@ -1379,6 +1560,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 +2024,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 +2113,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 @@ -2342,6 +2551,22 @@ func expanDefaultSpaceSettings(l []interface{}) *awstypes.DefaultSpaceSettings {
config.SecurityGroups = flex.ExpandStringValueSet(v)
}

if v, ok := m["jupyter_lab_app_settings"].([]interface{}); ok && len(v) > 0 {
config.JupyterLabAppSettings = expandDomainJupyterLabAppSettings(v)
}

if v, ok := m["space_storage_settings"].([]interface{}); ok && len(v) > 0 {
config.SpaceStorageSettings = expandDefaultSpaceStorageSettings(v)
}

if v, ok := m["custom_file_system_config"].([]interface{}); ok && len(v) > 0 {
config.CustomFileSystemConfigs = expandCustomFileSystemConfigs(v)
}

if v, ok := m["custom_posix_user_config"].([]interface{}); ok && len(v) > 0 {
config.CustomPosixUserConfig = expandCustomPOSIXUserConfig(v)
}

return config
}

Expand All @@ -2368,6 +2593,38 @@ func flattenDefaultSpaceSettings(config *awstypes.DefaultSpaceSettings) []map[st
m[names.AttrSecurityGroups] = flex.FlattenStringValueSet(config.SecurityGroups)
}

if config.JupyterLabAppSettings != nil {
m["jupyter_lab_app_settings"] = flattenDomainJupyterLabAppSettings(config.JupyterLabAppSettings)
}

if config.SpaceStorageSettings != nil {
m["space_storage_settings"] = flattenDefaultSpaceStorageSettings(config.SpaceStorageSettings)
}

if config.CustomFileSystemConfigs != nil {
m["custom_file_system_config"] = flattenCustomFileSystemConfigs(config.CustomFileSystemConfigs)
}

if config.CustomPosixUserConfig != nil {
m["custom_posix_user_config"] = flattenCustomPOSIXUserConfig(config.CustomPosixUserConfig)
}

if config.JupyterLabAppSettings != nil {
m["jupyter_lab_app_settings"] = flattenDomainJupyterLabAppSettings(config.JupyterLabAppSettings)
}

if config.SpaceStorageSettings != nil {
m["space_storage_settings"] = flattenDefaultSpaceStorageSettings(config.SpaceStorageSettings)
}

if config.CustomFileSystemConfigs != nil {
m["custom_file_system_config"] = flattenCustomFileSystemConfigs(config.CustomFileSystemConfigs)
}

if config.CustomPosixUserConfig != nil {
m["custom_posix_user_config"] = flattenCustomPOSIXUserConfig(config.CustomPosixUserConfig)
}

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

Expand Down Expand Up @@ -2508,3 +2765,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}
}
Loading

0 comments on commit 9297a9f

Please sign in to comment.