Open11
Pulumi を試す
アカウントを作る
Pulumi Cloud
CLI をインストール
brew install pulumi/tap/pulumi
Typescript の Pulumi プロジェクトを作成
% pulumi new aws-typescript
Manage your Pulumi stacks by logging in.
Run `pulumi login --help` for alternative login options.
Enter your access token from https://app.pulumi.com/account/tokens
or hit <ENTER> to log in using your browser :
We've launched your web browser to complete the login process.
Waiting for login to complete...
Welcome to Pulumi!
Pulumi helps you create, deploy, and manage infrastructure on any cloud using
your favorite language. You can get started today with Pulumi at:
https://www.pulumi.com/docs/get-started/
Tip: Resources you create with Pulumi are given unique names (a randomly
generated suffix) by default. To learn more about auto-naming or customizing resource
names see https://www.pulumi.com/docs/intro/concepts/resources/#autonaming.
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 (project): foo
Project description (A minimal AWS TypeScript Pulumi program):
Created project 'foo'
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):
The package manager to use for installing dependencies npm
The AWS region to deploy into (aws:region) (us-east-1): ap-northeast-1
Saved config
Installing dependencies...
added 391 packages, and audited 392 packages in 27s
46 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Finished installing dependencies
Your new project is ready to go! ✨
To perform an initial deployment, run `pulumi up`
作成されたファイル
% ls -1
index.ts
node_modules
package-lock.json
package.json
Pulumi.dev.yaml
Pulumi.yaml
README.md
tsconfig.json
デプロイしてみたけど認証エラー
% pulumi up
Previewing update (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/oppara/foo/dev/previews/xxxx
Type Name Plan Info
+ pulumi:pulumi:Stack foo-dev create
└─ pulumi:providers:aws default_7_7_0 1 error
Diagnostics:
pulumi:providers:aws (default_7_7_0):
error: pulumi:providers:aws resource 'default_7_7_0' has a problem: No valid credential sources found.
Please see https://www.pulumi.com/registry/packages/aws/installation-configuration/ for more information about providing credentials.
NEW: You can use Pulumi ESC to set up dynamic credentials with AWS OIDC to ensure the correct and valid credentials are used.
Learn more: https://www.pulumi.com/registry/packages/aws/installation-configuration/#dynamically-generate-credentials-via-pulumi-esc
[Pulumi Copilot] Would you like help with these diagnostics?
https://app.pulumi.com/oppara/foo/dev/previews/xxxx?explainFailure
Resources:
+ 1 to create
aws-vault を使っているので
% aws-vault exec oppara -- pulumi up
Previewing update (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/oppara/foo/dev/previews/72ef6912-6e92-4412-a7db-2b7b4b3f07a7
Type Name Plan
+ pulumi:pulumi:Stack foo-dev create
+ └─ aws:s3:Bucket my-bucket create
Outputs:
bucketName: [unknown]
Resources:
+ 2 to create
Do you want to perform this update? yes
Updating (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/oppara/foo/dev/updates/1
Type Name Status
+ pulumi:pulumi:Stack foo-dev created (4s)
+ └─ aws:s3:Bucket my-bucket created (1s)
Outputs:
bucketName: "my-bucket-a25c693"
Resources:
+ 2 created
Duration: 6s
バージョニングを追加
git diff
diff --git a/index.ts b/index.ts
index e38672c..3e89510 100644
--- a/index.ts
+++ b/index.ts
@@ -5,5 +5,12 @@ import * as awsx from "@pulumi/awsx";
// Create an AWS resource (S3 Bucket)
const bucket = new aws.s3.Bucket("my-bucket");
+const versioning = new aws.s3.BucketVersioning("my-bucket-versioning", {
+ bucket: bucket.id,
+ versioningConfiguration: {
+ status: "Enabled",
+ },
+});
+
// Export the name of the bucket
export const bucketName = bucket.id;
プレビュー
% aws-vault exec oppara -- pulumi preview
Previewing update (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/oppara/foo/dev/previews/f02961c9-584c-459c-9aae-a1e135151f89
Type Name Plan
pulumi:pulumi:Stack foo-dev
+ └─ aws:s3:BucketVersioning my-bucket-versioning create
Resources:
+ 1 to create
2 unchanged
デプロイ
% aws-vault exec oppara -- pulumi up
Previewing update (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/oppara/foo/dev/previews/147a9fbe-eeb9-41c2-8812-263653a5e278
Type Name Plan
pulumi:pulumi:Stack foo-dev
+ └─ aws:s3:BucketVersioning my-bucket-versioning create
Resources:
+ 1 to create
2 unchanged
Do you want to perform this update? yes
Updating (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/oppara/foo/dev/updates/2
Type Name Status
pulumi:pulumi:Stack foo-dev
+ └─ aws:s3:BucketVersioning my-bucket-versioning created (1s)
Outputs:
bucketName: "my-bucket-a25c693"
Resources:
+ 1 created
2 unchanged
Duration: 5s
後片付け
% aws-vault exec oppara -- pulumi destroy
Previewing destroy (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/oppara/foo/dev/previews/2c28501e-d307-4e65-a757-41fa19940a1b
Type Name Plan
- pulumi:pulumi:Stack foo-dev delete
- ├─ aws:s3:BucketVersioning my-bucket-versioning delete
- └─ aws:s3:Bucket my-bucket delete
Outputs:
- bucketName: "my-bucket-a25c693"
Resources:
- 3 to delete
Do you want to perform this destroy? yes
Destroying (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/oppara/foo/dev/updates/3
Type Name Status
- pulumi:pulumi:Stack foo-dev deleted (0.20s)
- ├─ aws:s3:BucketVersioning my-bucket-versioning deleted (0.66s)
- └─ aws:s3:Bucket my-bucket deleted (0.78s)
Outputs:
- bucketName: "my-bucket-a25c693"
Resources:
- 3 deleted
Duration: 4s
The resources in the stack have been deleted, but the history and configuration associated with the stack are still maintained.
If you want to remove the stack completely, run `pulumi stack rm dev`.
履歴
% pulumi stack history main
Version: 3
UpdateKind: destroy
Status: succeeded
Message: feat: initial commit
+0-3~0 0 Updated 50 seconds ago took 5s
exec.kind: cli
git.author: oppara
git.author.email: oppara@oppara.tv
git.committer: oppara
git.committer.email: oppara@oppara.tv
git.dirty: true
git.head: dfd5e99e3967dcdb42828709351d0f0f8b076cb1
git.headName: refs/heads/main
pulumi.arch: arm64
pulumi.os: darwin
pulumi.version: v3.197.0
stack.environments: []
updatePlan: false
Version: 2
UpdateKind: update
Status: succeeded
Message: feat: initial commit
+1-0~0 2 Updated 4 minutes ago took 5s
exec.kind: cli
git.author: oppara
git.author.email: oppara@oppara.tv
git.committer: oppara
git.committer.email: oppara@oppara.tv
git.dirty: true
git.head: dfd5e99e3967dcdb42828709351d0f0f8b076cb1
git.headName: refs/heads/main
pulumi.arch: arm64
pulumi.os: darwin
pulumi.version: v3.197.0
stack.environments: []
updatePlan: false
Version: 1
UpdateKind: update
Status: succeeded
Message:
+2-0~0 0 Updated 18 minutes ago took 7s
exec.kind: cli
pulumi.arch: arm64
pulumi.os: darwin
pulumi.version: v3.197.0
stack.environments: []
updatePlan: false