@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
346 lines • 13.6 kB
JavaScript
"use strict";
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** 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, Object.assign(Object.assign({}, 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 ? state.dataformRepositorySource : undefined;
resourceInputs["directNotebookSource"] = state ? state.directNotebookSource : undefined;
resourceInputs["displayName"] = state ? state.displayName : undefined;
resourceInputs["executionTimeout"] = state ? state.executionTimeout : undefined;
resourceInputs["executionUser"] = state ? state.executionUser : undefined;
resourceInputs["gcsNotebookSource"] = state ? state.gcsNotebookSource : undefined;
resourceInputs["gcsOutputUri"] = state ? state.gcsOutputUri : undefined;
resourceInputs["location"] = state ? state.location : undefined;
resourceInputs["notebookExecutionJobId"] = state ? state.notebookExecutionJobId : undefined;
resourceInputs["notebookRuntimeTemplateResourceName"] = state ? state.notebookRuntimeTemplateResourceName : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["serviceAccount"] = state ? state.serviceAccount : undefined;
}
else {
const args = argsOrState;
if ((!args || args.displayName === undefined) && !opts.urn) {
throw new Error("Missing required property 'displayName'");
}
if ((!args || args.gcsOutputUri === undefined) && !opts.urn) {
throw new Error("Missing required property 'gcsOutputUri'");
}
if ((!args || args.location === undefined) && !opts.urn) {
throw new Error("Missing required property 'location'");
}
resourceInputs["dataformRepositorySource"] = args ? args.dataformRepositorySource : undefined;
resourceInputs["directNotebookSource"] = args ? args.directNotebookSource : undefined;
resourceInputs["displayName"] = args ? args.displayName : undefined;
resourceInputs["executionTimeout"] = args ? args.executionTimeout : undefined;
resourceInputs["executionUser"] = args ? args.executionUser : undefined;
resourceInputs["gcsNotebookSource"] = args ? args.gcsNotebookSource : undefined;
resourceInputs["gcsOutputUri"] = args ? args.gcsOutputUri : undefined;
resourceInputs["location"] = args ? args.location : undefined;
resourceInputs["notebookExecutionJobId"] = args ? args.notebookExecutionJobId : undefined;
resourceInputs["notebookRuntimeTemplateResourceName"] = args ? args.notebookRuntimeTemplateResourceName : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["serviceAccount"] = args ? args.serviceAccount : undefined;
}
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