Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

New service example #10

Merged
merged 2 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion Back-End/lambdas/receive_sqs_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,43 @@ def get_all_rds(account_number, region, cross_account_role):
return var_list


# Get EKS Function
def get_all_eks(account_number, region, cross_account_role):

# Init
var_list = []

# Change boto client
client_eks = create_boto_client(
account_number, region, 'eks', cross_account_role)

# Page all eks clusters
clusters = client_eks.list_clusters()
for i in clusters['clusters']:

eks_detail = client_eks.describe_cluster(name=i)['cluster']
cluster_tags = eks_detail['arn']
eks_tags = client_eks.list_tags_for_resource(resourceArn=cluster_tags)['tags']

var_list.append({
'AccountNumber': str(account_number),
'EntryType': str('eks'),
'Region': str(region),
'Name': str(eks_detail['name']),
'Arn': str(eks_detail['arn']),
'Status': str(eks_detail['status']),
'RoleArn': str(eks_detail.get('roleArn', ' ')),
'Created': str(eks_detail['createdAt']),
'VpcId': str(eks_detail['resourcesVpcConfig'].get('vpcId', ' ')),
'PlatformVersion': str(eks_detail['platformVersion']),
'K8 Version': str(eks_detail['version']),
'Endpoint': str(eks_detail['endpoint']),
'Tags': str(eks_tags)
})

return var_list


# Get EC2 Function
def get_all_ec2(account_number, region, cross_account_role):

