AWS CDK安装到AWS EC2 Linux 2

2024-01-01 17:12
文章标签 linux 安装 aws ec2 cdk

本文主要是介绍AWS CDK安装到AWS EC2 Linux 2,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

  • 小结
  • 问题及解决
    • 安装NPM
    • 安装aws-cdk-lib
    • 找不到Python3
  • 测试
  • 参考

小结

AWS CDK安装到AWS EC2 Linux 2,并记录过程。

问题及解决

安装NPM

[ec2-user@ip-100-92-28-119 aws]$ sudo yum install npm
Loaded plugins: priorities, update-motd, upgrade-helper
amzn2-core                                                                                                                                                                                         | 3.6 kB  00:00:00     
amzn2extra-ecs                                                                                                                                                                                     | 2.9 kB  00:00:00     
amzn2extra-epel                                                                                                                                                                                    | 3.0 kB  00:00:00     
amzn2extra-mate-desktop1.x                                                                                                                                                                         | 3.0 kB  00:00:00     
amzn2extra-python3.8                                                                                                                                                                               | 2.9 kB  00:00:00     
epel/x86_64/metalink                                                                                                                                                                               | 4.9 kB  00:00:00     
epel                                                                                                                                                                                               | 4.7 kB  00:00:00     
(1/2): epel/x86_64/updateinfo                                                                                                                                                                      | 1.0 MB  00:00:00     
(2/2): epel/x86_64/primary_db                                                                                                                                                                      | 7.0 MB  00:00:00     
311 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package npm.x86_64 1:8.19.4-1.16.20.2.1.el7 will be installed
--> Processing Dependency: nodejs = 1:16.20.2-1.el7 for package: 1:npm-8.19.4-1.16.20.2.1.el7.x86_64
--> Running transaction check
---> Package nodejs.x86_64 1:16.20.2-1.el7 will be installed
--> Processing Dependency: nodejs-libs(x86-64) = 1:16.20.2-1.el7 for package: 1:nodejs-16.20.2-1.el7.x86_64
--> Processing Dependency: libuv >= 1:1.43.0 for package: 1:nodejs-16.20.2-1.el7.x86_64
--> Processing Dependency: openssl11 >= 1:1.1.1 for package: 1:nodejs-16.20.2-1.el7.x86_64
--> Processing Dependency: libbrotlidec.so.1()(64bit) for package: 1:nodejs-16.20.2-1.el7.x86_64
--> Processing Dependency: libbrotlienc.so.1()(64bit) for package: 1:nodejs-16.20.2-1.el7.x86_64
--> Processing Dependency: libcrypto.so.1.1()(64bit) for package: 1:nodejs-16.20.2-1.el7.x86_64
--> Processing Dependency: libnode.so.93()(64bit) for package: 1:nodejs-16.20.2-1.el7.x86_64
--> Processing Dependency: libssl.so.1.1()(64bit) for package: 1:nodejs-16.20.2-1.el7.x86_64
--> Processing Dependency: libuv.so.1()(64bit) for package: 1:nodejs-16.20.2-1.el7.x86_64
--> Running transaction check
---> Package libbrotli.x86_64 0:1.0.9-10.el7 will be installed
---> Package libuv.x86_64 1:1.39.0-1.amzn2 will be installed
---> Package nodejs.x86_64 1:16.20.2-1.el7 will be installed
--> Processing Dependency: libuv >= 1:1.43.0 for package: 1:nodejs-16.20.2-1.el7.x86_64
---> Package nodejs-libs.x86_64 1:16.20.2-1.el7 will be installed
---> Package openssl11.x86_64 1:1.1.1g-12.amzn2.0.19 will be installed
---> Package openssl11-libs.x86_64 1:1.1.1g-12.amzn2.0.19 will be installed
--> Processing Dependency: openssl11-pkcs11 for package: 1:openssl11-libs-1.1.1g-12.amzn2.0.19.x86_64
--> Running transaction check
---> Package nodejs.x86_64 1:16.20.2-1.el7 will be installed
--> Processing Dependency: libuv >= 1:1.43.0 for package: 1:nodejs-16.20.2-1.el7.x86_64
---> Package openssl11-pkcs11.x86_64 0:0.4.10-6.amzn2.0.1 will be installed
--> Finished Dependency Resolution
Error: Package: 1:nodejs-16.20.2-1.el7.x86_64 (epel)Requires: libuv >= 1:1.43.0Available: 1:libuv-1.23.2-1.amzn2.0.2.i686 (amzn2-core)libuv = 1:1.23.2-1.amzn2.0.2Available: 1:libuv-1.39.0-1.amzn2.i686 (amzn2-core)libuv = 1:1.39.0-1.amzn2You could try using --skip-broken to work around the problemYou could try running: rpm -Va --nofiles --nodigest

