Skip to content

Commit a866336

Browse files
committed
updaing readme and fixing a small profile issue.
1 parent c789f7c commit a866336

10 files changed

+122
-19
lines changed

README.md

+87-6
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,98 @@ Lists all resources in a AWS account.
1414

1515
* Runs a single operation
1616

17+
* CLI Support
18+
19+
## Overview
20+
21+
AWSRetriever scans sets of predefined `AWS` APIs, saved in "profile" files.
22+
23+
Profiles are `json` based files, holding a (potentially) very long list of operations to run. AWSRetriever is shipped with a `default.profile.js`, that holds a generic wide-variety of calls.
24+
25+
The profile is scanned when choosing "Full Scan" from the side-bar menu, or using the command-line parameter `-p` (combined with `-r`)
26+
27+
Profiles can be saved & loaded. The default profile loaded is defined in the configuration file.
28+
29+
A typical use-case is to define and test profiles for various AWS resources views and then use the CLI to periodically retrieve the items from AWS.
30+
31+
### Command-line interface
32+
33+
To export all items provided in my `ec2.profile.js`, and save them in `object.json`, use the following switches:
34+
35+
```PS
36+
>AWSRetriever.exe -r -p ec2.profile.js -o objects.json
37+
AWS Retriever
38+
Using profile: 'ec2.profile.js'
39+
Writing to 'objects.json'
40+
Queueing from 'default' profile...1825 operations queued.
41+
Scanning...
42+
```
43+
44+
To export all items to `myobjects.json` using the default profile and settings:
45+
```PS
46+
>AWSRetriever.exe -r -o myobjects.json
47+
AWS Retriever
48+
Using profile: 'default.profile.js'
49+
Writing to 'myobjects.json'
50+
Queueing from 'default' profile...1825 operations queued.
51+
Scanning...
52+
EC2 DescribeInternetGateways ap-northeast-1: 1 items retrieved
53+
EC2 DescribeInternetGateways ap-south-1: 1 items retrieved
54+
EC2 DescribeInternetGateways ap-northeast-2: 1 items retrieved
55+
EC2 DescribeInternetGateways ca-central-1: 1 items retrieved
56+
.
57+
.
58+
.
59+
```
60+
61+
The resulting `myobjects.json` file, holds a JSON array with the following structure:
62+
```json
63+
[
64+
{ "Type" : "InternetGateway", // the type of the object listed
65+
"Service" : "EC2", // the service it was retrieved from
66+
"Region" : "ap-northeast-2", // the region
67+
"Source" : { //the object itself, will change according to the object
68+
"Attachments": [
69+
{
70+
"State": {
71+
"Value": "available"
72+
},
73+
"VpcId": "vpc-e2e9f18a"
74+
}
75+
],
76+
"InternetGatewayId": "igw-0562ad6d",
77+
"OwnerId": "000000000000",
78+
"Tags": []
79+
}}
80+
,
81+
.
82+
.
83+
.
84+
```
85+
86+
### Profile Record
87+
88+
Each profile record holds:
89+
```json
90+
{
91+
"ServiceName": "EC2", // AWS service to execute
92+
"Name": "DescribeInternetGateways", // Specific API to execute
93+
"Regions": "ap-northeast-1 ap-northeast-2 ap-south-1 ap-southeast-1 ap-southeast-2 ca-central-1 eu-central-1 eu-north-1 eu-west-1 eu-west-2 eu-west-3 sa-east-1 us-east-1 us-east-2 us-west-1 us-west-2", // a list of regions to call
94+
"Enabled": true, // if false, this API is skipped
95+
"PageSize": 18 // if this API supports paging, this value will be the page size for each request.
96+
},
97+
```
98+
1799
## Download & Run
18100

