Skip to content
Open
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
19 changes: 16 additions & 3 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from lib.graph.db import Neo4j
from lib.util.console import console

from configparser import NoOptionError, NoSectionError

SERVICES = list(Ingestor.__subclasses__())


Expand Down Expand Up @@ -75,16 +77,27 @@ def handle_ingest(args):

# Use existing profile
elif args.profile in Profile().credentials.sections():
session = boto3.session.Session(profile_name=args.profile,
try:
session = boto3.session.Session(profile_name=args.profile,
region_name=Profile().config.get(section=f"profile {args.profile}",option="region")
if not args.profile == 'default'
else Profile().config.get(section=f"{args.profile}",option="region"))
except (NoSectionError, NoOptionError):
session = boto3.session.Session(profile_name=args.profile,
region_name=args.region)
# Use instance profile
elif args.profile == "default":
try:
provider = InstanceMetadataProvider(
iam_role_fetcher=InstanceMetadataFetcher())
creds = provider.load()

session = boto3.session.Session(region_name=args.region,
try:
session = boto3.session.Session(region_name=Profile().config.get(section=f"{args.profile}",option="region"),
aws_access_key_id=creds.access_key,
aws_secret_access_key=creds.secret_key,
aws_session_token=creds.token)
except (NoSectionError, NoOptionError):
session = boto3.session.Session(region_name=args.region,
aws_access_key_id=creds.access_key,
aws_secret_access_key=creds.secret_key,
aws_session_token=creds.token)
Expand Down