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

fix: typo r_studio_package_manager_url in sagemaker domain #38547

Merged
3 changes: 3 additions & 0 deletions .changelog/38547.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_sagemaker_domain: Properly send `domain_settings.r_studio_server_pro_domain_settings.r_studio_package_manager_url` argument on create
```
2 changes: 1 addition & 1 deletion internal/service/sagemaker/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ func expandRStudioServerProDomainSettings(l []interface{}) *sagemaker.RStudioSer
config.RStudioConnectUrl = aws.String(v)
}

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

Expand Down
120 changes: 120 additions & 0 deletions internal/service/sagemaker/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,38 @@ func testAccDomain_rStudioServerProAppSettings(t *testing.T) {
})
}

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

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.SageMakerServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckDomainDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccDomainConfig_rStudioServerProDomainSettings(rName, "https://connect.domain.com", "https://package.domain.com"),
Check: resource.ComposeTestCheckFunc(
testAccCheckDomainExists(ctx, resourceName, &domain),
resource.TestCheckResourceAttr(resourceName, "domain_settings.#", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, "domain_settings.0.r_studio_server_pro_domain_settings.#", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, "domain_settings.0.r_studio_server_pro_domain_settings.0.r_studio_connect_url", "https://connect.domain.com"),
resource.TestCheckResourceAttr(resourceName, "domain_settings.0.r_studio_server_pro_domain_settings.0.r_studio_package_manager_url", "https://package.domain.com"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"retention_policy"},
},
},
})
}

func testAccDomain_kernelGatewayAppSettings(t *testing.T) {
ctx := acctest.Context(t)
var domain sagemaker.DescribeDomainOutput
Expand Down Expand Up @@ -1876,6 +1908,94 @@ resource "aws_sagemaker_domain" "test" {
`, rName, state))
}

func testAccDomainConfig_rStudioServerProDomainSettings(rName, connectURL string, packageURL string) string {
return acctest.ConfigCompose(testAccDomainConfig_baseWithLicense(rName), fmt.Sprintf(`
resource "aws_sagemaker_domain" "test" {
domain_name = %[1]q
auth_mode = "IAM"
vpc_id = aws_vpc.test.id
subnet_ids = aws_subnet.test[*].id

domain_settings {

r_studio_server_pro_domain_settings {
r_studio_connect_url = %[2]q
r_studio_package_manager_url = %[3]q
domain_execution_role_arn = aws_iam_role.test.arn
default_resource_spec {
instance_type = "system"
}
}
}

default_user_settings {
execution_role = aws_iam_role.test.arn
}

retention_policy {
home_efs_file_system = "Delete"
}

# ignoring default image
# it would be too hard to create the logic to find the default Rstudio image: https://docs.aws.amazon.com/sagemaker/latest/dg/rstudio-version.html
# it changes for every region
lifecycle {
ignore_changes = [
domain_settings[0].r_studio_server_pro_domain_settings[0].default_resource_spec[0]
]
}
}
`, rName, connectURL, packageURL))
}

func testAccDomainConfig_baseWithLicense(rName string) string {
return acctest.ConfigCompose(acctest.ConfigVPCWithSubnets(rName, 1), fmt.Sprintf(`
data "aws_partition" "current" {}

resource "aws_iam_role" "test" {
name = %[1]q
path = "/"
assume_role_policy = data.aws_iam_policy_document.test.json
inline_policy {
name = "GetLicense"
policy = data.aws_iam_policy_document.license.json
}
}

data "aws_iam_policy_document" "test" {
statement {
actions = ["sts:AssumeRole"]

principals {
type = "Service"
identifiers = ["sagemaker.${data.aws_partition.current.dns_suffix}"]
}
}
}

# needed for RStudio
data "aws_iam_policy_document" "license" {
statement {
sid = "ReadLicense"
effect = "Allow"
actions = [
"license-manager:ExtendLicenseConsumption",
"license-manager:ListReceivedLicenses",
"license-manager:GetLicense",
"license-manager:CheckoutLicense",
"license-manager:CheckInLicense",
]
resources = ["*"]
}
}

resource "aws_iam_role_policy_attachment" "test" {
role = aws_iam_role.test.name
policy_arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonSageMakerFullAccess"
}
`, rName))
}

func testAccDomainConfig_codeEditorAppSettings(rName string) string {
return acctest.ConfigCompose(testAccDomainConfig_base(rName), fmt.Sprintf(`
resource "aws_sagemaker_domain" "test" {
Expand Down
2 changes: 2 additions & 0 deletions internal/service/sagemaker/sagemaker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func testAccErrorCheckSkip(t *testing.T) resource.ErrorCheckFunc {
return acctest.ErrorCheckSkipMessagesContaining(t,
"is not supported in region",
"is not supported for the chosen region",
"No available licenses were found",
)
}

Expand Down Expand Up @@ -66,6 +67,7 @@ func TestAccSageMaker_serial(t *testing.T) {
"domainSettings": testAccDomain_domainSettings,
"rSessionAppSettings": testAccDomain_rSessionAppSettings,
"rStudioServerProAppSettings": testAccDomain_rStudioServerProAppSettings,
"rStudioServerProDomainSettings": testAccDomain_rStudioServerProDomainSettings,
"spaceSettingsKernelGatewayAppSettings": testAccDomain_spaceSettingsKernelGatewayAppSettings,
"code": testAccDomain_jupyterServerAppSettings_code,
"efs": testAccDomain_efs,
Expand Down
Loading