Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/sagemaker_domain/user_profile - add additional canvas app args #34265

Merged
merged 8 commits into from
Nov 8, 2023
Merged
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
19 changes: 19 additions & 0 deletions .changelog/34265.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```release-note:enhancement
resource/aws_sagemaker_domain: Add `default_user_settings.canvas_app_settings.direct_deploy_settings`, `default_user_settings.canvas_app_settings.identity_provider_oauth_settings` and `default_user_settings.canvas_app_settings.kendra_settings` arguments
```

```release-note:enhancement
resource/aws_sagemaker_user_profile: Add `default_user_settings.canvas_app_settings.direct_deploy_settings`, `default_user_settings.canvas_app_settings.identity_provider_oauth_settings` and `default_user_settings.canvas_app_settings.kendra_settings` arguments
```

```release-note:enhancement
resource/aws_sagemaker_domain: Change `default_space_settings.kernel_gateway_app_settings.custom_image`, `default_user_settings.kernel_gateway_app_settings.custom_image` and `default_user_settings.r_session_app_settings.custom_image` `MaxItems` from `30` to `200`
```

```release-note:enhancement
resource/aws_sagemaker_space: Change `space_settings.kernel_gateway_app_settings.custom_image` `MaxItems` from `30` to `200`
```

```release-note:bug
resource/aws_sagemaker_domain: Fix updating `default_space_settings.r_studio_server_pro_app_settings.access_status` from `ENABLED` to `DISABLED`
```
178 changes: 172 additions & 6 deletions internal/service/sagemaker/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func ResourceDomain() *schema.Resource {
"custom_image": {
Type: schema.TypeList,
Optional: true,
MaxItems: 30,
MaxItems: 200,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"app_image_config_name": {
Expand Down Expand Up @@ -225,6 +225,58 @@ func ResourceDomain() *schema.Resource {
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"direct_deploy_settings": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"status": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(sagemaker.FeatureStatus_Values(), false),
},
},
},
},
"identity_provider_oauth_settings": {
Type: schema.TypeList,
Optional: true,
MaxItems: 20,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"data_source_name": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(sagemaker.DataSourceName_Values(), false),
},
"secret_arn": {
Type: schema.TypeString,
Required: true,
ValidateFunc: verify.ValidARN,
},
"status": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(sagemaker.FeatureStatus_Values(), false),
},
},
},
},
"kendra_settings": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"status": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(sagemaker.FeatureStatus_Values(), false),
},
},
},
},
"model_register_settings": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -393,7 +445,7 @@ func ResourceDomain() *schema.Resource {
"custom_image": {
Type: schema.TypeList,
Optional: true,
MaxItems: 30,
MaxItems: 200,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"app_image_config_name": {
Expand Down Expand Up @@ -478,7 +530,7 @@ func ResourceDomain() *schema.Resource {
"custom_image": {
Type: schema.TypeList,
Optional: true,
MaxItems: 30,
MaxItems: 200,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"app_image_config_name": {
Expand Down Expand Up @@ -1003,10 +1055,12 @@ func expandRStudioServerProAppSettings(l []interface{}) *sagemaker.RStudioServer

if v, ok := m["access_status"].(string); ok && v != "" {
config.AccessStatus = aws.String(v)
}

if v, ok := m["user_group"].(string); ok && v != "" {
config.UserGroup = aws.String(v)
if v == sagemaker.RStudioServerProAccessStatusEnabled {
if g, ok := m["user_group"].(string); ok && g != "" {
config.UserGroup = aws.String(g)
}
}
}

return config
Expand Down Expand Up @@ -1154,6 +1208,9 @@ func expandCanvasAppSettings(l []interface{}) *sagemaker.CanvasAppSettings {
m := l[0].(map[string]interface{})

config := &sagemaker.CanvasAppSettings{
IdentityProviderOAuthSettings: expandIdentityProviderOAuthSettings(m["identity_provider_oauth_settings"].([]interface{})),
DirectDeploySettings: expandDirectDeploySettings(m["direct_deploy_settings"].([]interface{})),
KendraSettings: expandKendraSettings(m["kendra_settings"].([]interface{})),
ModelRegisterSettings: expandModelRegisterSettings(m["model_register_settings"].([]interface{})),
TimeSeriesForecastingSettings: expandTimeSeriesForecastingSettings(m["time_series_forecasting_settings"].([]interface{})),
WorkspaceSettings: expandWorkspaceSettings(m["workspace_settings"].([]interface{})),
Expand All @@ -1162,6 +1219,64 @@ func expandCanvasAppSettings(l []interface{}) *sagemaker.CanvasAppSettings {
return config
}

func expandKendraSettings(l []interface{}) *sagemaker.KendraSettings {
if len(l) == 0 || l[0] == nil {
return nil
}

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

config := &sagemaker.KendraSettings{}

if v, ok := m["status"].(string); ok && v != "" {
config.Status = aws.String(v)
}

return config
}

func expandDirectDeploySettings(l []interface{}) *sagemaker.DirectDeploySettings {
if len(l) == 0 || l[0] == nil {
return nil
}

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

config := &sagemaker.DirectDeploySettings{}

if v, ok := m["status"].(string); ok && v != "" {
config.Status = aws.String(v)
}

return config
}

func expandIdentityProviderOAuthSettings(l []interface{}) []*sagemaker.IdentityProviderOAuthSetting {
providers := make([]*sagemaker.IdentityProviderOAuthSetting, 0, len(l))

for _, eRaw := range l {
data := eRaw.(map[string]interface{})

provider := &sagemaker.IdentityProviderOAuthSetting{}

if v, ok := data["data_source_name"].(string); ok && v != "" {
provider.DataSourceName = aws.String(v)
}

if v, ok := data["secret_arn"].(string); ok && v != "" {
provider.SecretArn = aws.String(v)
}

if v, ok := data["status"].(string); ok && v != "" {
provider.Status = aws.String(v)
}

providers = append(providers, provider)
}

return providers
}

func expandModelRegisterSettings(l []interface{}) *sagemaker.ModelRegisterSettings {
if len(l) == 0 || l[0] == nil {
return nil
Expand Down Expand Up @@ -1435,6 +1550,9 @@ func flattenCanvasAppSettings(config *sagemaker.CanvasAppSettings) []map[string]
}

m := map[string]interface{}{
"direct_deploy_settings": flattenDirectDeploySettings(config.DirectDeploySettings),
"identity_provider_oauth_settings": flattenIdentityProviderOAuthSettings(config.IdentityProviderOAuthSettings),
"kendra_settings": flattenKendraSettings(config.KendraSettings),
"time_series_forecasting_settings": flattenTimeSeriesForecastingSettings(config.TimeSeriesForecastingSettings),
"model_register_settings": flattenModelRegisterSettings(config.ModelRegisterSettings),
"workspace_settings": flattenWorkspaceSettings(config.WorkspaceSettings),
Expand All @@ -1443,6 +1561,54 @@ func flattenCanvasAppSettings(config *sagemaker.CanvasAppSettings) []map[string]
return []map[string]interface{}{m}
}

func flattenDirectDeploySettings(config *sagemaker.DirectDeploySettings) []map[string]interface{} {
if config == nil {
return []map[string]interface{}{}
}

m := map[string]interface{}{
"status": aws.StringValue(config.Status),
}

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

func flattenKendraSettings(config *sagemaker.KendraSettings) []map[string]interface{} {
if config == nil {
return []map[string]interface{}{}
}

m := map[string]interface{}{
"status": aws.StringValue(config.Status),
}

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

func flattenIdentityProviderOAuthSettings(config []*sagemaker.IdentityProviderOAuthSetting) []map[string]interface{} {
providers := make([]map[string]interface{}, 0, len(config))

for _, raw := range config {
provider := make(map[string]interface{})

if raw.DataSourceName != nil {
provider["data_source_name"] = aws.StringValue(raw.DataSourceName)
}

if raw.SecretArn != nil {
provider["secret_arn"] = aws.StringValue(raw.SecretArn)
}

if raw.Status != nil {
provider["status"] = aws.StringValue(raw.Status)
}

providers = append(providers, provider)
}

return providers
}

func flattenModelRegisterSettings(config *sagemaker.ModelRegisterSettings) []map[string]interface{} {
if config == nil {
return []map[string]interface{}{}
Expand Down
Loading
Loading