Skip to content

Commit

Permalink
fix: undefined method
Browse files Browse the repository at this point in the history
Erro ao executar vagrant up --provider=aws.
Solução adicionar as seguintes linhas ao vagrante file:

class Hash
  def slice(*keep_keys)
    h = {}
    keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
    h
  end unless Hash.method_defined?(:slice)
  def except(*less_keys)
    slice(*keys - less_keys)
  end unless Hash.method_defined?(:except)
end

Solução foi encontrada nas referências abaixo.

mitchellh/vagrant-aws#568
mitchellh/vagrant-aws#566

 On branch master
 Changes to be committed:
	modified:   README.md
	modified:   Vagrantfile
  • Loading branch information
ricamos committed Sep 24, 2021
1 parent 703d89e commit 9070450
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ $ vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dumm
aws.access_key_id = "YOUR KEY"
aws.secret_access_key = "YOUR SECRET KEY"
```

Estas duas variaveis são preenchidas com chaves obtidas no [console do IAM](https://console.aws.amazon.com/iam) de sua conta AWS e devem ser mantidas em segredo.

#### [Amazon Machine Images (AMI)](https://docs.aws.amazon.com/pt_br/AWSEC2/latest/UserGuide/AMIs.html)
Expand Down Expand Up @@ -75,6 +74,12 @@ Ao invés de [criar um par de chaves usando o Amazon EC2](https://docs.aws.amazo

[Abra o console do Amazon EC2]( https://console.aws.amazon.com/ec2/) em Redes e segurança selecione pares de chaves. Em ações selecione importar pares de chaves e cole o conteúdo do arquivo vagrant.pub criado anteriormente. Em nosso exemplo nomeamos esta chave no console AWS como vagrant.

#### Interação com o ambiente.
```
$ vagrant up --provider=aws
$ vagrant destroy -f
```

## Autor e referências <a name="autor"></a>
Ricardo Coelho

Expand Down
12 changes: 12 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

class Hash
def slice(*keep_keys)
h = {}
keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
h
end unless Hash.method_defined?(:slice)
def except(*less_keys)
slice(*keys - less_keys)
end unless Hash.method_defined?(:except)
end

Vagrant.configure("2") do |config|
config.vm.box = "dummy"
config.vm.provider :aws do |aws, override|
aws.access_key_id = "AKIASIX4VFN7ZA45UZOB"
aws.secret_access_key = "IdevldVEJG/2uFmtujunplOFJ2/HzcgSstdzPLVx"


aws.ami = "ami-02e2a5679226e293c"

override.ssh.username = "admin"
Expand Down

0 comments on commit 9070450

Please sign in to comment.