以上报·epel·提供的·libuv·版本过低,关闭·epel·的·YUM·源,

[ec2-user@ip-100-92-28-119 deployment_automation_script]$ ls /etc/yum.repos.d/
amzn2-core.repo  amzn2-extras.repo  epel.repo.bak  epel-testing.repo.bak

安装aws-cdk-lib

[ec2-user@ip-100-92-28-119 aws]$ python3.8 -m pip install aws-cdk-lib[ec2-user@ip-100-92-28-119 aws]$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100 15916  100 15916    0     0  48438      0 --:--:-- --:--:-- --:--:-- 48376
=> nvm is already installed in /home/ec2-user/.nvm, trying to update using git
=> => Compressing and cleaning up git repository=> nvm source string already in /home/ec2-user/.bashrc
=> bash_completion source string already in /home/ec2-user/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
[ec2-user@ip-100-92-28-119 aws]$ . ~/.nvm/nvm.sh
[ec2-user@ip-100-92-28-119 aws]$ nvm install --lts
Installing latest LTS version.
Downloading and installing node v20.10.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v20.10.0-linux-x64/node-v20.10.0-linux-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v20.10.0-linux-x64/node-v20.10.0-linux-x64.tar.xz
Now using node v20.10.0
[ec2-user@ip-100-92-28-119 aws]$ npm install -g aws-cdk
node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)

以上报没找到GLIBC库,卸载版本20.10.0,安装版本16.0.0:

[ec2-user@ip-100-92-28-119 aws]$ nvm uninstall 20.10.0
Uninstalled node v20.10.0
[ec2-user@ip-100-92-28-119 aws]$ nvm install 16.0.0
v16.0.0 is already installed.
Now using node v16.0.0 (npm v10.2.4)
[ec2-user@ip-100-92-28-119 aws]$ npm install -g aws-cdk
npm WARN cli npm v10.2.4 does not support Node.js v16.0.0. This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at https://nodejs.org/.changed 1 package in 2s
npm notice 
npm notice New patch version of npm available! 10.2.4 -> 10.2.5
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.2.5
npm notice Run npm install -g npm@10.2.5 to update!
npm notice 

找不到Python3

碰到了没有找到Python3的问题,

[ec2-user@ip-100-92-28-119 hello-ecs]$ cdk bootstrap
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!                                                                            !!
!!  Node 16 has reached end-of-life on 2023-09-11 and is not supported.       !!
!!  Please upgrade to a supported node version as soon as possible.           !!
!!                                                                            !!
!!  This software is currently running on node v16.0.0.                       !!
!!  As of the current release of this software, supported node releases are:  !!
!!  - ^20.0.0 (Planned end-of-life: 2026-04-30)                               !!
!!  - ^18.0.0 (Planned end-of-life: 2025-04-30)                               !!
!!                                                                            !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/bin/sh: python3: command not foundSubprocess exited with error 127

由于我使用的是Python3.8,需要创建一个软链接:


