获取aws数据的git远程帮助程序

git-remote-aws的Python项目详细描述


git远程aws PyPI version

git-remote-aws是一个git remote helper用于从aws帐户提取数据,就像从git远程服务器提取数据一样。

GitlabGithub上发布的存储库

网站发布于https://git-remote-aws.autofitcloud.com

查看自述文件底部的愿望列表以了解未来的计划。

新闻2019-08-23: 我昨晚在r/git上发布了这个项目, 今天早上醒来发现它在Subreddit上面! R/Git太棒了! Screenshot

更多新闻2019-08-23: 显然,我的十字架也在一夜之间到达了3号!Screenshot

安装

sudo apt-get install git python3 python3-pip

pip install awscli git-remote-aws

基本用法

使用aws密钥和密钥配置awscli(如果已经完成,请跳过此步骤)

aws configure

配置的角色或用户应附加以下策略的子集(或全部)

AmazonEC2ReadOnlyAccess
AWSCloudTrailReadOnlyAccess
CloudWatchReadOnlyAccess

初始化新的Git回购

TMPDIR=`mktemp -d`
cd $TMPDIR
git init

为ec2添加aws remotes描述实例、列表度量等。

git remote add ctle_ec2Typechanges      aws+cloudtrail::/lookup-events?filter=ec2TypeChanges
git remote add cw_descAlarms      aws+cw::/describe-alarms
git remote add cw_getMetricData   aws+cw::/get-metric-data
git remote add cw_listMetrics     aws+cw::/list-metrics
git remote add ec2_descInstances  aws+ec2::/describe-instances
git remote add sns_listTopics     aws+sns::/list-topics

从所有远程设备获取数据。

git fetch --all

这将创建一个文件夹aws.amazon.com,其目录结构包含相关数据

> tree
.
└── aws.amazon.com
    └── us-west-2
        └── ec2_describeInstances
        │   ├── i-02432bc7.json
        │   ├── i-069a7808addd143c7.json
        │   ├── i-08c802de5accc1e89.json
        │   ├── i-0e2662888859c5507.json
        │   ├── i-0fb05d874895a05ec.json
        │   ├── i-34ca2fc2.json
        │   └── i-e1ca46eb.json
        └── ...

4 directories, 11 files

高级用法

awscli配置文件

要使用~/.aws/credentials中的配置文件而不是默认配置文件, 将?profile=<optional profile name to use>附加到远程url。

BOTO3选项

附加其他boto3会话构造函数参数 here, 将?boto3_session_config=path/to/file附加到远程url, 其中path/to/file指向一个json文件,该文件包含来自boto3会话构造函数的参数。

例如,

{ "aws_access_key_id": "ABC", "aws_secret_access_key": "ABC", ...}

注意:describe-instances端点的默认行为是将ec2描述子集为最小值。 要获得完整的ec2描述,请将?fulldata=true附加到端点。

Git推送遥控器

按下Git遥控器

git add aws.amazon.com
git commit -m 'first commit'

git remote add origin git@gitlab.com:shadiakiki1986/shadiakiki1986.aws.amazon.com-json.git
git push -u origin master

承保服务

目前涵盖以下AWS服务

ServiceCommandNotes
EC2describe-instances-
Cloudtraillookup-eventsCustom filter of results for EC2 instance type changes.
Cloudwatchlist-metrics-
Cloudwatchget-metric-data-
Cloudwatchdescribe-alarms-
SNSlist-topics-

每个服务所需的策略/权限

ServicePolicy
EC2AmazonEC2ReadOnlyAccess
CloudtrailAWSCloudTrailReadOnlyAccess
CloudwatchCloudWatchReadOnlyAccess
SNS-

aws/moto端点

远程url的完整结构如下所示

git remote add example_1 aws+<service>::<endpoint url>/<command>?profile=<optional profile name to use>&boto3_session_config=path/to/file

其中

  • serviceec2cw(cloudwatch),sns
  • endpoint url是要使用的aws端点
    • 为默认aws端点留空,或为模拟aws服务使用moto
  • command:根据上面的service,这可以是
    • ec2
      • describe-instances
      • catalog(这不是正式的aws服务,而是从https://www.ec2instances.info填充的。检查下面“开发人员说明”中的相关说明)
    • cw
      • list-metrics
      • get-metric-data
      • describe-alarms
    • sns
      • list-topics
  • profile是来自~/.aws/credentials的配置文件名。
    • 一次只支持一个profileatm,checkissue #5
  • boto3_session_config是一个json文件,包含与boto3会话构造函数参数相对应的键值对。
    • 这是可选的
    • BOTO3会话的文档是here
    • 一次只支持一个boto3_session_configatm,checkissue #5

示例

# get from AWS using the default profile in ~/.aws/credentials
git remote add example_1_ec2 aws+ec2::/describe-instances
git remote add example_1_catalog aws+ec2::/catalog
git remote add example_1_cwListMetrics aws+cw::/list-metrics

# Specific aws endpoint
git remote add example_3 aws+ec2::http://ec2.us-west-2.amazonaws.com/describe-instances

# use a specific profile and AWS default endpoints
git remote add example_2 aws+ec2::/describe-instances?profile_name=profile&boto3_session_config=path/to/file

提取数据

git fetch example_1_ec2
git fetch example_1_catalog

开发人员注释

检查DEVELOPER.md

愿望列表

下面是从redditr/gitr/aws中提出的功能列表

  • Issue #1:将推送功能添加到aws+ec2://describe instances remote
  • Issue #2:如果可能,git fetch应该构建一个历史记录

支架

我创建了git-remote-aws作为AutofitCloud背后工作流程的一部分,这是我正在创建的一个早期初创企业,旨在减少地球上的云浪费。

如果你想git-remote-aws并希望看到它进一步发展, 请通过在https://autofitcloud.com注册来支持我

一遍又一遍!

--u/shadiakiki1986

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
我可以用C++代码使用java代码吗?   java使用JSR303在派生类中提供更具体的约束   java在这个查找唯一路径数算法中我做错了什么?   java如何为2个不同的服务提供商使用2个不同的SSL证书?   java在Gridview上绘制文本   java使用连接for循环构建字符串名   java StringBuilder拆分无法处理某些文件   java事件关注EditText   Java Web Start“找不到URL的缓存资源”   java程序从命令行运行的速度比在Eclipse中慢   java为什么HttpServletRequest会截断#字符上的url输入?   java自定义折叠工具栏平滑标题大小调整   使用Mockito对安卓 java中调用另一个静态函数的函数进行单元测试   http在java客户机中使用cachecontrol头   java如何使用。是否使用Delimiter从输入文件中排除标点符号和数字?   使用上下文作为参数/参数的java   java更有效地从Jar中提取文件   java为多个JButton提供相同的actionListener