This repository has been archived by the owner on Jun 5, 2020. It is now read-only.
/
create.pp
92 lines (83 loc) · 1.97 KB
/
create.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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_securitygroup { 'db-sg':
ensure => present,
description => 'Security group for database servers',
ingress => [{
security_group => 'web-sg',
},{
protocol => 'tcp',
port => 22,
cidr => '0.0.0.0/0'
}],
}
ec2_instance { ['web-1', 'web-2']:
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,
}
}
ec2_instance { 'db-1':
ensure => present,
image_id => 'ami-67a60d7a', # EU 'ami-b8c41ccf',
security_groups => ['db-sg'],
instance_type => 't1.micro',
monitoring => true,
tags => {
department => 'engineering',
project => 'cloud',
created_by => $::id,
},
block_devices => [
{
device_name => '/dev/sda1',
volume_size => 8,
}
]
}
elb_loadbalancer { 'lb-1':
ensure => present,
availability_zones => ['sa-east-1a'],
instances => ['web-1', 'web-2'],
listeners => [{
protocol => 'tcp',
load_balancer_port => 80,
instance_protocol => 'tcp',
instance_port => 80,
}],
}