[ec2-user@ip-100-92-28-119 bin]$ ls python*
python  python2  python2.7  python2.7-config  python2-config  python3  python3.8  python3.8-config  python3.8-x86_64-config  python-config[ec2-user@ip-100-92-28-119 hello-ecs]$ ll /usr/bin/python*
lrwxrwxrwx 1 root root    7 Nov  1 20:24 /usr/bin/python -> python2
lrwxrwxrwx 1 root root    9 Nov  1 20:24 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 7048 Oct 19 21:17 /usr/bin/python2.7
-rwxr-xr-x 1 root root 1846 Oct 19 21:17 /usr/bin/python2.7-config
lrwxrwxrwx 1 root root   16 Nov  1 20:24 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root    9 Dec 28 04:30 /usr/bin/python3 -> python3.8
-rwxr-xr-x 1 root root 7048 Aug 30 23:21 /usr/bin/python3.8
-rwxr-xr-x 1 root root  171 Aug 30 23:20 /usr/bin/python3.8-config
-rwxr-xr-x 1 root root 3397 Aug 30 23:13 /usr/bin/python3.8-x86_64-config
lrwxrwxrwx 1 root root   14 Nov  1 20:24 /usr/bin/python-config -> python2-config[ec2-user@ip-100-92-28-119 bin]$ sudo ln -s python3.8 /usr/bin/python3

测试

[ec2-user@ip-100-92-28-119 aws]$ mkdir hello-ecs
[ec2-user@ip-100-92-28-119 aws]$ cd hello-ecs/
[ec2-user@ip-100-92-28-119 hello-ecs]$ cdk init --language python
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!                                                                            !!
!!  Node 16 has reached end-of-life on 2023-09-11 and is not supported.       !!
!!  Please upgrade to a supported node version as soon as possible.           !!
!!                                                                            !!
!!  This software is currently running on node v16.0.0.                       !!
!!  As of the current release of this software, supported node releases are:  !!
!!  - ^20.0.0 (Planned end-of-life: 2026-04-30)                               !!
!!  - ^18.0.0 (Planned end-of-life: 2025-04-30)                               !!
!!                                                                            !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Applying project template app for python# Welcome to your CDK Python project!This is a blank project for CDK development with Python.The `cdk.json` file tells the CDK Toolkit how to execute your app.This project is set up like a standard Python project.  The initialization
process also creates a virtualenv within this project, stored under the `.venv`
directory.  To create the virtualenv it assumes that there is a `python3`
(or `python` for Windows) executable in your path with access to the `venv`
package. If for any reason the automatic creation of the virtualenv fails,
you can create the virtualenv manually.To manually create a virtualenv on MacOS and Linux:$ python3 -m venv .venvAfter the init process completes and the virtualenv is created, you can use the following
step to activate your virtualenv.$ source .venv/bin/activateIf you are a Windows platform, you would activate the virtualenv like this:% .venv\Scripts\activate.batOnce the virtualenv is activated, you can install the required dependencies.$ pip install -r requirements.txtAt this point you can now synthesize the CloudFormation template for this code.$ cdk synthTo add additional dependencies, for example other CDK libraries, just add
them to your `setup.py` file and rerun the `pip install -r requirements.txt`
command.## Useful commands* `cdk ls`          list all stacks in the app* `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 documentationEnjoy!Initializing a new git repository...
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Author identity unknown*** Please tell me who you are.Rungit config --global user.email "you@example.com"git config --global user.name "Your Name"to set your account's default identity.
Omit --global to set the identity only in this repository.fatal: unable to auto-detect email address (got 'ec2-user@ip-100-92-28-119.(none)')
Unable to initialize git repository for your project.
Please run 'python3 -m venv .venv'!
Executing Creating virtualenv...
/bin/sh: python3: command not found
Unable to create virtualenv automatically
Please run 'python3 -m venv .venv'!
✅ All done!

参考

aws-cdk-lib 2.116.0
AWS: Getting started with the AWS CDK
stackoverflow: creating an alias for python3
stackoverflow: nodejs-16 dependency issue with libuv
Installing NPM on AWS EC2

这篇关于AWS CDK安装到AWS EC2 Linux 2的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/559955

相关文章

Jsoncpp的安装与使用方式

《Jsoncpp的安装与使用方式》JsonCpp是一个用于解析和生成JSON数据的C++库,它支持解析JSON文件或字符串到C++对象,以及将C++对象序列化回JSON格式,安装JsonCpp可以通过... 目录安装jsoncppJsoncpp的使用Value类构造函数检测保存的数据类型提取数据对json数

Linux磁盘分区、格式化和挂载方式

《Linux磁盘分区、格式化和挂载方式》本文详细介绍了Linux系统中磁盘分区、格式化和挂载的基本操作步骤和命令,包括MBR和GPT分区表的区别、fdisk和gdisk命令的使用、常见的文件系统格式以... 目录一、磁盘分区表分类二、fdisk命令创建分区1、交互式的命令2、分区主分区3、创建扩展分区,然后

mac安装redis全过程

《mac安装redis全过程》文章内容主要介绍了如何从官网下载指定版本的Redis,以及如何在自定义目录下安装和启动Redis,还提到了如何修改Redis的密码和配置文件,以及使用RedisInsig... 目录MAC安装Redis安装启动redis 配置redis 常用命令总结mac安装redis官网下

Linux中chmod权限设置方式

《Linux中chmod权限设置方式》本文介绍了Linux系统中文件和目录权限的设置方法,包括chmod、chown和chgrp命令的使用,以及权限模式和符号模式的详细说明,通过这些命令,用户可以灵活... 目录设置基本权限命令:chmod1、权限介绍2、chmod命令常见用法和示例3、文件权限详解4、ch

Linux内核之内核裁剪详解

《Linux内核之内核裁剪详解》Linux内核裁剪是通过移除不必要的功能和模块,调整配置参数来优化内核,以满足特定需求,裁剪的方法包括使用配置选项、模块化设计和优化配置参数,图形裁剪工具如makeme... 目录简介一、 裁剪的原因二、裁剪的方法三、图形裁剪工具四、操作说明五、make menuconfig

Linux使用nohup命令在后台运行脚本

《Linux使用nohup命令在后台运行脚本》在Linux或类Unix系统中,后台运行脚本是一项非常实用的技能,尤其适用于需要长时间运行的任务或服务,本文我们来看看如何使用nohup命令在后台... 目录nohup 命令简介基本用法输出重定向& 符号的作用后台进程的特点注意事项实际应用场景长时间运行的任务服

什么是cron? Linux系统下Cron定时任务使用指南

《什么是cron?Linux系统下Cron定时任务使用指南》在日常的Linux系统管理和维护中,定时执行任务是非常常见的需求,你可能需要每天执行备份任务、清理系统日志或运行特定的脚本,而不想每天... 在管理 linux 服务器的过程中,总有一些任务需要我们定期或重复执行。就比如备份任务,通常会选在服务器资

如何安装 Ubuntu 24.04 LTS 桌面版或服务器? Ubuntu安装指南

《如何安装Ubuntu24.04LTS桌面版或服务器?Ubuntu安装指南》对于我们程序员来说,有一个好用的操作系统、好的编程环境也是很重要,如何安装Ubuntu24.04LTS桌面... Ubuntu 24.04 LTS,代号 Noble NumBAT,于 2024 年 4 月 25 日正式发布,引入了众

如何安装HWE内核? Ubuntu安装hwe内核解决硬件太新的问题

《如何安装HWE内核?Ubuntu安装hwe内核解决硬件太新的问题》今天的主角就是hwe内核(hardwareenablementkernel),一般安装的Ubuntu都是初始内核,不能很好地支... 对于追求系统稳定性,又想充分利用最新硬件特性的 Ubuntu 用户来说,HWEXBQgUbdlna(Har

Linux限制ip访问的解决方案

《Linux限制ip访问的解决方案》为了修复安全扫描中发现的漏洞,我们需要对某些服务设置访问限制,具体来说,就是要确保只有指定的内部IP地址能够访问这些服务,所以本文给大家介绍了Linux限制ip访问... 目录背景:解决方案:使用Firewalld防火墙规则验证方法深度了解防火墙逻辑应用场景与扩展背景: