🪸
pulumiでAWSリソースを作成する雰囲気を一分で
pulumi でAWSリソースを作成してみる
1〜2分程度眺めていただく程度のシンプル記事となります。
Install
$ brew install pulumi/tap/pulumi
pulumi new
$ mkdir test && cd test
$ pulumi new aws-yaml
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...
Account Create=>login
create project & stack
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 (test): test
project description (A minimal AWS Pulumi YAML program):
Created project 'test'
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):
Saved config
Your new project is ready to go! ✨
To perform an initial deployment, run `pulumi up`
作成されたファイル
pulumi.dev.yaml
config:
aws:region: us-east-1
pulumi.yaml
name: test
runtime: yaml
description: A minimal AWS Pulumi YAML program
outputs:
# Export the name of the bucket
bucketName: ${my-bucket.id}
resources:
# Create an AWS resource (S3 Bucket)
my-bucket:
type: aws:s3:Bucket
pulumi up
$ pulumi up
Previewing update (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/hoge/test/dev/previews/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Downloading plugin: 191.19 MiB / 191.19 MiB [====================] 100.00% 1m10s
[resource plugin aws-6.18.0] installing
Type Name Plan
+ pulumi:pulumi:Stack test-dev create
+ └─ aws:s3:Bucket my-bucket create
Outputs:
bucketName: output<string>
Resources:
+ 2 to create
Do you want to perform this update? yes
Updating (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/hoge/test/dev/updates/1
Type Name Status
+ pulumi:pulumi:Stack test-dev created (7s)
+ └─ aws:s3:Bucket my-bucket created (4s)
Outputs:
bucketName: "my-bucket-3a8d05c"
Resources:
+ 2 created
Duration: 8s
pulumiコンソールを確認
AWSコンソールを確認
pulumi destroy
$ pulumi destroy
Previewing destroy (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/hoge/test/dev/previews/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Type Name Plan
- pulumi:pulumi:Stack test-dev delete
- └─ aws:s3:Bucket my-bucket delete
Outputs:
- bucketName: "my-bucket-3a8d05c"
Resources:
- 2 to delete
Do you want to perform this destroy? yes
Destroying (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/hoge/test/dev/updates/2
Type Name Status
- pulumi:pulumi:Stack test-dev deleted (0.25s)
- └─ aws:s3:Bucket my-bucket deleted (2s)
Outputs:
- bucketName: "my-bucket-3a8d05c"
Resources:
- 2 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コンソールを確認
以上でした
他のIaC技術との違いや良い所などについてまた近日調べてみたいと思います。
Discussion