Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More details on how credentials work #9

Open
SolomonHD opened this issue Jun 19, 2019 · 4 comments
Open

More details on how credentials work #9

SolomonHD opened this issue Jun 19, 2019 · 4 comments

Comments

@SolomonHD
Copy link

SolomonHD commented Jun 19, 2019

Hi,
I usually use the AWS_PROFILE variable for any aws related tasks. This Capistrano plugin doesn't seem to recognize when I have a shell with the proper AWS_PROFILE loaded in. Can I have some details about how it works?

Here's what I have in our deploy/production.rb:

Aws.config.update({
  region: 'us-west-1',
  profile: ENV['AWS_PROFILE']
})
aws_ec2_register

set :aws_ec2_regions, ['us-west-1']
set :aws_ec2_name_tag, 'unique.name.tag.here'
set :aws_ec2_contact_point, :public_ip

What I'm trying to do is deploy to an EC2 with a specific name tag. The cap production aws:ec2:instances command doesn't return any instances

@fernandocarletti
Copy link
Owner

Hi @SolomonHD. This gem does not manage the any credentials to access AWS. This is done directly through the AWS SDK (as you can see here: https://github.com/aws/aws-sdk-ruby#configuration).

It does not seem properly documented in the link I provided, but there's a spec that covers this functionality (https://github.com/aws/aws-sdk-ruby/blob/97b28ccf18558fc908fd56f52741cf3329de9869/gems/aws-sdk-core/spec/aws/credential_provider_chain_spec.rb#L95)

Are you sure the env var is properly set? Try doing a quick debug on it by placing this piece of code on top of the config file, just to double check:

puts ENV['AWS_PROFILE']; exit;

@SolomonHD
Copy link
Author

So when I put the line you gave me at the top of deploy.rb it did output the profile I'm using. Now when I run the describe instances command it says cap aborted application not set

@SolomonHD
Copy link
Author

This is what I currently have:

#deploy.rb
Aws.config.update({
  region: 'us-east-1',
  profile: ENV['AWS_PROFILE']
})
aws_ec2_register

set :aws_ec2_stage, (proc { fetch(:stage) })
lock "~> 3.11.0"


set :application, "dlp-curate"
set :repo_url, "https://github.com/emory-libraries/dlp-curate.git"
set :deploy_to, '/opt/dlp-curate'
set :rails_env, 'production'
set :assets_prefix, "#{shared_path}/public/assets"

#production.rb

set :aws_ec2_name_tag, 'test.solomon.com'
set :aws_ec2_contact_point, :private_ip
set :aws_ec2_roles_tag, 'web, db, app'
set :aws_ec2_application_tag, 'dlp-curate'

@SolomonHD
Copy link
Author

SolomonHD commented Jul 1, 2019

My current config:

#production.rb
Aws.config.update({
  region: 'us-east-1',
  profile: ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'],
})
aws_ec2_register
#set :aws_ec2_application, (proc { fetch(:application) })
#set :aws_ec2_regions, ['us-east-1']
#set :aws_ec2_stage, (proc { fetch(:stage) })
#set :aws_ec2_stage_tag, 'production'
#set :aws_ec2_contact_point, :private_ip
#set :aws_ec2_roles_tag, 'web, db, app'
set :aws_ec2_extra_filters, [
  {
    name: "tag:Name",
    values: ["test.solomon.com"],
  },
]

Also, I tested out the aws-sdk (via aws-v3.rb)

It works fine and sees my instances with the ec2.describe_instances.reservations.first.instances.first command if I set AWS_PROFILE, it seems to ignore AWS_DEFAULT_PROFILE (as per aws/aws-sdk-ruby#2034)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants