hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.81k stars 9.16k forks source link

[Bug]: aws_sagemaker_domain breaks default_space/user settings args everytime #39894

Open barra51 opened 1 day ago

barra51 commented 1 day ago

Terraform Core Version

1.9.2

AWS Provider Version

5.73.0

Affected Resource(s)

Expected Behavior

  1. Defining a simple default_space_settings or default_user_settings using the aws_sagemaker_domain for apps like JupyterLab should ignore optional values and not force them on every terraform run/apply. This causes to use not desired values/omit the default ones.

Actual Behavior

Applying the following code under aws_sagemaker_domain:

      jupyter_lab_app_settings {
        code_repository {
          repository_url = local.github_repo
      }
          default_resource_spec {
            #instance_type                 = "ml.g4dn.xlarge"
            lifecycle_config_arn          = aws_sagemaker_studio_lifecycle_config.startup.arn
          }
            lifecycle_config_arns = [
            aws_sagemaker_studio_lifecycle_config.startup.arn
            ]
        }

And subsequent runs after applied produces terraform to change:

 ~ space_settings {    
  ~  jupyter_lab_app_settings { 
    ~   default_resource_spec { 
      ~    sagemaker_image_arn :    "arn:aws:sagemaker:us-east-1:885854791233:image/sagemaker-distribution-cpu" -> ""
        ~  sagemaker_image_version_alias: "2.0.0"  -> ""

Relevant Error/Panic Output Snippet

Error: updating SageMaker Space: operation error SageMaker: UpdateSpace, https response error StatusCode: 400, RequestID: b09d1b8f-33ae-4bc3-aa83-e8aeee0a65ae, api error ValidationException: Updating AppType for Space is not supported.

Terraform Configuration Files

resource "aws_sagemaker_domain" "this" {
  domain_name             = "mydomain"
  auth_mode               = "IAM"
  vpc_id                  = data.aws_vpc.id
  app_network_access_type = "VpcOnly"
  subnet_ids              = local.subnets
  tags                    = local.tags
  kms_key_id              = aws_kms_key.sagemaker_kms_key.key_id

  domain_settings {
    security_group_ids = local.security_groups
    docker_settings {
      enable_docker_access = "ENABLED"
    }
  }

  default_space_settings {
    execution_role  = "arn:custom"
    security_groups = local.security_groups

    jupyter_lab_app_settings {
      code_repository {
        repository_url = local.github_repo
      }
      default_resource_spec {
        instance_type                 = "ml.g4dn.xlarge"
        lifecycle_config_arn          = aws_sagemaker_studio_lifecycle_config.startup.arn
        # If I set these two, then no errors on the plan. . .
        #sagemaker_image_arn           = null
        #sagemaker_image_version_alias = null
        }
          lifecycle_config_arns = [
            aws_sagemaker_studio_lifecycle_config.startup.arn
        ]
     }
}

Steps to Reproduce

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 day ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue