diff --git a/acceptance/bundle/config-remote-sync/job_run_as/databricks.yml.tmpl b/acceptance/bundle/config-remote-sync/job_run_as/databricks.yml.tmpl index c655e36c9c2..cf5653eeec2 100644 --- a/acceptance/bundle/config-remote-sync/job_run_as/databricks.yml.tmpl +++ b/acceptance/bundle/config-remote-sync/job_run_as/databricks.yml.tmpl @@ -3,6 +3,23 @@ bundle: resources: jobs: + # run_as is not set in config, so the backend defaults it to the deployer. + no_run_as: + name: no-run-as-$UNIQUE_NAME + tasks: + - task_key: main + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/notebook + + # The terraform provider pins run_as to the job's identity on every update, + # so a remote run_as that names the creator is a default, not an edit. + no_run_as_creator: + name: no-run-as-creator-$UNIQUE_NAME + tasks: + - task_key: main + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/notebook + user_to_user: name: user-to-user-$UNIQUE_NAME run_as: @@ -12,6 +29,7 @@ resources: notebook_task: notebook_path: /Users/{{workspace_user_name}}/notebook + # The creator default only applies when the config leaves run_as unset. user_to_creator: name: user-to-creator-$UNIQUE_NAME run_as: diff --git a/acceptance/bundle/config-remote-sync/job_run_as/output.txt b/acceptance/bundle/config-remote-sync/job_run_as/output.txt index 424cac25200..6080e872493 100644 --- a/acceptance/bundle/config-remote-sync/job_run_as/output.txt +++ b/acceptance/bundle/config-remote-sync/job_run_as/output.txt @@ -1,18 +1,23 @@ >>> [CLI] bundle deploy Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default/files... +Created jobs.no_run_as +Created jobs.no_run_as_creator Created jobs.user_to_creator Created jobs.user_to_sp Created jobs.user_to_user Files: 2 uploaded, 0 deleted -Resources: 3 created, 0 changed, 0 deleted, 0 unchanged +Resources: 5 created, 0 changed, 0 deleted, 0 unchanged === Change run_as remotely === Detect and save changes >>> [CLI] bundle config-remote-sync --save -Detected changes in 3 resource(s): +Detected changes in 4 resource(s): + +Resource: resources.jobs.no_run_as + run_as: add Resource: resources.jobs.user_to_creator run_as.user_name: replace @@ -29,21 +34,28 @@ Resource: resources.jobs.user_to_user >>> diff.py databricks.yml.backup databricks.yml --- databricks.yml.backup +++ databricks.yml -@@ -7,5 +7,5 @@ +@@ -12,4 +12,6 @@ + notebook_path: /Users/{{workspace_user_name}}/notebook + ++ run_as: ++ service_principal_name: [UUID] + # The terraform provider pins run_as to the job's identity on every update, + # so a remote run_as that names the creator is a default, not an edit. +@@ -24,5 +26,5 @@ name: user-to-user-[UNIQUE_NAME] run_as: - user_name: first-user@example.com + user_name: second-user@example.com tasks: - task_key: main -@@ -16,5 +16,5 @@ +@@ -34,5 +36,5 @@ name: user-to-creator-[UNIQUE_NAME] run_as: - user_name: first-user@example.com + user_name: [USERNAME] tasks: - task_key: main -@@ -25,5 +25,5 @@ +@@ -43,5 +45,5 @@ name: user-to-sp-[UNIQUE_NAME] run_as: - user_name: first-user@example.com @@ -60,14 +72,16 @@ No changes detected. === Plan after sync >>> [CLI] bundle plan -Plan: 0 to add, 0 to change, 0 to delete, 3 unchanged +Plan: 0 to add, 0 to change, 0 to delete, 5 unchanged >>> [CLI] bundle destroy --auto-approve The following resources will be deleted: + delete resources.jobs.no_run_as + delete resources.jobs.no_run_as_creator delete resources.jobs.user_to_creator delete resources.jobs.user_to_sp delete resources.jobs.user_to_user All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default -Destroy: 3 deleted +Destroy: 5 deleted diff --git a/acceptance/bundle/config-remote-sync/job_run_as/script b/acceptance/bundle/config-remote-sync/job_run_as/script index 5beb36780a5..ed68fef3637 100644 --- a/acceptance/bundle/config-remote-sync/job_run_as/script +++ b/acceptance/bundle/config-remote-sync/job_run_as/script @@ -8,6 +8,12 @@ trap cleanup EXIT trace $CLI bundle deploy title "Change run_as remotely" +edit_resource.py jobs "$(read_id.py no_run_as)" <<'PY' +r["run_as"] = {"service_principal_name": "11111111-2222-3333-4444-555555555555"} +PY +edit_resource.py jobs "$(read_id.py no_run_as_creator)" <