puppetlabs-toy-chest / puppetlabs-aws

Puppet module for managing AWS resources to build out infrastructure
Apache License 2.0
187 stars 217 forks source link

Error creating ec2 instance #299

Open hesamaseh opened 8 years ago

hesamaseh commented 8 years ago

Hi

im getting the error below when im trying to create an ec2 instance ? any ideas on whats the problem ?

[root@tocwcds5ic aws]# puppet apply create.pp Notice: Compiled catalog for tocwcds5ic.bns in environment production in 0.16 seconds Notice: /Stage[main]/Main/Ec2_securitygroup[lb-sg]/ensure: created Notice: /Stage[main]/Main/Ec2_securitygroup[web-sg]/ingress: ingress changed [] to '{"security_group"=>"lb-sg"} {"protocol"=>"tcp", "port"=>22, "cidr"=>"0.0.0.0/0"}' Error: Security groups 'web-sg' not found in VPCs 'vpc-88cadded' Error: /Stage[main]/Main/Ec2_instance[web-1]/ensure: change from absent to present failed: Security groups 'web-sg' not found in VPCs 'vpc-88cadded' Notice: Applied catalog in 36.30 seconds

`# This will create a set of instances, load balancers and security groups in the

specified AWS region.

Ec2_securitygroup { region => 'sa-east-1', }

Ec2_instance { region => 'sa-east-1', availability_zone => 'sa-east-1a', }

Elb_loadbalancer { region => 'sa-east-1', }

ec2_securitygroup { 'lb-sg': ensure => present, description => 'Security group for load balancer', ingress => [{ protocol => 'tcp', port => 80, cidr => '0.0.0.0/0' }], }

ec2_securitygroup { 'web-sg': ensure => present, description => 'Security group for web servers', ingress => [{ security_group => 'lb-sg', },{ protocol => 'tcp', port => 22, cidr => '0.0.0.0/0' }], }

ec2_instance { ['web-1']: ensure => present, image_id => 'ami-67a60d7a', # EU 'ami-b8c41ccf', security_groups => ['web-sg'], instance_type => 't1.micro', tags => { department => 'engineering', project => 'cloud', created_by => $::id, } `

sagrahari1 commented 8 years ago

Hi hesamaseh, which version of puppet are you using ?

daveside commented 8 years ago

Hi hesamaseh, I'm getting the same error as you. Have you been able to find a solution?

Sagrahari1, I did a fresh new standalone install in order to try the puppetlabs-aws modules. I'm running a clean version of CentOs 7.2 with puppet 3.8.7 and all the updates installed. I followed the installation instructions and installed aws-sdk-core, retries and the puppetlabs-aws module.

So when I tried a simple ec2 instance creation with my AWS credentials export, I got the following error message:

Notice: Compiled catalog for ip-172-31-49-17.ec2.internal in environment production in 0.03 seconds
WARNING: jmespath gem requires json gem >= 1.8.1; json 1.7.7 already loaded
Error: Security groups 'default' not found in VPCs 'vpc-0e038a6b'
Error: /Stage[main]/Main/Ec2_instance[my-instance-name]/ensure: change from absent to present failed: Security groups 'default' not found in VPCs 'vpc-0e038a6b'
Notice: Finished catalog run in 1.02 seconds

The content of the manifest file is:

ec2_instance { 'my-instance-name':
  ensure        => present,
  region        => 'us-east-1',
  image_id      => 'ami-d97897b4',
  instance_type => 't2.micro',
} 

When I try the stack test example, I'm able to create all the security groups but not instances. Here is the output error:

Notice: Compiled catalog for ip-172-31-49-17.ec2.internal in environment production in 0.08 seconds
WARNING: jmespath gem requires json gem >= 1.8.1; json 1.7.7 already loaded
Notice: /Stage[main]/Main/Ec2_securitygroup[lb-sg]/ensure: created
Notice: /Stage[main]/Main/Ec2_securitygroup[web-sg]/ensure: created
Error: Security groups 'web-sg' not found in VPCs 'vpc-0e038a6b'
Error: /Stage[main]/Main/Ec2_instance[web-2]/ensure: change from absent to present failed: Security groups 'web-sg' not found in VPCs 'vpc-0e038a6b'
Error: Security groups 'web-sg' not found in VPCs 'vpc-0e038a6b'
Error: /Stage[main]/Main/Ec2_instance[web-1]/ensure: change from absent to present failed: Security groups 'web-sg' not found in VPCs 'vpc-0e038a6b'
Notice: /Stage[main]/Main/Elb_loadbalancer[lb-1]: Dependency Ec2_instance[web-1] has failures: true
Notice: /Stage[main]/Main/Elb_loadbalancer[lb-1]: Dependency Ec2_instance[web-2] has failures: true
Warning: /Stage[main]/Main/Elb_loadbalancer[lb-1]: Skipping because of failed dependencies
Notice: /Stage[main]/Main/Ec2_securitygroup[db-sg]/ensure: created
Error: Security groups 'db-sg' not found in VPCs 'vpc-0e038a6b'
Error: /Stage[main]/Main/Ec2_instance[db-1]/ensure: change from absent to present failed: Security groups 'db-sg' not found in VPCs 'vpc-0e038a6b'
Notice: Finished catalog run in 5.60 seconds

Any help would be appreciate

hesamaseh commented 8 years ago

I think its a bug, just make sure all your components ( eg security group, vpc, ... ) have the name Tag filled in.

sagrahari1 commented 8 years ago

@daveside, there is a bug with ec2_instance. though it says optional but it expects "subnet" to be passed. Try with passing "subnet" parameter.

daveside commented 8 years ago

Thank you very much. It is finally working with the subnet parameter with a name specified. Note: before using the script, I set the name of all the subnet manually using the AWS dashboard.

ec2_instance { 'my-instance-name':
  ensure        => present,
  region        => 'us-east-1',
  image_id      => 'ami-d97897b4',
  instance_type => 't2.micro',
  subnet        => 'subnet-us-east-1',
} 
zakariaboualaid commented 8 years ago

@daveside Hey, glad you find an answer, I've tried the same solution by providing the Name of the subnet I have made manually through AWS dashboard, but I am still getting the same error

Error: Security groups 'bnpl-web-tier-to-elb' not found in VPCs 'vpc-xxxxxxxx'

Any help is appreciated.

smdanzar commented 7 years ago

Please let me know how can solve this issue?.