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

[Bug]: r_studio_package_manager_url missing in SageMaker domain API calls #38546

Closed
felipempda opened this issue Jul 25, 2024 · 5 comments · Fixed by #38547
Closed

[Bug]: r_studio_package_manager_url missing in SageMaker domain API calls #38546

felipempda opened this issue Jul 25, 2024 · 5 comments · Fixed by #38547
Labels
bug Addresses a defect in current functionality. service/sagemaker Issues and PRs that pertain to the sagemaker service.
Milestone

Comments

@felipempda
Copy link
Contributor

felipempda commented Jul 25, 2024

Terraform Core Version

1.9.3

AWS Provider Version

5.6.0

Affected Resource(s)

aws_sagemaker_domain

Expected Behavior

r_studio_package_manager_url should be used during SageMaker domain creation/update when set

For example, the following code shows it in the plan:

resource "aws_sagemaker_domain" "rstudio" {
  domain_name = "test"
  auth_mode   = "IAM"
  vpc_id      = "vpc-vpc-xxxxxxxxxxxx"
  subnet_ids  = ["subnet-yyyyyyyyyyy"]

  domain_settings {

    r_studio_server_pro_domain_settings {
      r_studio_connect_url         = "https://connect.domain.com"
      r_studio_package_manager_url = "https://package.domain.com"
      domain_execution_role_arn    = "arn:aws:iam::zzzzzzzzzzzzzz:role/sagmakerDomainRole"
      default_resource_spec {
        instance_type                 = "system" 
        sagemaker_image_arn           = "arn:aws:sagemaker:ca-central-1:310906938811:image/rstudio-workbench-2023.03"
       }
    }
  }

  default_user_settings {
    execution_role = "arn:aws:iam::zzzzzzzzzzzzzz:role/sagmakerDomainRole"

  }

  retention_policy {
    home_efs_file_system = "Delete"
  }
}

And here it's the log after applying it:

