Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable using AWS services with ec2role #343

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions aws-cloudwatch/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down
18 changes: 12 additions & 6 deletions aws-cloudwatch/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ def auth_cloudwatch(self, access_key, secret_key, region):
},
)

self.cloudwatch = boto3.client(
'logs',
config = my_config,
aws_access_key_id = access_key,
aws_secret_access_key = secret_key,
)
if access_key!="":
self.cloudwatch = boto3.resource(
'logs',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
else:
self.cloudwatch = boto3.resource(
'logs',
config=my_config,
)
print(self.cloudwatch)
return self.cloudwatch

Expand Down
4 changes: 2 additions & 2 deletions aws-dynamodb/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down
18 changes: 12 additions & 6 deletions aws-dynamodb/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ def auth_dynamodb(self, access_key, secret_key, region):
},
)

self.dynamodb = boto3.resource(
'dynamodb',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
if access_key!="":
self.dynamodb = boto3.resource(
'dynamodb',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
else:
self.dynamodb = boto3.resource(
'dynamodb',
config=my_config,
)

return self.dynamodb

Expand Down
5 changes: 3 additions & 2 deletions aws-ec2/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down Expand Up @@ -63,6 +63,7 @@ actions:
returns:
schema:
type: string

- name: get_rules
description: Gets the rules for an ACL ID
parameters:
Expand Down
18 changes: 12 additions & 6 deletions aws-ec2/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ def auth_ec2(self, access_key, secret_key, region):
},
)

self.ec2 = boto3.resource(
'ec2',
config = my_config,
aws_access_key_id = access_key,
aws_secret_access_key = secret_key,
)
if access_key!="":
self.ec2 = boto3.resource(
'ec2',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
else:
self.ec2 = boto3.resource(
'ec2',
config=my_config,
)

return self.ec2

Expand Down
4 changes: 2 additions & 2 deletions aws-guardduty/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down
21 changes: 13 additions & 8 deletions aws-guardduty/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ def auth_guardduty(self, access_key, secret_key, region):
},
)

return boto3.client(
'guardduty',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)


if access_key!="":
return boto3.client(
'guardduty',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
else:
return boto3.client(
'guardduty',
config=my_config,
)

def create_detector(self, access_key, secret_key, region, enable):
client = self.auth_guardduty(access_key, secret_key, region)
try:
Expand Down
4 changes: 2 additions & 2 deletions aws-iam/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down
18 changes: 12 additions & 6 deletions aws-iam/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ def auth_iam(self, access_key, secret_key, region):
},
)

self.iam = boto3.resource(
'iam',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
if access_key!="":
self.iam = boto3.resource(
'iam',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
else:
self.iam = boto3.resource(
'iam',
config=my_config,
)

return self.iam

Expand Down
4 changes: 2 additions & 2 deletions aws-lambda/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down
20 changes: 13 additions & 7 deletions aws-lambda/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ def auth_lambda(self, access_key, secret_key, region):
'mode': 'standard'
},
)

return boto3.client(
'lambda',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)

if access_key!="":
return boto3.client(
'lambda',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
else:
return boto3.client(
'lambda',
config=my_config,
)


def list_functions(self, access_key, secret_key, region):
Expand Down
4 changes: 2 additions & 2 deletions aws-s3/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down
18 changes: 12 additions & 6 deletions aws-s3/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ def auth_s3(self, access_key, secret_key, region):
},
)

self.s3 = boto3.resource(
's3',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
if access_key!="":
self.s3 = boto3.resource(
's3',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
else:
self.s3 = boto3.resource(
's3',
config=my_config,
)

return self.s3

Expand Down
4 changes: 2 additions & 2 deletions aws-securityhub/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down
18 changes: 12 additions & 6 deletions aws-securityhub/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ def auth(self, access_key, secret_key, region):
},
)

return boto3.client(
'securityhub',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
if access_key!="":
return boto3.client(
'securityhub',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
else:
return boto3.client(
'securityhub',
config=my_config,
)

# Write your data inside this function
def enable_security_hub(self, access_key, secret_key, region):
Expand Down
4 changes: 2 additions & 2 deletions aws-ses/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down
18 changes: 12 additions & 6 deletions aws-ses/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ def auth_ses(self, access_key, secret_key, region):
},
)

self.ses = boto3.client(
'ses',
config = my_config,
aws_access_key_id = access_key,
aws_secret_access_key = secret_key,
)
if access_key!="":
self.dynamodb = boto3.resource(
'ses',
config=my_config,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
)
else:
self.dynamodb = boto3.resource(
'ses',
config=my_config,
)

return self.ses

Expand Down
4 changes: 2 additions & 2 deletions aws-waf/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ authentication:
- name: access_key
description: The access key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: secret_key
description: The secret key to use
example: "*****"
required: true
required: false
schema:
type: string
- name: region
Expand Down
Loading