継続は力なり

タイトル通り定期的な更新を心掛けるブログです。

AWS CDK CLI のバージョンアップを行う方法

タダです.

AWS CDK のバージョン0.33.0がリリースされました.

github.com

リリース情報

Bug Fixes

  • core: Fn.cidr should return a list and not a string (#2678) (9d2ea2a), closes #2671
  • cli: fix ts-node usage on Windows (#2660) (5fe0af5)
  • cli: make cdk docs open the new API reference (#2633) (6450758)
  • cli: correctly pass build args to docker build (#2634) (9c58d6f)
  • core: hide dependencyRoots from public API (#2668) (2ba5ad2), closes #2348
  • autoscaling: move lifecycle hook targets to their own module (#2628) (b282132), closes #2447
  • codepipeline: no longer allow providing an index when adding a Stage to a Pipeline. (#2624) (ce39b12)
  • codepipeline-actions: correctly serialize the userParameters passed to the Lambda invoke Action. (#2537) (ceaf54a)
  • cx-api: improve compatibility messages for cli <=> app (#2676) (38a9894)
  • ecs: move high level ECS constructs into aws-ecs-patterns (#2623) (f901313)
  • logs: move log destinations into 'aws-logs-destinations' (#2655) (01601c2), closes #2444
  • s3: move notification destinations into their own module (#2659) (185951c), closes #2445

Features

  • cli: decouple "synth" and "deploy" through cloud assemblies (#2636) (c52bcfc), closes #1893 #2093 #1954 #2310 #2073 #1245 #341 #956 #233 #2016
  • acm: allow specifying region for validated certificates (#2626) (1a7d4db)
  • apigateway: support for UsagePlan, ApiKey, UsagePlanKey (#2564) (203f114), closes #723
  • autoscaling: allow setting spotPrice (#2571) (d640055), closes #2208
  • cfn: update CloudFormation spec to v3.3.0 (#2669) (0f553ee)
  • cli: disable noUnusedLocals and noUnusedParameters from typescript templates (#2654) (b061826)
  • cloudformation: aws-api custom resource (#1850) (9a48b66)
  • cloudwatch: support all Y-Axis properties (#2406) (8904c3e), closes #2385

BREAKING CHANGES

  • logs: using a Lambda or Kinesis Stream as CloudWatch log subscription destination now requires an integration object from the @aws-cdk/aws-logs-destinations package.
  • codepipeline-actions: removed the addPutJobResultPolicy property when creating LambdaInvokeAction.
  • cli: --interactive has been removed
  • cli: --numbered has been removed
  • cli: --staging is now a boolean flag that indicates whether assets should be copied to the --output directory or directly referenced (--no-staging is useful for e.g. local debugging with SAM CLI)
  • assets: Assets (e.g. Lambda code assets) are now referenced relative to the output directory.
  • assert: SynthUtils.templateForStackName has been removed (use SynthUtils.synthesize(stack).template).
  • cx-api: cxapi.SynthesizedStack renamed to cxapi.CloudFormationStackArtifact with multiple API changes.
  • core: cdk.App.run() now returns a cxapi.CloudAssembly instead of cdk.ISynthesisSession.
  • s3: using a Topic, Queue or Lambda as bucket notification destination now requires an integration object from the @aws-cdk/aws-s3-notifications package.
  • autoscaling: using a Topic, Queue or Lambda as Lifecycle Hook Target now requires an integration object from the @aws-cdk/aws-autoscaling-hooktargets package.
  • codepipeline: the property atIndex has been removed from the StagePlacement interface.
  • aws-ecs: These changes move all L3 and higher constructs out of the aws-ecs module into the aws-ecs-patterns module. The following constructs have been moved into the aws-ecs-patterns module: EcsQueueWorkerService, FargateQueueWorkerService, LoadBalancedEcsService, LoadBalancedFargateService and LoadBalancedFargateServiceApplets.
  • cloudwatch: rename leftAxisRange => leftYAxis, rightAxisRange => rightYAxis, rename YAxisRange => YAxisProps.

AWS CDK CLI のバージョンアップ方法

ローカルの「AWS CDK CLI」のバージョンが0.30.0になっていたのですが,リリース情報に以下の記載もあったのでバージョンアップしてみました.今回はその対応時の情報をまとめます.

IMPORTANT: apps created with the CDK version 0.33.0 and above cannot be used with an older CLI version.

バージョンアップ前の情報

$ cdk  --version
0.30.0 (build 4740446)

npm-check-updates を使ってバージョンアップ方法を確認する

AWS CDK CLI」はnpmを使ってインストールしました.そのため npm パッケージの更新方法を確認していたところnpm-check-updatesを使うのが良さそうだと思い使ってみました.

github.com

参考記事

dackdive.hateblo.jp

npm-check-updatesの導入は以下の通りです.

$ npm i -g npm-check-updates
/usr/local/bin/ncu -> /usr/local/lib/node_modules/npm-check-updates/bin/ncu
/usr/local/bin/npm-check-updates -> /usr/local/lib/node_modules/npm-check-updates/bin/npm-check-updates
+ npm-check-updates@3.1.9
added 154 packages from 80 contributors in 10.035s

npm-check-updatesncuコマンドを使ってパッケージのアップデート確認が可能です.実行してみるとnpm -g install aws-cdk@0.33.0 でバージョンアップ可能なことが確認できます.

$ ncu -g aws-cdk
[====================] 1/1 100%

 aws-cdk  0.30.00.33.0

ncu itself cannot upgrade global packages. Run the following to upgrade all global packages:

npm -g install aws-cdk@0.33.0

ncuコマンドで確認したようにコマンドを実行しアップデートをかけてみます.バージョンが0.33.0になったことを確認できました.

$ npm -g install aws-cdk@0.33.0
npm WARN deprecated @aws-cdk/applet-js@0.33.0: Applets have been deprecated in favor of 'decdk'
/usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk

> core-js@2.6.9 postinstall /usr/local/lib/node_modules/aws-cdk/node_modules/core-js
> node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

+ aws-cdk@0.33.0
added 3 packages from 1 contributor, removed 7 packages and updated 25 packages in 31.781s
$ cdk --version
0.33.0 (build 50d71bf)

これで楽しい「AWS CDK CLI」ライフ実現に一歩近づきました.

まとめ

初めて「AWS CDK CLI」のバージョンアップ対応を行なったのでその方法をまとめました.npm-check-updates 使うとアップデート方法がすぐわかって簡単に対応できました.今後アップデート予定の方の何か参考になれば幸いです!

関連記事

sadayoshi-tada.hatenablog.com

sadayoshi-tada.hatenablog.com