获取aws数据的git远程帮助程序
git-remote-aws的Python项目详细描述
git远程aws
git-remote-aws
是一个git remote helper用于从aws帐户提取数据,就像从git远程服务器提取数据一样。
网站发布于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服务
Service | Command | Notes |
---|---|---|
EC2 | describe-instances | - |
Cloudtrail | lookup-events | Custom filter of results for EC2 instance type changes. |
Cloudwatch | list-metrics | - |
Cloudwatch | get-metric-data | - |
Cloudwatch | describe-alarms | - |
SNS | list-topics | - |
每个服务所需的策略/权限
Service | Policy |
---|---|
EC2 | AmazonEC2ReadOnlyAccess |
Cloudtrail | AWSCloudTrailReadOnlyAccess |
Cloudwatch | CloudWatchReadOnlyAccess |
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
其中
service
是ec2
,cw
(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
的配置文件名。- 一次只支持一个
profile
atm,checkissue #5
- 一次只支持一个
boto3_session_config
是一个json文件,包含与boto3会话构造函数参数相对应的键值对。
示例
# 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
愿望列表
支架
我创建了git-remote-aws
作为AutofitCloud背后工作流程的一部分,这是我正在创建的一个早期初创企业,旨在减少地球上的云浪费。
如果你想git-remote-aws
并希望看到它进一步发展,
请通过在https://autofitcloud.com注册来支持我
一遍又一遍!