Skip to content
Closed
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
added option for specifying AWS credential profile
# Need

Utilizing AWS profiles is considered best practice: https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs

# Solution

Added option to connect to AWS by specifying credential profile.
  • Loading branch information
neil-rubens committed Oct 8, 2015
commit fb260f0ed0ba6616d58249248d3cca44f942aef0
9 changes: 8 additions & 1 deletion ec2/spark_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ def parse_args():
parser.add_option(
"--instance-profile-name", default=None,
help="IAM profile name to launch instances under")
parser.add_option(
"--aws-profile-name", default=None,
help="Use aws profile credentials")


(opts, args) = parser.parse_args()
if len(args) != 2:
Expand Down Expand Up @@ -1315,7 +1319,10 @@ def real_main():
sys.exit(1)

try:
conn = ec2.connect_to_region(opts.region)
if opts.aws_profile_name != None:
conn = ec2.connect_to_region(opts.region, profile_name = opts.aws_profile_name)
else:
conn = ec2.connect_to_region(opts.region)
except Exception as e:
print((e), file=stderr)
sys.exit(1)
Expand Down