override fun run()

in jetbrains-core/src/software/aws/toolkits/jetbrains/services/clouddebug/actions/StartRemoteShellAction.kt [75:124]


                    override fun run(indicator: ProgressIndicator) {
                        if (cloudDebugExecutable !is ExecutableInstance.Executable) {
                            val error = (cloudDebugExecutable as? ExecutableInstance.BadExecutable)?.validationError ?: message("general.unknown_error")

                            runInEdt {
                                notifyError(message("cloud_debug.step.clouddebug.install.fail", error))
                            }
                            throw Exception("cloud debug executable not found")
                        }

                        val connectionManager = AwsConnectionManager.getInstance(project)
                        val credentials = connectionManager.activeCredentialProvider
                        val region = connectionManager.activeRegion

                        val description = CloudDebuggingResources.describeInstrumentedResource(credentials, region, cluster, service)
                        if (description == null || description.status != INSTRUMENTED_STATUS || description.taskRole.isEmpty()) {
                            runInEdt {
                                notifyError(message("cloud_debug.execution.failed.not_set_up"))
                            }
                            throw RuntimeException("Resource somehow became de-instrumented?")
                        }
                        val role = description.taskRole

                        val target = try {
                            runInstrument(project, cloudDebugExecutable, cluster, service, role).target
                        } catch (e: Exception) {
                            e.notifyError(title)
                            null
                        } ?: return

                        val cmdLine = buildBaseCmdLine(project, cloudDebugExecutable)
                            .withParameters("exec")
                            .withParameters("--target")
                            .withParameters(target)
                            /* TODO remove this when the cli conforms to the contract */
                            .withParameters("--selector")
                            .withParameters(containerName)
                            .withParameters("--tty")
                            .withParameters("/aws/cloud-debug/common/busybox", "sh", "-i")

                        val cmdList = cmdLine.getCommandLineList(null).toTypedArray()
                        val env = cmdLine.effectiveEnvironment
                        val ptyProcess = PtyProcess.exec(cmdList, env, null)
                        val process = CloudTerminalProcess(ptyProcess.outputStream, ptyProcess.inputStream)
                        val runner = CloudTerminalRunner(project, containerName, process)

                        runInEdt {
                            TerminalView.getInstance(project).createNewSession(runner, TerminalTabState().also { it.myTabName = containerName })
                        }
                    }