Usage:
pulumi new [template|url] [flags]
Flags:
-c, --config stringArray Config to save
--config-path Config keys contain a path to a property in a map or list to set -d, --description string The project description; if not specified, a prompt will request it
--dir string The location to place the generated project; if not specified, the current directory is used
-f, --force Forces content to be generated even if it would change existing files
-g, --generate-only Generate the project only; do not create a stack, save config, or install dependencies
-h, --help helpfor new
-n, --name string The project name; if not specified, a prompt will request it
-o, --offline Use locally cached templates without making any network requests
--secrets-provider string The type of the provider that should be used to encrypt and decrypt secrets (possible choices: default, passphrase, awskms, azurekeyvault, gcpkms, hashivault) (default "default")
-s, --stack string The stack name; either an existing stack or stack to create; if not specified, a prompt will request it
-y, --yes Skip prompts and proceed with default values
可以選擇的 Template 超多,那我們這次用 AWS 搭配 Go 語言的 Temaplate 當作範例
$ pulumi new aws-go --dir demo
This command will walk you through creating a new Pulumi project.
Enter a value or leave blank to accept the (default), and press <ENTER>.
Press ^C at any time to quit.
project name: (demo)
project description: (A minimal AWS Go Pulumi program)
Created project 'demo'Please enter your desired stack name.
To create a stack in an organization, use the format <org-name>/<stack-name> (e.g. `acmecorp/dev`).
stack name: (dev)
Created stack 'dev'aws:region: The AWS region to deploy into: (us-east-1) ap-northeast-1
Saved config
Installing dependencies...
Finished installing dependencies
Your new project is ready to go! ✨
To perform an initial deployment, run 'cd demo', then, run 'pulumi up'
packagemainimport("github.com/pulumi/pulumi-aws/sdk/v3/go/aws/s3""github.com/pulumi/pulumi/sdk/v2/go/pulumi")funcmain(){pulumi.Run(func(ctx*pulumi.Context)error{// Create an AWS resource (S3 Bucket)bucket,err:=s3.NewBucket(ctx,"my-bucket",nil)iferr!=nil{returnerr}// Export the name of the bucketctx.Export("bucketName",bucket.ID())returnnil})}
Previewing update (dev)
View Live: https://app.pulumi.com/appleboy/demo/dev/previews/db6a9e4e-f391-4cc4-b50c-408319b3d8e2
Type Name Plan
+ pulumi:pulumi:Stack demo-dev create
+ └─ aws:s3:Bucket my-bucket create
Resources:
+ 2 to create
Do you want to perform this update? [Use arrows to move, enter to select, type to filter]
yes
> no
details
Do you want to perform this update? yes
Updating (dev)
View Live: https://app.pulumi.com/appleboy/demo/dev/updates/3
Type Name Status
+ pulumi:pulumi:Stack demo-dev created
+ └─ aws:s3:Bucket my-bucket created
Outputs:
bucketName: "my-bucket-9dd3052"Resources:
+ 2 created
Duration: 17s
funcmain(){pulumi.Run(func(ctx*pulumi.Context)error{// Create an AWS resource (S3 Bucket)bucket,err:=s3.NewBucket(ctx,"my-bucket",&s3.BucketArgs{Bucket:pulumi.String("foobar-1234"),})iferr!=nil{returnerr}// Export the name of the bucketctx.Export("bucketID",bucket.ID())ctx.Export("bucketName",bucket.Bucket)returnnil})}
packagemainimport("mime""path""github.com/pulumi/pulumi-aws/sdk/v3/go/aws/s3""github.com/pulumi/pulumi/sdk/v2/go/pulumi")funcmain(){pulumi.Run(func(ctx*pulumi.Context)error{// Create an AWS resource (S3 Bucket)bucket,err:=s3.NewBucket(ctx,"my-bucket",&s3.BucketArgs{Bucket:pulumi.String("foobar-1234"),Website:s3.BucketWebsiteArgs{IndexDocument:pulumi.String("index.html"),},})iferr!=nil{returnerr}index:=path.Join("content","index.html")_,err=s3.NewBucketObject(ctx,"index.html",&s3.BucketObjectArgs{Bucket:bucket.Bucket,Source:pulumi.NewFileAsset(index),Acl:pulumi.String("public-read"),ContentType:pulumi.String(mime.TypeByExtension(path.Ext(index))),})iferr!=nil{returnerr}// Export the name of the bucketctx.Export("bucketID",bucket.ID())ctx.Export("bucketName",bucket.Bucket)ctx.Export("bucketEndpoint",bucket.WebsiteEndpoint)returnnil})}