Skip to content

Commit c65ece0

Browse files
authored
Merge pull request #42144 from DrFaust92/domain-remove-efs
r/sagemaker_domain - allow removing custom file config
2 parents 9fe2bfc + 3143b64 commit c65ece0

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

.changelog/42144.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:bug
2+
resource/aws_sagemaker_domain: Allow `default_user_settings.custom_file_system_config` and `default_space_settings.custom_file_system_config` to be removed on Update
3+
```
4+
5+
```release-note:bug
6+
resource/aws_sagemaker_user_profile: Allow `user_settings.custom_file_system_config` to be removed on Update
7+
```

internal/service/sagemaker/domain.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,8 +1853,12 @@ func expandUserSettings(l []any) *awstypes.UserSettings {
18531853
config.CodeEditorAppSettings = expandDomainCodeEditorAppSettings(v)
18541854
}
18551855

1856-
if v, ok := m["custom_file_system_config"].([]any); ok && len(v) > 0 {
1857-
config.CustomFileSystemConfigs = expandCustomFileSystemConfigs(v)
1856+
if v, ok := m["custom_file_system_config"].([]any); ok {
1857+
if len(v) > 0 {
1858+
config.CustomFileSystemConfigs = expandCustomFileSystemConfigs(v)
1859+
} else {
1860+
config.CustomFileSystemConfigs = []awstypes.CustomFileSystemConfig{}
1861+
}
18581862
}
18591863

18601864
if v, ok := m["custom_posix_user_config"].([]any); ok && len(v) > 0 {
@@ -3114,8 +3118,12 @@ func expanDefaultSpaceSettings(l []any) *awstypes.DefaultSpaceSettings {
31143118
config.SpaceStorageSettings = expandDefaultSpaceStorageSettings(v)
31153119
}
31163120

3117-
if v, ok := m["custom_file_system_config"].([]any); ok && len(v) > 0 {
3118-
config.CustomFileSystemConfigs = expandCustomFileSystemConfigs(v)
3121+
if v, ok := m["custom_file_system_config"].([]any); ok {
3122+
if len(v) > 0 {
3123+
config.CustomFileSystemConfigs = expandCustomFileSystemConfigs(v)
3124+
} else {
3125+
config.CustomFileSystemConfigs = []awstypes.CustomFileSystemConfig{}
3126+
}
31193127
}
31203128

31213129
if v, ok := m["custom_posix_user_config"].([]any); ok && len(v) > 0 {

internal/service/sagemaker/domain_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,15 @@ func testAccDomain_efs(t *testing.T) {
14511451
ImportStateVerify: true,
14521452
ImportStateVerifyIgnore: []string{"retention_policy"},
14531453
},
1454+
{
1455+
Config: testAccDomainConfig_efsRemoved(rName),
1456+
Check: resource.ComposeTestCheckFunc(
1457+
testAccCheckDomainExists(ctx, resourceName, &domain),
1458+
resource.TestCheckResourceAttr(resourceName, names.AttrDomainName, rName),
1459+
resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.execution_role", "aws_iam_role.test", names.AttrARN),
1460+
resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.custom_file_system_config.#", "0"),
1461+
),
1462+
},
14541463
},
14551464
})
14561465
}
@@ -3053,6 +3062,36 @@ resource "aws_sagemaker_domain" "test" {
30533062
`, rName))
30543063
}
30553064

3065+
func testAccDomainConfig_efsRemoved(rName string) string {
3066+
return acctest.ConfigCompose(testAccDomainConfig_base(rName), fmt.Sprintf(`
3067+
resource "aws_efs_file_system" "test" {
3068+
tags = {
3069+
Name = %[1]q
3070+
}
3071+
}
3072+
3073+
resource "aws_efs_mount_target" "test" {
3074+
file_system_id = aws_efs_file_system.test.id
3075+
subnet_id = aws_subnet.test[0].id
3076+
}
3077+
3078+
resource "aws_sagemaker_domain" "test" {
3079+
domain_name = %[1]q
3080+
auth_mode = "IAM"
3081+
vpc_id = aws_vpc.test.id
3082+
subnet_ids = aws_subnet.test[*].id
3083+
3084+
default_user_settings {
3085+
execution_role = aws_iam_role.test.arn
3086+
}
3087+
3088+
retention_policy {
3089+
home_efs_file_system = "Delete"
3090+
}
3091+
}
3092+
`, rName))
3093+
}
3094+
30563095
func testAccDomainConfig_spaceStorageSettings(rName string) string {
30573096
return acctest.ConfigCompose(testAccDomainConfig_base(rName), fmt.Sprintf(`
30583097
resource "aws_sagemaker_domain" "test" {

0 commit comments

Comments
 (0)