AWS EC2 Windows Instance User Data and Task Scheduler

I am attempting to spin up a python script that uses the boto3 client at startup. I’m using Task Scheduler to do so. However, if using the SYSTEM user to start the task I get a script error that the AWS profile I have set in my environment variables can’t be found ("botocore.exceptions.profilenotfound: the config profile (default) could not be found").
I recognize that this may be that I need to edit the config file in the .aws folder. However, I don’t know where that is located for the SYSTEM user in windows. By the way, the task works running under administrator when running it manually.

I can not run this task as any other user due to my organizations group policy around storing passwords and will not allow "Do not store password" to not be ticked in the task setup. If I run the task with "Do not store password" not ticked I get that the task failed on startup with error code 2147943711.

I have also attempted this as user-data script. It works as a first boot option but as soon as I place in the "persist" tag the persistent user-data execution is placed in the Windows Task Scheduler to run under SYSTEM user and the issues stated above apply.

Surely I’m not the first to run into this issue?

Source: Windows Questions

LEAVE A COMMENT