I have a job processing architecture based on AWS that requires EC2 instances query S3 and SQS. In order for running instances to have access to the API the credentials are sen
You can store the credentials on the machine (or transfer, use, then remove them.)
You can transfer the credentials over a secure channel (e.g. using scp
with non-interactive authentication e.g. key pair) so that you would not need to perform any custom encryption (only make sure that permissions are properly set to 0400
on the key file at all times, e.g. set the permissions on the master files and use scp -p
)
If the above does not answer your question, please provide more specific details re. what your setup is and what you are trying to achieve. Are EC2 actions to be initiated on multiple nodes from a central location? Is SSH available between the multiple nodes and the central location? Etc.
EDIT
Have you considered parameterizing your AMI, requiring those who instantiate your AMI to first populate the user data (ec2-run-instances -f user-data-file
) with their AWS keys? Your AMI can then dynamically retrieve these per-instance parameters from http://169.254.169.254/1.0/user-data
.
UPDATE
OK, here goes a security-minded comparison of the various approaches discussed so far:
user-data
unencrypted
telnet
, curl
, wget
, etc. (can access clear-text http://169.254.169.254/1.0/user-data
)http://169.254.169.254/1.0/user-data
)user-data
and encrypted (or decryptable) with easily obtainable key
telnet
, curl
, wget
, etc. (can access clear-text http://169.254.169.254/1.0/user-data
)http://169.254.169.254/1.0/user-data
, ulteriorly descrypted with the easily-obtainable key)user-data
and encrypted with not easily obtainable key
telnet
, curl
, wget
, etc. (can access encrypted http://169.254.169.254/1.0/user-data
)
root
for interactive impersonation) improves securitySo any method involving the AMI user-data
is not the most secure, because gaining access to any user on the machine (weakest point) compromises the data.
This could be mitigated if the S3 credentials were only required for a limited period of time (i.e. during the deployment process only), if AWS allowed you to overwrite or remove the contents of user-data
when done with it (but this does not appear to be the case.) An alternative would be the creation of temporary S3 credentials for the duration of the deployment process, if possible (compromising these credentials, from user-data
, after the deployment process is completed and the credentials have been invalidated with AWS, no longer poses a security threat.)
If the above is not applicable (e.g. S3 credentials needed by deployed nodes indefinitely) or not possible (e.g. cannot issue temporary S3 credentials for deployment only) then the best method remains to bite the bullet and scp
the credentials to the various nodes, possibly in parallel, with the correct ownership and permissions.