Skip to main content

Add your description here

Project description

nonebot_plugin_awsmgmt

A NoneBot2 plugin for AWS management.

使用方法

  1. 安装插件

    pip install nonebot-plugin-awsmgmt
    
  2. 在 NoneBot2 项目中加载插件

    bot.pypyproject.toml 中添加 nonebot_plugin_awsmgmt 到插件列表。

    例如,在 pyproject.toml 中:

    [tool.nonebot]
    plugins = ["nonebot_plugin_awsmgmt"]
    
  3. 配置 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": "*"
        }
    ]
}

步骤:

  1. 登录 AWS 管理控制台。
  2. 导航到 IAM 服务。
  3. 在左侧导航栏中选择 Policies
  4. 点击 Create policy
  5. 选择 JSON 选项卡,并粘贴上述 Policy JSON 内容。
  6. 点击 Next: Tags,然后点击 Next: Review
  7. 为策略命名(例如:NoneBotAWSPolicy),并添加描述。
  8. 点击 Create policy

2. 创建 IAM 用户并附加策略

创建一个新的 IAM 用户,并为其提供编程访问权限,然后附加您刚刚创建的策略。

步骤:

  1. 在 IAM 服务中,选择左侧导航栏中的 Users
  2. 点击 Add user
  3. 输入用户名(例如:nonebot-aws-user)。
  4. Select AWS access type 部分,勾选 Programmatic access
  5. 点击 Next: Permissions
  6. 选择 Attach existing policies directly
  7. 搜索并选择您刚刚创建的策略(例如:NoneBotAWSPolicy)。
  8. 点击 Next: Tags,然后点击 Next: Review
  9. 点击 Create user
  10. 重要: 记录下生成的 Access key IDSecret access key。这些将用于配置 NoneBot2 插件。这些凭证只显示一次,请务必妥善保管。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_awsmgmt-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_awsmgmt-0.1.0-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_awsmgmt-0.1.0.tar.gz.

File metadata

  • Download URL: nonebot_plugin_awsmgmt-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for nonebot_plugin_awsmgmt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dadd2862afc224b5d60a151e27af79d347e481645745222348c233f104427316
MD5 fa151176e4e8819c98e537a7920a4ab7
BLAKE2b-256 cac79c9cfa9eca21ded5091e88a7d9e89a6eb78170fc888797856edbda3516ab

See more details on using hashes here.

File details

Details for the file nonebot_plugin_awsmgmt-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_awsmgmt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71c705c0601e726b182e844549b4436ac4936a7ed7c1d955401550b1ef3be2bd
MD5 56970562f50a99250ed9b5b859e4462f
BLAKE2b-256 cd8fc71031b633ab004ab580a19f4f01898cced6b8aeb58da3bd2443cbc8fd73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page