nonebot_plugin_awsmgmt
一个用于 AWS 管理的 NoneBot2 插件。
使用方法
EC2
/ec2_start [target]/ec2_stop [target]/ec2_reboot [target]/ec2_status [target]
Target (目标):
tag:Key:Value: 例如tag:Project:MyProjectid:i-xxxx: 例如id:i-0fd0acc80b595ac71
如果未提供 target,插件将使用您在配置中设置的 aws_default_target_tag(如果已设置)。
Lightsail
/lightsail_list/lightsail_start <实例名称>/lightsail_stop <实例名称>
Cost Explorer (成本管理器)
/aws_cost today(今日成本)/aws_cost month(本月成本)/aws_cost month by_service(按服务划分的本月成本)
安装
-
安装插件
pip install nonebot-plugin-awsmgmt
-
在 NoneBot2 项目中加载插件
在
bot.py或pyproject.toml中添加nonebot_plugin_awsmgmt到插件列表。例如,在
pyproject.toml中:[tool.nonebot] plugins = ["nonebot_plugin_awsmgmt"]
-
配置 AWS 凭证
在您的 NoneBot2 项目的
.env文件中配置您的 AWS 访问密钥和秘密访问密钥:AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY AWS_REGION_NAME=your-aws-region # 例如: us-east-1
AWS 侧配置
为了使插件能够管理您的 AWS 资源,您需要在 AWS IAM 中创建一个具有适当权限的用户。
1. 创建 IAM Policy
创建一个新的 IAM Policy,并粘贴以下 JSON 内容。您可以根据需要修改此策略以限制权限。
Policy JSON (aws-policy.json):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:RebootInstances"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:StartInstances",
"ec2:StopInstances"
],
"Resource": "arn:aws:ec2:*:*:instance/*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/ManagedBy": "nonebot-plugin-awsmgmt"
}
}
},
{
"Effect": "Allow",
"Action": [
"lightsail:GetInstances",
"lightsail:GetInstance",
"lightsail:StartInstance",
"lightsail:StopInstance"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ce:GetCostAndUsage"
],
"Resource": "*"
}
]
}
步骤:
- 登录 AWS 管理控制台。
- 导航到 IAM 服务。
- 在左侧导航栏中选择 Policies。
- 点击 Create policy。
- 选择 JSON 选项卡,并粘贴上述 Policy JSON 内容。
- 点击 Next: Tags,然后点击 Next: Review。
- 为策略命名(例如:
NoneBotAWSPolicy),并添加描述。 - 点击 Create policy。
2. 创建 IAM 用户并附加策略
创建一个新的 IAM 用户,并为其提供编程访问权限,然后附加您刚刚创建的策略。
步骤:
- 在 IAM 服务中,选择左侧导航栏中的 Users。
- 点击 Add user。
- 输入用户名(例如:
nonebot-aws-user)。 - 在 Select AWS access type 部分,勾选 Programmatic access。
- 点击 Next: Permissions。
- 选择 Attach existing policies directly。
- 搜索并选择您刚刚创建的策略(例如:
NoneBotAWSPolicy)。 - 点击 Next: Tags,然后点击 Next: Review。
- 点击 Create user。
- 重要: 记录下生成的 Access key ID 和 Secret access key。这些将用于配置 NoneBot2 插件。这些凭证只显示一次,请务必妥善保管。
Metadata
Release files for nonebot-plugin-awsmgmt 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot_plugin_awsmgmt-0.1.3.tar.gz | 11.3 kB | Without provenance | Details for nonebot_plugin_awsmgmt-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_plugin_awsmgmt-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for nonebot_plugin_awsmgmt-0.1.3-py3-none-any.whl |
Total release size: 24.4 kB
Release files / nonebot_plugin_awsmgmt-0.1.3.tar.gz
| Download URL | nonebot_plugin_awsmgmt-0.1.3.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30f9846bdc342218af9aa03ab5f5f361e7c059ba1e60bf507fc2953d35c0d8c9
|
|
BLAKE2b-256 checksum How to use checksums |
9f7417a8ef663d102c1fcc42c7993daac15056f61413d478a25707b7f3769496
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.15
|
Release files / nonebot_plugin_awsmgmt-0.1.3-py3-none-any.whl
| Download URL | nonebot_plugin_awsmgmt-0.1.3-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44824f207460d361d964d136a3116a84a4b8e82beb8fbe0a259cdf71496f8663
|
|
BLAKE2b-256 checksum How to use checksums |
4f6a62091418639b231e8336f5818bef675227eaab2af24650ca95b255e3fc14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.15
|
Security for nonebot-plugin-awsmgmt 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.