Expand Down Expand Up @@ -747,6 +784,9 @@ def compare_and_update_function(account_number, region, sqs_function, cross_acco
elif sqs_function == 'ec2':
current_boto_list = get_all_ec2(
account_number, region, cross_account_role)
elif sqs_function == 'eks':
current_boto_list = get_all_eks(
account_number, region, cross_account_role)
elif sqs_function == 'rds':
current_boto_list = get_all_rds(
account_number, region, cross_account_role)
Expand Down Expand Up @@ -797,7 +837,6 @@ def compare_and_update_function(account_number, region, sqs_function, cross_acco
dynamo_list = get_current_table(
account_number=account_number, entry_type=sqs_function, region=region)


# Deep copy instead of double dynamo read
pop_dynamo = copy.deepcopy(dynamo_list)

Expand Down
6 changes: 3 additions & 3 deletions Back-End/lambdas/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
boto3==1.9.228
botocore==1.12.228
boto3==1.9.249
botocore==1.12.249
docutils==0.15.2
jmespath==0.9.4
python-dateutil==2.8.0
s3transfer==0.2.1
six==1.12.0
urllib3==1.25.3
urllib3==1.25.6
3 changes: 3 additions & 0 deletions Back-End/lambdas/send_sqs_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def lambda_handler(event, context):
'network-interfaces',
'vpc',
'ri',
'eks',
'testpass'
]

Expand Down Expand Up @@ -153,6 +154,8 @@ def lambda_handler(event, context):
accountNumber=i, function='lambda', region=b)
send_sqs_message(
accountNumber=i, function='ec2', region=b)
send_sqs_message(
accountNumber=i, function='eks', region=b)
send_sqs_message(
accountNumber=i, function='rds', region=b)
send_sqs_message(
Expand Down
2 changes: 2 additions & 0 deletions Front-End/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import MyTheme from "./components/AmplifyTheme";
import { Home } from './pages/Home';
import { Navigation } from './components/Navigation';
import AllEC2 from './pages/AllEC2';
import AllEKS from './pages/AllEKS';
import AllRDS from './pages/AllRDS';
import AllODCR from './pages/AllODCR';
import AllRis from './pages/AllRis';
Expand Down Expand Up @@ -62,6 +63,7 @@ class App extends Component {
<Navigation />
<Route exact path="/" component={Home} />
<Route path="/allec2" component={AllEC2} />
<Route path="/alleks" component={AllEKS} />
<Route path="/alllambda" component={AllLambda} />
<Route path="/Table" component={Table} />
<Route path="/allodcr" component={AllODCR} />
Expand Down
1 change: 1 addition & 0 deletions Front-End/src/components/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class Navigation extends Component {
<NavDropdown.Item href="/allec2">View All EC2 Instances</NavDropdown.Item>
<NavDropdown.Item href="/allris">View All RIs</NavDropdown.Item>
<NavDropdown.Item href="/allodcr">View All ODCRs</NavDropdown.Item>
<NavDropdown.Item href="/alleks">View All EKS</NavDropdown.Item>
<NavDropdown.Item href="/alllightsail">View All Lightsail Instances</NavDropdown.Item>
</NavDropdown>

Expand Down
126 changes: 126 additions & 0 deletions Front-End/src/pages/AllEKS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0

import React from 'react';
import { API } from 'aws-amplify';
import Table from './Table';

export default class AllEKS extends React.Component {
constructor(props) {
super(props)
this.state = {
instances: [],
isLoading: true
};
}

componentDidMount() {

// API Gateway
let apiName = 'MyAPIGatewayAPI';
let querypath = '/search/?scan=eks';

//Loading
this.setState({ isloading: true });

// Scan DynamoDB for results
API.get(apiName, querypath).then(response => {
this.setState({
instances: response,
isLoading: false
});
})
.then(response => {
console.log(this.state.instances)
})
.catch(error => {
this.setState({ error, isLoading: false })
console.log(error.response)
});
}
render() {

const { instances, isLoading, error } = this.state;

if (error) {
return <div className="default"><h1><center><br></br>{error.message}</center></h1></div>;
}

if (isLoading) {
return <div className="default"><h1><center><br></br>Loading ...</center></h1></div>;
}

const columns = [
{
dataField: 'Id',
text: 'Id',
hidden: true,
csvExport: false
}, {
dataField: 'AccountNumber',
text: 'Account',
sort: true
}, {
dataField: 'Region',
text: 'Region',
sort: true
}, {
dataField: 'Name',
text: 'Name',
sort: true
}, {
dataField: 'Status',
text: 'Status',
sort: true
}, {
dataField: 'PlatformVersion',
text: 'PlatformVersion',
sort: true
}, {
dataField: 'K8 Version',
text: 'K8Version',
sort: true
}, {
dataField: 'Endpoint',
text: 'Endpoint',
sort: true
}, {
dataField: 'Tags',
text: 'Tags',
sort: true,
hidden: true
},{
dataField: 'VpcId',
text: 'VpcId',
sort: true
}, {
dataField: 'RoleArn',
text: 'RoleArn',
sort: true,
hidden: true
}, {
dataField: 'Created',
text: 'Created',
sort: true,
hidden: true
}, {
dataField: 'Arn',
text: 'Arn',
sort: true,
hidden: true
},]

return (
<div className="default" style={{ padding: "20px", fontSize: "14px" }}>
<center><h2>All EKS Clusters</h2></center>
<br />
<Table data={instances}
columns={columns}
loading={isLoading}
id="Id"
sort="AccountNumber"
search="name" />
</div>
)
}
}
1 change: 1 addition & 0 deletions Front-End/src/pages/Refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Refresh extends React.Component {
<option value="iam-roles">IAM Roles</option>
<option value="iam-attached-policys">IAM Attached Policys</option>
<option value="vpc">VPC</option>
<option value="eks">EKS</option>
<option value="network-interfaces">Network Interfaces</option>
<option value="subnet">Subnets</option>
<option value="org">Organizations</option>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Serverless app designed for any customer with two or more accounts to view resou
Current working examples are:

- All AWS Accounts in Organizations
- All EC2, Lambdas, ODCR, EC2 Reserved Instances, RDS
- All EC2, Lambdas, ODCR, EC2 Reserved Instances, RDS, EKS
- All IAM Users, Roles, Policy’s
- All VPCs, Subnets
- All S3 Buckets
Expand Down