2022年9月5日月曜日

AWS CLI & CDK

https://docs.aws.amazon.com/cdk/api/v1/python/index.html

【タイムゾーンと日本語】
$ sudo timedatectl set-timezone Asia/Tokyo
$ sudo timedatectl
$ sudo localectl set-locale LANG=ja_JP.utf8
$ sudo localectl


【CDKインストール】
# dnf remove nodejs npm

# dnf install npm
$ npm install -g n
$ n stable
$ npm install -g aws-cdk

----------------------------------------------------------------------
※ amazon linux2 にnpmをインストールするには、
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
$ .   ~/.nvm/nvm.sh                          # .bash_profileに記述
$ nvm install --lts
$  node -v
v16.17.0
$ npm install -g n
$ n stable
$ npm install -g aws-cdk
--------------------------------------------------------------------------

$  cdk --version
2.40.0 (build 56ba2ab)

※ cdk version up
$ npm install -g aws-cdk

$ aws sts get-caller-identity
$ cdk bootstrap aws://99999999999/ap-northeast-1 
    ※ aws://<アカウントID>/<リージョン名>  [ --profile  default ]

$ mkdir cdk-demo
$ cd cdk-demo
$ cdk init  app  --language python     # app template 名
# Useful commands
 *  cdk ls                list all stacks in the app
 * cdk synthesize
 *  cdk synth       emits the synthesized CloudFormation template
 * cdk deploy    deploy this stack to your default AWS account/region
 * cdk diff           compare deployed stack with current state
 * cdk docs        open CDK documentation
* cdk destroy   destropy this stack
* cdk context
* cdk metadata

*
Enjoy!

# dnf install python38
# update-alternatives --config python
python3.8を選択

$ python3.8  -m venv  .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt

※ python3.6では、下記エラー発生 ( 3.8はOK)
 ERROR: Could not find a version that satisfies the requirement aws-cdk-lib==2.40.0
$ pip install  aws-cdk-lib
2.23.0がインストールされた。

$ cdk synth


API リファレンス
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html

※ https://github.com/aws-samples/aws-cdk-examples


※ https://atsushinotes.com/deploy_wordpress_cdk_python/2/













cdk init --language typescript

## Useful commands * `npm run build` compile typescript to js * `npm run watch` watch for changes and compile * `npm run test` perform the jest unit tests * `cdk deploy` deploy this stack to your default AWS account/region * `cdk diff` compare deployed stack with current state * `cdk synth` emits the synthesized CloudFormation templat

0 件のコメント:

コメントを投稿

シャットダウン時の後処理 (shutdown)

# vi /etc/systemd/system/drop.service [Unit] Description= stop httpgwd DefaultDependencies=no Before=shutdown.target RefuseManualStart=true ...