I am trying to execute this command programmatically with python 2.7:
aws configure --profile name_profile
The thing is that this command as soon as you executed it, it ask the user to input some parameters:
$ aws configure
AWS Access Key ID [****]: access_key_input
AWS Secret Access Key [****]: secret__key_input
Default region name [us-west-1]: region_optional_input
I know how to execute commands in python, usually with these lines you are done:
def execute_command(command):
try:
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate()
return output, error
except Exception as error:
return None, error
But in this case, I don't know how to simulate this process. I want to write something like
def add_profile(access_key, access_secret, name_profile, region=None)
And that should execute the command of before and answer the questions with the parameters.
Thanks in advance to all.