UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

346 lines • 13.1 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.NotebookExecution = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * 'An instance of a notebook Execution' * * To get more information about NotebookExecution, see: * * * [API documentation](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.notebookExecutionJobs) * * How-to Guides * * [Schedule a notebook run](https://cloud.google.com/colab/docs/schedule-notebook-run) * * ## Example Usage * * ### Colab Notebook Execution Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as std from "@pulumi/std"; * * const myRuntimeTemplate = new gcp.colab.RuntimeTemplate("my_runtime_template", { * name: "runtime-template-name", * displayName: "Runtime template", * location: "us-central1", * machineSpec: { * machineType: "e2-standard-4", * }, * networkSpec: { * enableInternetAccess: true, * }, * }); * const outputBucket = new gcp.storage.Bucket("output_bucket", { * name: "my_bucket", * location: "US", * forceDestroy: true, * uniformBucketLevelAccess: true, * }); * const notebook_execution = new gcp.colab.NotebookExecution("notebook-execution", { * displayName: "Notebook execution basic", * location: "us-central1", * directNotebookSource: { * content: std.base64encode({ * input: ` { * "cells": [ * { * "cell_type": "code", * "execution_count": null, * "metadata": {}, * "outputs": [], * "source": [ * "print(\\"Hello, World!\\")" * ] * } * ], * "metadata": { * "kernelspec": { * "display_name": "Python 3", * "language": "python", * "name": "python3" * }, * "language_info": { * "codemirror_mode": { * "name": "ipython", * "version": 3 * }, * "file_extension": ".py", * "mimetype": "text/x-python", * "name": "python", * "nbconvert_exporter": "python", * "pygments_lexer": "ipython3", * "version": "3.8.5" * } * }, * "nbformat": 4, * "nbformat_minor": 4 * } * `, * }).then(invoke => invoke.result), * }, * notebookRuntimeTemplateResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}`, * gcsOutputUri: pulumi.interpolate`gs://${outputBucket.name}`, * serviceAccount: "my@service-account.com", * }, { * dependsOn: [ * myRuntimeTemplate, * outputBucket, * ], * }); * ``` * ### Colab Notebook Execution Full * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myRuntimeTemplate = new gcp.colab.RuntimeTemplate("my_runtime_template", { * name: "runtime-template-name", * displayName: "Runtime template", * location: "us-central1", * machineSpec: { * machineType: "e2-standard-4", * }, * networkSpec: { * enableInternetAccess: true, * }, * }); * const outputBucket = new gcp.storage.Bucket("output_bucket", { * name: "my_bucket", * location: "US", * forceDestroy: true, * uniformBucketLevelAccess: true, * }); * const notebook = new gcp.storage.BucketObject("notebook", { * name: "hello_world.ipynb", * bucket: outputBucket.name, * content: ` { * "cells": [ * { * "cell_type": "code", * "execution_count": null, * "metadata": {}, * "outputs": [], * "source": [ * "print(\\"Hello, World!\\")" * ] * } * ], * "metadata": { * "kernelspec": { * "display_name": "Python 3", * "language": "python", * "name": "python3" * }, * "language_info": { * "codemirror_mode": { * "name": "ipython", * "version": 3 * }, * "file_extension": ".py", * "mimetype": "text/x-python", * "name": "python", * "nbconvert_exporter": "python", * "pygments_lexer": "ipython3", * "version": "3.8.5" * } * }, * "nbformat": 4, * "nbformat_minor": 4 * } * `, * }); * const notebook_execution = new gcp.colab.NotebookExecution("notebook-execution", { * notebookExecutionJobId: "colab-notebook-execution", * displayName: "Notebook execution full", * location: "us-central1", * executionTimeout: "86400s", * gcsNotebookSource: { * uri: pulumi.interpolate`gs://${notebook.bucket}/${notebook.name}`, * generation: notebook.generation, * }, * serviceAccount: "my@service-account.com", * gcsOutputUri: pulumi.interpolate`gs://${outputBucket.name}`, * notebookRuntimeTemplateResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}`, * }, { * dependsOn: [ * notebook, * outputBucket, * myRuntimeTemplate, * ], * }); * ``` * ### Colab Notebook Execution Dataform * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myRuntimeTemplate = new gcp.colab.RuntimeTemplate("my_runtime_template", { * name: "runtime-template-name", * displayName: "Runtime template", * location: "us-central1", * machineSpec: { * machineType: "e2-standard-4", * }, * networkSpec: { * enableInternetAccess: true, * }, * }); * const outputBucket = new gcp.storage.Bucket("output_bucket", { * name: "my_bucket", * location: "US", * forceDestroy: true, * uniformBucketLevelAccess: true, * }); * const secret = new gcp.secretmanager.Secret("secret", { * secretId: "secret", * replication: { * auto: {}, * }, * }); * const secretVersion = new gcp.secretmanager.SecretVersion("secret_version", { * secret: secret.id, * secretData: "secret-data", * }); * const dataformRepository = new gcp.dataform.Repository("dataform_repository", { * name: "dataform-repository", * displayName: "dataform_repository", * npmrcEnvironmentVariablesSecretVersion: secretVersion.id, * kmsKeyName: "my-crypto-key", * labels: { * label_foo1: "label-bar1", * }, * gitRemoteSettings: { * url: "https://github.com/OWNER/REPOSITORY.git", * defaultBranch: "main", * authenticationTokenSecretVersion: secretVersion.id, * }, * workspaceCompilationOverrides: { * defaultDatabase: "database", * schemaSuffix: "_suffix", * tablePrefix: "prefix_", * }, * }); * const notebook_execution = new gcp.colab.NotebookExecution("notebook-execution", { * displayName: "Notebook execution Dataform", * location: "us-central1", * dataformRepositorySource: { * commitSha: "randomsha123", * dataformRepositoryResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/repositories/${dataformRepository.name}`, * }, * notebookRuntimeTemplateResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}`, * gcsOutputUri: pulumi.interpolate`gs://${outputBucket.name}`, * serviceAccount: "my@service-account.com", * }, { * dependsOn: [ * myRuntimeTemplate, * outputBucket, * secretVersion, * dataformRepository, * secret, * ], * }); * ``` * * ## Import * * NotebookExecution can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{location}}/notebookExecutionJobs/{{notebook_execution_job_id}}` * * * `{{project}}/{{location}}/{{notebook_execution_job_id}}` * * * `{{location}}/{{notebook_execution_job_id}}` * * When using the `pulumi import` command, NotebookExecution can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:colab/notebookExecution:NotebookExecution default projects/{{project}}/locations/{{location}}/notebookExecutionJobs/{{notebook_execution_job_id}} * ``` * * ```sh * $ pulumi import gcp:colab/notebookExecution:NotebookExecution default {{project}}/{{location}}/{{notebook_execution_job_id}} * ``` * * ```sh * $ pulumi import gcp:colab/notebookExecution:NotebookExecution default {{location}}/{{notebook_execution_job_id}} * ``` */ class NotebookExecution extends pulumi.CustomResource { /** * Get an existing NotebookExecution resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new NotebookExecution(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of NotebookExecution. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === NotebookExecution.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["dataformRepositorySource"] = state?.dataformRepositorySource; resourceInputs["directNotebookSource"] = state?.directNotebookSource; resourceInputs["displayName"] = state?.displayName; resourceInputs["executionTimeout"] = state?.executionTimeout; resourceInputs["executionUser"] = state?.executionUser; resourceInputs["gcsNotebookSource"] = state?.gcsNotebookSource; resourceInputs["gcsOutputUri"] = state?.gcsOutputUri; resourceInputs["location"] = state?.location; resourceInputs["notebookExecutionJobId"] = state?.notebookExecutionJobId; resourceInputs["notebookRuntimeTemplateResourceName"] = state?.notebookRuntimeTemplateResourceName; resourceInputs["project"] = state?.project; resourceInputs["serviceAccount"] = state?.serviceAccount; } else { const args = argsOrState; if (args?.displayName === undefined && !opts.urn) { throw new Error("Missing required property 'displayName'"); } if (args?.gcsOutputUri === undefined && !opts.urn) { throw new Error("Missing required property 'gcsOutputUri'"); } if (args?.location === undefined && !opts.urn) { throw new Error("Missing required property 'location'"); } resourceInputs["dataformRepositorySource"] = args?.dataformRepositorySource; resourceInputs["directNotebookSource"] = args?.directNotebookSource; resourceInputs["displayName"] = args?.displayName; resourceInputs["executionTimeout"] = args?.executionTimeout; resourceInputs["executionUser"] = args?.executionUser; resourceInputs["gcsNotebookSource"] = args?.gcsNotebookSource; resourceInputs["gcsOutputUri"] = args?.gcsOutputUri; resourceInputs["location"] = args?.location; resourceInputs["notebookExecutionJobId"] = args?.notebookExecutionJobId; resourceInputs["notebookRuntimeTemplateResourceName"] = args?.notebookRuntimeTemplateResourceName; resourceInputs["project"] = args?.project; resourceInputs["serviceAccount"] = args?.serviceAccount; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(NotebookExecution.__pulumiType, name, resourceInputs, opts); } } exports.NotebookExecution = NotebookExecution; /** @internal */ NotebookExecution.__pulumiType = 'gcp:colab/notebookExecution:NotebookExecution'; //# sourceMappingURL=notebookExecution.js.map