# aws_sagemaker_domain.rstudio will be created
  + resource "aws_sagemaker_domain" "rstudio" {
      + app_network_access_type                        = "PublicInternetOnly"
      + arn                                            = (known after apply)
      + auth_mode                                      = "IAM"
      + domain_name                                    = "test"
      + home_efs_file_system_id                        = (known after apply)
      + id                                             = (known after apply)
      + security_group_id_for_domain_boundary          = (known after apply)
      + single_sign_on_application_arn                 = (known after apply)
      + single_sign_on_managed_application_instance_id = (known after apply)
      + subnet_ids                                     = [
          + "subnet-yyyyyyyyyyy",
        ]
      + tags_all                                       = (known after apply)
      + url                                            = (known after apply)
      + vpc_id                                         = "vpc-vpc-xxxxxxxxxxxx"

      + default_user_settings {
          + default_landing_uri = (known after apply)
          + execution_role      = "arn:aws:iam::zzzzzzzzzzzzzz:role/sagmakerDomainRole"
          + studio_web_portal   = (known after apply)
        }

      + domain_settings {
          + r_studio_server_pro_domain_settings {
              + domain_execution_role_arn    = "arn:aws:iam::zzzzzzzzzzzzzz:role/sagmakerDomainRole"
              + r_studio_connect_url         = "https://connect.domain.com"
              + r_studio_package_manager_url = "https://package.domain.com"

              + default_resource_spec {
                  + instance_type       = "system"
                  + sagemaker_image_arn = "arn:aws:sagemaker:ca-central-1:310906938811:image/rstudio-workbench-2023.03"
                }
            }
        }

      + retention_policy {
          + home_efs_file_system = "Delete"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
aws_sagemaker_domain.rstudio: Creating...
aws_sagemaker_domain.rstudio: Still creating... [10s elapsed]
...
aws_sagemaker_domain.rstudio: Still creating... [4m20s elapsed]
aws_sagemaker_domain.rstudio: Still creating... [4m30s elapsed]
aws_sagemaker_domain.rstudio: Creation complete after 4m35s [id=d-sauslritkv2i]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Actual Behavior

However after creation we see this attribute missing on AWS Console or when describing the sage maker domain. On future terraform plans it shows as pending update:

aws_sagemaker_domain.rstudio: Refreshing state... [id=d-sauslritkv2i]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_sagemaker_domain.rstudio will be updated in-place
  ~ resource "aws_sagemaker_domain" "rstudio" {
        id                                             = "d-sauslritkv2i"
        tags                                           = {}
        # (14 unchanged attributes hidden)

      ~ domain_settings {
            # (2 unchanged attributes hidden)

          ~ r_studio_server_pro_domain_settings {
              + r_studio_package_manager_url = "https://package.domain.com"
                # (2 unchanged attributes hidden)

                # (1 unchanged block hidden)
            }
        }

        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
aws_sagemaker_domain.rstudio: Modifying... [id=d-sauslritkv2i]
aws_sagemaker_domain.rstudio: Modifications complete after 3s [id=d-sauslritkv2i]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

data "aws_partition" "current" {}

resource "aws_iam_role" "test" {
  name               = "sagemaker-domain-role"
  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"
}

resource "aws_sagemaker_domain" "rstudio" {
  domain_name = "test"
  auth_mode   = "IAM"
  vpc_id       = "vpc-vpc-xxxxxxxxxxxx" # PLEASE ADAPT
  subnet_ids  = ["subnet-yyyyyyyyyyy"] # PLEASE ADAPT

  domain_settings {

    r_studio_server_pro_domain_settings {
      r_studio_connect_url         = "https://connect.domain.com"
      r_studio_package_manager_url = "https://package.domain.com"
      domain_execution_role_arn    = aws_iam_role.test.arn
      default_resource_spec {
        instance_type                 = "system" 
       # default image: https://docs.aws.amazon.com/sagemaker/latest/dg/rstudio-version.html
       #  sagemaker_image_arn           = "arn:aws:sagemaker:ca-central-1:310906938811:image/rstudio-workbench-2023.03"
       }
    }
  }

  default_user_settings {
    execution_role = aws_iam_role.test.arn

  }

  retention_policy {
    home_efs_file_system = "Delete"
  }


  lifecycle {
    ignore_changes = [ 
        domain_settings[0].r_studio_server_pro_domain_settings[0].default_resource_spec[0]
     ]
  }
}

Steps to Reproduce

  1. Make sure you have the right license from Posit to use this RStudio: https://docs.aws.amazon.com/sagemaker/latest/dg/rstudio-license.html
  2. Create SageMaker domain with r_studio_package_manager_url
  3. Verify that Sagemaker Domain it's not present in domain when describing it:
    aws sagemaker describe-domain --domain-id d-xxxxxxx
  4. Do another terraform plan and see it's pending
    terraform plan
  5. Even after second terraform apply the attribute is still missing

Debug Output

No response

Panic Output

No response

Important Factoids

When tracing the API calls from AWS see. that this attribute It's ignored during API calls
CloudTrail trace shows that the attribute wasn't received on AWS side:

{
    "eventVersion": "1.09",
    "userIdentity": {
        ...
    },
    "eventTime": "2024-07-25T22:34:58Z",
    "eventSource": "sagemaker.amazonaws.com",
    "eventName": "CreateDomain",
    "awsRegion": "ca-central-1",
    ...
    "requestParameters": {
        "domainName": "test",
        "authMode": "IAM",
        "defaultUserSettings": {
            "executionRole": "arn:aws:iam::zzzzzzzzzzzzzz:role/sagmakerDomainRole"
        },
        "domainSettings": {
            "rStudioServerProDomainSettings": {
                "domainExecutionRoleArn": "arn:aws:iam::zzzzzzzzzzzzzz:role/sagmakerDomainRole",
                "rStudioConnectUrl": "https://connect.domain.com",
                "defaultResourceSpec": {
                    "sageMakerImageArn": "arn:aws:sagemaker:ca-central-1:310906938811:image/rstudio-workbench-2023.03",
                    "instanceType": "system"
                }
            }
        },
        "subnetIds": [
            "subnet-yyyyyyyyyyy"
        ],
        "vpcId": "vpc-vpc-xxxxxxxxxxxx",
        "tags": [],
        "appNetworkAccessType": "PublicInternetOnly"
    },
    "responseElements": {
        "domainArn": "arn:aws:sagemaker:ca-central-1:zzzzzzzzzzzzzz:domain/d-sauslritkv2i",
        "url": "https://d-sauslritkv2i.studio.ca-central-1.sagemaker.aws"
    },
   ....
}

We only see rStudioConnectUrl attribute but no rStudioPackageManagerUrl
The same is valid for UpdateDomain API call.

References

No response

Would you like to implement a fix?

Yes

@felipempda felipempda added the bug Addresses a defect in current functionality. label Jul 25, 2024
@github-actions github-actions bot added the service/sagemaker Issues and PRs that pertain to the sagemaker service. label Jul 25, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 25, 2024
@felipempda
Copy link
Contributor Author

felipempda commented Jul 25, 2024

I've found the issue, it's a simple typo!

I've created a PR for this with an acceptance test.
Thanks a lot!

@github-actions github-actions bot added the service/iam Issues and PRs that pertain to the iam service. label Jul 26, 2024
@justinretzolk justinretzolk removed service/iam Issues and PRs that pertain to the iam service. needs-triage Waiting for first response or review from a maintainer. labels Aug 1, 2024
Copy link

github-actions bot commented Aug 1, 2024

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.61.0 milestone Aug 1, 2024
Copy link

github-actions bot commented Aug 2, 2024

This functionality has been released in v5.61.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

github-actions bot commented Sep 1, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/sagemaker Issues and PRs that pertain to the sagemaker service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants