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

相关文章

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法

《ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法》本文介绍了Elasticsearch的基本概念,包括文档和字段、索引和映射,还详细描述了如何通过Docker... 目录1、ElasticSearch概念2、ElasticSearch、Kibana和IK分词器部署

Linux流媒体服务器部署流程

《Linux流媒体服务器部署流程》文章详细介绍了流媒体服务器的部署步骤,包括更新系统、安装依赖组件、编译安装Nginx和RTMP模块、配置Nginx和FFmpeg,以及测试流媒体服务器的搭建... 目录流媒体服务器部署部署安装1.更新系统2.安装依赖组件3.解压4.编译安装(添加RTMP和openssl模块

linux下多个硬盘划分到同一挂载点问题

《linux下多个硬盘划分到同一挂载点问题》在Linux系统中,将多个硬盘划分到同一挂载点需要通过逻辑卷管理(LVM)来实现,首先,需要将物理存储设备(如硬盘分区)创建为物理卷,然后,将这些物理卷组成... 目录linux下多个硬盘划分到同一挂载点需要明确的几个概念硬盘插上默认的是非lvm总结Linux下多

Python安装时常见报错以及解决方案

《Python安装时常见报错以及解决方案》:本文主要介绍在安装Python、配置环境变量、使用pip以及运行Python脚本时常见的错误及其解决方案,文中介绍的非常详细,需要的朋友可以参考下... 目录一、安装 python 时常见报错及解决方案(一)安装包下载失败(二)权限不足二、配置环境变量时常见报错及

linux进程D状态的解决思路分享

《linux进程D状态的解决思路分享》在Linux系统中,进程在内核模式下等待I/O完成时会进入不间断睡眠状态(D状态),这种状态下,进程无法通过普通方式被杀死,本文通过实验模拟了这种状态,并分析了如... 目录1. 问题描述2. 问题分析3. 实验模拟3.1 使用losetup创建一个卷作为pv的磁盘3.

MySQL8.2.0安装教程分享

《MySQL8.2.0安装教程分享》这篇文章详细介绍了如何在Windows系统上安装MySQL数据库软件,包括下载、安装、配置和设置环境变量的步骤... 目录mysql的安装图文1.python访问网址2javascript.点击3.进入Downloads向下滑动4.选择Community Server5.

CentOS系统Maven安装教程分享

《CentOS系统Maven安装教程分享》本文介绍了如何在CentOS系统中安装Maven,并提供了一个简单的实际应用案例,安装Maven需要先安装Java和设置环境变量,Maven可以自动管理项目的... 目录准备工作下载并安装Maven常见问题及解决方法实际应用案例总结Maven是一个流行的项目管理工具

MySql9.1.0安装详细教程(最新推荐)

《MySql9.1.0安装详细教程(最新推荐)》MySQL是一个流行的关系型数据库管理系统,支持多线程和多种数据库连接途径,能够处理上千万条记录的大型数据库,本文介绍MySql9.1.0安装详细教程,... 目录mysql介绍:一、下载 Mysql 安装文件二、Mysql 安装教程三、环境配置1.右击此电脑