mirror of https://github.com/pulumi/pulumi.git
bbde4002ad
11168: [auto/go] Support for remote operations r=justinvp a=justinvp This change adds preview support for remote operations in Go's Automation API. Here's an example of using it: ```go package main import ( "context" "fmt" "os" "github.com/pulumi/pulumi/sdk/v3/go/auto" "github.com/pulumi/pulumi/sdk/v3/go/auto/optremotedestroy" "github.com/pulumi/pulumi/sdk/v3/go/auto/optremoteup" ) func main() { // to destroy our program, we can run `go run main.go destroy` var preview, destroy, refresh bool argsWithoutProg := os.Args[1:] destroy := len(argsWithoutProg) > 0 && argsWithoutProg[0] == "destroy" ctx := context.Background() org := "justinvp" projectName := "aws-ts-s3-folder" stackName := auto.FullyQualifiedStackName(org, projectName, "devgo") repo := auto.GitRepo{ URL: "https://github.com/pulumi/examples.git", Branch: "refs/heads/master", ProjectPath: projectName, } env := map[string]auto.EnvVarValue{ "AWS_REGION": {Value: "us-west-2"}, "AWS_ACCESS_KEY_ID": {Value: os.Getenv("AWS_ACCESS_KEY_ID")}, "AWS_SECRET_ACCESS_KEY": {Value: os.Getenv("AWS_SECRET_ACCESS_KEY"), Secret: true}, "AWS_SESSION_TOKEN": {Value: os.Getenv("AWS_SESSION_TOKEN"), Secret: true}, } s, err := auto.UpsertRemoteStackGitSource(ctx, stackName, repo, auto.RemoteEnvVars(env)) if err != nil { fmt.Printf("Failed to create or select stack: %v\n", err) os.Exit(1) } if destroy { stdoutStreamer := optremotedestroy.ProgressStreams(os.Stdout) _, err := s.Destroy(ctx, stdoutStreamer) if err != nil { fmt.Printf("Failed to destroy stack: %v", err) } fmt.Println("Stack successfully destroyed") os.Exit(0) } stdoutStreamer := optremoteup.ProgressStreams(os.Stdout) res, err := s.Up(ctx, stdoutStreamer) if err != nil { fmt.Printf("Failed to update stack: %v\n\n", err) os.Exit(1) } fmt.Println("Update succeeded!") url, ok := res.Outputs["websiteUrl"].Value.(string) if !ok { fmt.Println("Failed to unmarshall output URL") os.Exit(1) } fmt.Printf("URL: %s\n", url) } ``` I will add sanity tests subsequently. 11170: [auto/nodejs] Support for remote operations r=justinvp a=justinvp This change adds preview support for remote operations in Node.js's Automation API. Here's an example of using it: ```ts import * as process from "process"; import { RemoteWorkspace, fullyQualifiedStackName } from "`@pulumi/pulumi/automation";` const args = process.argv.slice(2); const destroy = args.length > 0 && args[0] === "destroy"; const org = "justinvp"; const projectName = "aws-ts-s3-folder"; const stackName = fullyQualifiedStackName(org, projectName, "devnode"); (async function() { const stack = await RemoteWorkspace.createOrSelectStack({ stackName, url: "https://github.com/pulumi/examples.git", branch: "refs/heads/master", projectPath: projectName, }, { envVars: { AWS_REGION: "us-west-2", AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID ?? "", AWS_SECRET_ACCESS_KEY: { secret: process.env.AWS_SECRET_ACCESS_KEY ?? "" }, AWS_SESSION_TOKEN: { secret: process.env.AWS_SESSION_TOKEN ?? "" }, }, }); if (destroy) { await stack.destroy({ onOutput: out => process.stdout.write(out) }); console.log("Stack successfully destroyed"); process.exit(0); } const upRes = await stack.up({ onOutput: out => process.stdout.write(out) }); console.log("Update succeeded!"); console.log(`url: ${upRes.outputs.websiteUrl.value}`); })(); ``` I will add sanity tests subsequently. 11174: [auto/python] Support for remote operations r=justinvp a=justinvp This change adds preview support for remote operations in Python's Automation API. Here's an example of using it: ```python import sys import os import pulumi.automation as auto args = sys.argv[1:] destroy = args and args[0] == "destroy" org = "justinvp" project_name = "aws-ts-s3-folder" stack_name = auto.fully_qualified_stack_name(org, project_name, "devpy") stack = auto.create_or_select_remote_stack_git_source( stack_name=stack_name, url="https://github.com/pulumi/examples.git", branch="refs/heads/master", project_path=project_name, opts=auto.RemoteWorkspaceOptions( env_vars={ "AWS_REGION": "us-west-2", "AWS_ACCESS_KEY_ID": os.environ["AWS_ACCESS_KEY_ID"], "AWS_SECRET_ACCESS_KEY": auto.Secret(os.environ["AWS_SECRET_ACCESS_KEY"]), "AWS_SESSION_TOKEN": auto.Secret(os.environ["AWS_SESSION_TOKEN"]), }, ), ) if destroy: stack.destroy(on_output=print) print("Stack successfully destroyed") sys.exit() up_res = stack.up(on_output=print) print(f"Update succeeded!") print(f"url: {up_res.outputs['websiteUrl'].value}") ``` I will add sanity tests subsequently. Co-authored-by: Justin Van Patten <jvp@justinvp.com> |
||
---|---|---|
.. | ||
20221027--auto-go--support-for-remote-operations.yaml | ||
20221027--auto-nodejs--support-for-remote-operations.yaml | ||
20221027--auto-python--support-for-remote-operations.yaml |