Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The environment variable AWS_ACCESS_KEY_ID must be set

I am using Linux 18.04 and I want to lunch a spark cluster on EC2.

I used the export command to set environment variables

export AWS_ACCESS_KEY_ID=MyAccesskey
export AWS_SECRET_ACCESS_KEY=Mysecretkey

but when I run the command to lunch the spark cluster I get

ERROR: The environment variable AWS_ACCESS_KEY_ID must be set

I put all the commands I used in case I made a mistake:


sudo mv ~/Downloads/keypair.pem   /usr/local/spark/keypair.pem
sudo mv ~/Downloads/credentials.csv   /usr/local/spark/credentials.csv
# Make sure the .pem file is readable by the current user.
chmod 400 "keypair.pem"
# Go into the spark directory and set the environment variables with the credentials information
cd spark
export AWS_ACCESS_KEY_ID=ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=SECRET_KEY
# To install Spark 2.0 on the cluster:
sudo spark-ec2/spark-ec2 -k keypair --identity-file=keypair.pem --region=us-west-2 --zone=us-west-2a --copy-aws-credentials --instance-type t2.micro --worker-instances 1 launch project-launch

I am new to these things and any help is really appreciated

like image 856
G. Hak. Avatar asked Nov 17 '25 08:11

G. Hak.


1 Answers

You can also retrieve the value AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY by using the get subcommand for aws configure:

AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id)
AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key) 

In command line:

sudo AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id) AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key) spark-ec2/spark-ec2 -k keypair --identity-file=keypair.pem --region=us-west-2 --zone=us-west-2a --copy-aws-credentials --instance-type t2.micro --worker-instances 1 launch project-launch

source: AWS Command Line Interface User Guide

like image 145
zeroA11 Avatar answered Nov 19 '25 01:11

zeroA11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!