AWS CDK安装到AWS EC2 Linux 2

这篇具有很好参考价值的文章主要介绍了AWS CDK安装到AWS EC2 Linux 2。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

小结

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.0
           Available: 1:libuv-1.23.2-1.amzn2.0.2.i686 (amzn2-core)
               libuv = 1:1.23.2-1.amzn2.0.2
           Available: 1:libuv-1.39.0-1.amzn2.i686 (amzn2-core)
               libuv = 1:1.39.0-1.amzn2
 You could try using --skip-broken to work around the problem
 You 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  Current
                                 Dload  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 found

Subprocess 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 .venv


After the init process completes and the virtualenv is created, you can use the following
step to activate your virtualenv.


$ source .venv/bin/activate


If you are a Windows platform, you would activate the virtualenv like this:


% .venv\Scripts\activate.bat


Once the virtualenv is activated, you can install the required dependencies.


$ pip install -r requirements.txt


At this point you can now synthesize the CloudFormation template for this code.


$ cdk synth


To 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 documentation

Enjoy!

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.

Run

  git 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文章来源地址https://www.toymoban.com/news/detail-772662.html

到了这里,关于AWS CDK安装到AWS EC2 Linux 2的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【aws】| 04 | AWS EC2 实例磁盘空间扩容

    进入控制台,选择 EBS - Volumes -Action - Modify Volume 首先使用lsblk可以查看附加到实例上的所有存储卷的真实size以及分区情况 注: 挂载在根目录上的是EBS存储卷上的分区而不是这个卷,而且卷被扩容但是分区大小不变依旧不能扩容。 xvda是一个存储卷,xvda1是存储卷上的一个分区

    2024年02月11日
    浏览(48)
  • AWS EC2实例管理

    针对近期学习的AWS EC2实例进行知识归纳与总结,欢迎家人们指正错误!ψ(`∇´)ψ AWS:亚马逊网络服务平台(亚马逊云服务平台)(Amazon Web Service) 英文全称:Amazon Elastic Compute Cloud 中文全称:亚马逊弹性计算云,又名“实例(instance)” 通俗理解:实例是 AWS 云中的 虚拟服

    2024年02月04日
    浏览(38)
  • AWS——01篇(AWS入门 以及 AWS之EC2实例及简单实用)

    什么是AWS? 好,我就截这么多,更多的自己搜搜看…… 官网地址如下: https://aws.amazon.com/cn/. 注册时,如果有谷歌邮箱,最好使用谷歌邮箱,如下: 按照提示注册成功之后,登录即可使用 随便点点,貌似看到了点东西 继续…… 3.1.1 入口 如下: 3.1.2 设置名称 + 选择服务 如

    2024年02月14日
    浏览(43)
  • AWS EC2的SSM配置(AWS云中的跳板机)

    开发人员需要访问AWS云中私有子网的数据库服务等,都需要通过EC2进行SSH隧道代理。这里假设本地已经有一款稳定优秀的SSH客户端工具,并且假设已经会熟练使用SSH的隧道代理。 搜索找到EC2服务,如下图: 点击“启动实例”,开始EC2实例创建,如下图: 填入名称后,选择默

    2024年02月02日
    浏览(28)
  • 【AWS】如何用SSH连接aws上的EC2实例(虚拟机)?

    目录 0.环境 1.连接结果示例 2.SSH连接思路 3.具体步骤 1)安装并运行ssh服务 2)启动ssh服务 3)在AWS上找到正在运行的EC2实例,并且根据提供的ssh连接语句进行连接 windows 11 64位 前提: 有aws账户(IAM),已经存在一个EC2实例(虚拟机) 首先,需要有AWS账户以及正在运行的EC2实

    2024年02月10日
    浏览(24)
  • 设置 AWS EC2 允许使用密码登录

    AWS 的服务器默认是使用秘钥进行登录,如果想要使用密码进行登录,可进行如下设置 1、先使用秘钥登录(安装aws网站上的教程即可) 2、登录之后为 root 创建密码 系统会让你输入两次密码,一定要注意了。 3、切换为root用户 4、编辑 sshd_config 并做修改 将  PasswordAuthenticati

    2024年02月11日
    浏览(78)
  • Prometheus 自动发现监控AWS EC2实例

    本文章简述对接自动发现AWS云EC2实例 前提环境: Promethues Grafana AWS IAM权限 涉及参考文档: AWS EC2 Grafana 通用监控模板 一、IAM 用户创建 1、创建Prometheus 策略 策略规则: 2、创建用户赋予Prometheus 策略 创建过程成,请下载ak、sk 此过程不演示。 二、配置Prometheus 可参考本文章进

    2024年02月04日
    浏览(57)
  • AWS EC2 服务启动显示磁盘挂载异常

    首先启动异常,在AWS网站中,肯定能定位到错误日志,找到实例,然后点击操作,找到监控和故障排除,然后找到日志,我这里日志问题如下: [0m] A start job is running for dev-xvdf.device (1min 29s / 1min 30s) [0m] A start job is running for dev-xvdf.device (1min 30s / 1min 30s) [0m] Timed out waiting for dev

    2024年02月13日
    浏览(35)
  • AWS EC2手动/自动切换Elastic IP

    一,手动切换 Elastic IP  1,进入ec2控制台,选中实例然后操作-联网-管理IP地址  2进入分配 Elastic IP页面,点击分配 3,分配 Elastic IP 4,配置 Elastic IP   5,关联ip地址 二,自动脚本更换实例ip地址 1,进入服务器设置aws configure,先到iam界面生成一个Access keys,然后到实例中配置Access keys  

    2024年02月11日
    浏览(22)
  • 通过FinalShell连接AWS的EC2服务器

    今天通过AWS的EC2服务器,搭建了一下ChatGPT的服务,体验了一把,通过FinalShell连接AWS的EC2服务器遇到了一个问题,记录一下。 小插曲 :(ChatGPT的服务后续将集成到“ 韭盾 ”公众号合“ 安前码后 ”公众号,一个是赚钱的号,一个是提升技术的号,可以体验一把) 第一次在

    2024年02月04日
    浏览(27)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包