19101
Download [the latest](https://github.com/dtylman/AWSRetriever/releases/) for Windows or Linux.
20102

21103
### Windows
22104

23-
1. (Requires .NET 4.5)
105+
1. Requires `.NET`
24106
1. Create a folder `AWSRetriever`
25107
1. Unzip to folder.
26-
1. Run `AWSRetriver.exe`
108+
1. Run `AWSRetriever.exe`
27109

28110
### Linux / Ubuntu
29111

@@ -48,14 +130,13 @@ mono AWSRetriver.exe
48130

49131
### Profile Editor
50132

51-
![profile-editor](./doc/profile-editor1.PNG)
133+
![profile-editor](./doc/profile-editor.PNG)
52134

53-
### Lanching a specific API
135+
### Launching a specific API
54136

55137
![single-operation](./doc/single-operation.PNG)
56138

57-
58139
### Thanks
59140

60-
* [Modern UI Done RIght](https://github.com/NickAcPT/ModernUIDoneRight)
141+
* [Modern UI Done Right](https://github.com/NickAcPT/ModernUIDoneRight)
61142
* [Icons8](https://icons8.com/license/)

Retriever/ConsoleScanner.cs

+18-10
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ public class ConsoleScanner
1818
private AWSCredentials creds;
1919

2020

21-
public void Scan(string outputFile)
21+
public void Scan(string outputFile, string profile)
2222
{
23+
Console.WriteLine(String.Format("Using profile: '{0}'", profile));
2324
Console.WriteLine(String.Format("Writing to '{0}'", outputFile));
2425
swout = new StreamWriter(outputFile);
2526
swout.WriteLine("[");
@@ -38,7 +39,7 @@ public void Scan(string outputFile)
3839
throw new ApplicationException(String.Format("No credentials provided. Edit in configuration file: '{0}'",
3940
Configuration.Instance.ConfigFileName));
4041
}
41-
this.profile = Profile.Load(Configuration.Instance.Profile);
42+
this.profile = Profile.Load(profile);
4243
QueueOperations();
4344
Console.WriteLine("Scanning...");
4445
this.scanner.Scan();
@@ -57,15 +58,22 @@ private void Progress_ProgressChanged(object sender, OperationResult e)
5758
e.Operation.ServiceName, e.Operation.Name, e.Operation.Region.SystemName, e.ResultText()));
5859
if (!e.IsError())
5960
{
60-
foreach (CloudObject cobo in e.Operation.CollectedObjects)
61-
{
62-
swout.WriteLine("" +
63-
" {" +
64-
" \"Type\" : \"" + cobo.TypeName + "\",");
65-
swout.WriteLine(
66-
" \"Source\" : " + cobo.Source + ",},");
67-
61+
var iter = e.Operation.CollectedObjects.GetEnumerator();
62+
do
63+
{
64+
CloudObject cobo = iter.Current;
65+
if (cobo == null)
66+
{
67+
continue;
68+
}
69+
swout.WriteLine("{ \"Type\" : \"" + cobo.TypeName + "\",");
70+
swout.WriteLine(" \"Service\" : \"" + cobo.Service+ "\",");
71+
swout.WriteLine(" \"Region\" : \"" + cobo.Region+ "\",");
72+
swout.WriteLine(" \"Source\" : " + cobo.Source + "}");
73+
swout.WriteLine(",");
6874
}
75+
while (iter.MoveNext());
76+
6977
swout.Flush();
7078
}
7179
}

Retriever/Program.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ static void Main()
5858
{
5959
AppMain(consoleAttached);
6060
}
61+
catch (Exception ex)
62+
{
63+
var debug = Environment.GetEnvironmentVariable("AWSRetriever_DEBUG");
64+
if (!string.IsNullOrEmpty(debug))
65+
{
66+
Console.WriteLine(ex);
67+
}
68+
Console.WriteLine(ex.Message);
69+
}
6170
finally
6271
{
6372
if (consoleAttached)
@@ -72,7 +81,7 @@ private static void AppMain(bool consoleAttached)
7281
{
7382
if (consoleAttached)
7483
{
75-
Console.WriteLine("AWS Retriver");
84+
Console.WriteLine("AWS Retriever");
7685
}
7786
FluentCommandLineParser<ProgramArgs> p = new FluentCommandLineParser<ProgramArgs>();
7887
p.Setup(arg => arg.RunNow).As('r', "run").SetDefault(false).WithDescription("Run now");
@@ -98,7 +107,12 @@ private static void AppMain(bool consoleAttached)
98107
if (p.Object.RunNow)
99108
{
100109
ConsoleScanner cs = new ConsoleScanner();
101-
cs.Scan(p.Object.OutFile);
110+
string profile = p.Object.ProfileFile;
111+
if (string.IsNullOrEmpty(profile))
112+
{
113+
profile = Configuration.Instance.Profile;
114+
}
115+
cs.Scan(p.Object.OutFile,profile);
102116
}
103117
else
104118
{

Retriever/Retriever.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<ProductName>AWSRetriever</ProductName>
3131
<PublisherName>AWSRetriever</PublisherName>
3232
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
33-
<ApplicationRevision>7</ApplicationRevision>
33+
<ApplicationRevision>8</ApplicationRevision>
3434
<ApplicationVersion>0.1.0.%2a</ApplicationVersion>
3535
<UseApplicationTrust>false</UseApplicationTrust>
3636
<CreateDesktopShortcut>true</CreateDesktopShortcut>

doc/main-screen.PNG

-10.8 KB
Loading

doc/profile-editor.PNG

-31.7 KB
Loading

doc/profile-editor1.PNG

-50.5 KB
Binary file not shown.

doc/single-operation.PNG

831 Bytes
Loading

doc/with-menu.PNG

83.6 KB
Loading

doc/with-menu1.PNG

-73.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)