LoginSignup
2
4

More than 5 years have passed since last update.

AWS Cloud Development Kitをさわってみた

Last updated at Posted at 2018-08-29

AWS Cloud Development Kit (Developer Preview)をさわってみました。

どんなもの?

AWSのインフラストラクチャをコードで定義して CloudFormation でプロビジョニングできる優れもの。

チュートリアルをやってみる

S3バケットを作成します。

$ npm install -g aws-cdk
$ mkdir hello-cdk
$ cd hello-cdk
$ git init
$ npm init -y
$ vi index.js
$ vi cdk.json
index.js
const cdk = require('@aws-cdk/cdk');
const s3 = require('@aws-cdk/aws-s3');

class MyStack extends cdk.Stack {
    constructor(parent, id, props) {
        super(parent, id, props);

        new s3.Bucket(this, 'MyFirstBucket', {
            versioned: true
        });
    }
}

class MyApp extends cdk.App {
    constructor(argv) {
        super(argv);

        new MyStack(this, 'hello-cdk');
    }
}

process.stdout.write(new MyApp(process.argv).run());
cdk.json
{
  "app": "node index.js"
}
$ cdk synth hello-cdk
$ cdk deploy
 ⏳  Starting deployment of stack hello-cdk...
[0/2] Thu Aug 30 2018 06:32:39 GMT+0900 (JST)  CREATE_IN_PROGRESS  [AWS::CloudFormation::WaitConditionHandle] WaitCondition
[0/2] Thu Aug 30 2018 06:32:39 GMT+0900 (JST)  CREATE_IN_PROGRESS  [AWS::CloudFormation::WaitConditionHandle] WaitCondition Resource creation Initiated
[1/2] Thu Aug 30 2018 06:32:40 GMT+0900 (JST)  CREATE_COMPLETE     [AWS::CloudFormation::WaitConditionHandle] WaitCondition
[2/2] Thu Aug 30 2018 06:32:41 GMT+0900 (JST)  CREATE_COMPLETE     [AWS::CloudFormation::Stack] hello-cdk
[0/4] Thu Aug 30 2018 06:32:55 GMT+0900 (JST)  CREATE_IN_PROGRESS  [AWS::CDK::Metadata] CDKMetadata
[0/4] Thu Aug 30 2018 06:32:55 GMT+0900 (JST)  CREATE_IN_PROGRESS  [AWS::S3::Bucket] MyFirstBucketB8884501
[0/4] Thu Aug 30 2018 06:32:56 GMT+0900 (JST)  CREATE_IN_PROGRESS  [AWS::S3::Bucket] MyFirstBucketB8884501 Resource creation Initiated
[0/4] Thu Aug 30 2018 06:32:58 GMT+0900 (JST)  CREATE_IN_PROGRESS  [AWS::CDK::Metadata] CDKMetadata Resource creation Initiated
[1/4] Thu Aug 30 2018 06:32:58 GMT+0900 (JST)  CREATE_COMPLETE     [AWS::CDK::Metadata] CDKMetadata
[2/4] Thu Aug 30 2018 06:33:18 GMT+0900 (JST)  CREATE_COMPLETE     [AWS::S3::Bucket] MyFirstBucketB8884501
[2/4] Thu Aug 30 2018 06:33:19 GMT+0900 (JST)  UPDATE_COMPLETE_CLEANUP_IN_PROGRESS  [AWS::CloudFormation::Stack] hello-cdk
[2/4] Thu Aug 30 2018 06:33:21 GMT+0900 (JST)  DELETE_IN_PROGRESS  [AWS::CloudFormation::WaitConditionHandle] WaitCondition
[3/4] Thu Aug 30 2018 06:33:21 GMT+0900 (JST)  DELETE_COMPLETE     [AWS::CloudFormation::WaitConditionHandle] WaitCondition
[4/4] Thu Aug 30 2018 06:33:21 GMT+0900 (JST)  UPDATE_COMPLETE     [AWS::CloudFormation::Stack] hello-cdk
 ✅  Deployment of stack hello-cdk completed successfully, it has ARN arn:aws:cloudformation:us-east-1:***********:stack/hello-cdk/0c3c7ce0-abd3-11e8-b59a-50d5ca6e601e

対応サービス

ECSやEKSやNeptune等、比較的新しいサービスにも対応しているようです。

雑感

  • これでAWSのインフラエンジニアやCloudformation職人はいらない子に。→ 自分
  • 逆に言えば、アプリエンジニアがAWSをさわらない言い訳ができなくなった
  • 他のクラウドにも早く対応しないかな
2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4