-
Notifications
You must be signed in to change notification settings - Fork 573
Can AWS Credentials in Vagrantfile be programmatically grabbed? #151
Comments
Just use different AWS keypairs. |
How can I check the Vagrantfile in to a public repository, though? That's the real question. My use case is that I'd like people to be able to provision a local VirtualBox VM using the same Vagrantfile but then have anyone with ec2 creds be able to set them in their environment or something and launch an ec2 instance using vagrant-aws. |
hmm, I think you can have a conditional statement inside your unified Vagrantfile that would search for an env var, and use the proper provider accordingly. People with those env vars would launch on EC2, else plain local vbox. I will try this later and post my findings here. |
@tralamazza You might want to check out the approach taken by https://github.com/aws/aws-sdk-ruby/blob/master/lib/aws/core/credential_providers.rb#L89 |
@timvisher You could probably use multiple Vagrantfiles and make the conditionals based on AWS environment variables. |
see also #182 |
I think this is a good thing to allow to be stuck into a file in |
+1 on creating a file inside |
Someone made a little plugin that handles this problem https://github.com/maoueh/nugrant |
I'd just like to chip in and say this would be a useful feature for us. I'd also like to note that default location for amazon credentials files is ~/.aws/credentials these days (which is where Amazon tools read from) and other tools are starting to use that too. It would be good to keep it consistent. The format of that file is: where the non-default credentials are other credential sets that can be specified. |
As an interim solution, I got this working by externalizing the key and secret in their own files which can then be referenced in my
(The regex is necessary to remove any new lines or file termination characters that might be in the file - this had me flummoxed for a while. I think it'll remove anything that's not likely to appear in an AWS secret on the assumption that they use vanilla base64, which could be incorrect so the usual caveats apply.) Then I realised that I can do what tralamazza suggested because I've already loaded my credentials as environment variables (because I'm using the ec2.py script with ansible) so all I actually have to do is this:
Hope someone finds that helpful. |
+1 on the suggestion made by @yoshiwaan on using the I created an internal tool that gets a SAML assertion from our ADFS endpoint and gets a session token and writes it back to |
This is not a super big deal. If you're willing to install the AWS gem, you can get at the credentials using: aws_creds = Aws::SharedCredentials.new().credentials
$my_kname = aws_creds.access_key_id
$my_khash = aws_creds.secret_access_key I'm all for native vagrant support for the above so I'll leave this issue open but that's how I've solved things at this point. |
+1 for ~/.aws/credentials |
+1 for this plugin obtaining credentials the same way as AWS SDKs do. |
It seems it's fixed in PR #441. If you want to patch the existing version, try:
Then install
If won't work, revert the changes by:
|
It would also be useful to support SAML Auth for enterprise users:
|
This works, but PR #441 doesn't read AWS_PROFILE environment variable set. Ref: https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html#using-profiles I did a small change in PR #533, can you please review it. |
AFAICT this has been fixed for years. Sorry I left it open for so long. :) |
I'm trying to use vagrant for an open source project but I want to keep the people who can launch ec2 instances at a minimum. Is there any way to do this with vagrant aws?
The text was updated successfully, but these errors were encountered: