Puppet Class: psick::aws::puppet::rds

Defined in:
manifests/aws/puppet/rds.pp

Overview

Setup RDS

Parameters:

  • default_master_user_password (String)
  • ensure (String) (defaults to: 'present')
  • region (String) (defaults to: $::psick::aws::region)
  • default_vpc_name (String) (defaults to: $::psick::aws::default_vpc_name)
  • create_defaults (Boolean) (defaults to: $::psick::aws::create_defaults)
  • multi_az (Boolean) (defaults to: false)
  • rds_instances (Hash) (defaults to: { })
  • rds_db_securitygroups (Hash) (defaults to: { })
  • rds_db_parameter_groups (Hash) (defaults to: { })
  • default_db_name (String) (defaults to: 'db')
  • default_db_instance_class (String) (defaults to: 'db.t2.micro')
  • default_allocated_storage (String) (defaults to: '100')
  • default_backup_retention_period (String) (defaults to: '7')
  • default_engine_version (String) (defaults to: '5.7.11')
  • default_db_parameter_group (String) (defaults to: 'default.mysql5.7')
  • default_engine (String) (defaults to: 'mysql')
  • default_storage_type (String) (defaults to: 'gp2')
  • default_master_username (String) (defaults to: 'admin')
  • default_family (String) (defaults to: 'mysql5.7')


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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'manifests/aws/puppet/rds.pp', line 2

class psick::aws::puppet::rds (
  String  $default_master_user_password,

  String  $ensure                          = 'present',

  String  $region                          = $::psick::aws::region,
  String  $default_vpc_name                = $::psick::aws::default_vpc_name,
  Boolean $create_defaults                 = $::psick::aws::create_defaults,

  Boolean $multi_az                        = false,

  # Hashes of resources to create
  Hash    $rds_instances                   = { },
  Hash    $rds_db_securitygroups           = { },
  Hash    $rds_db_parameter_groups         = { },

  # Default settings
  String  $default_db_name                 = 'db',
  String  $default_db_instance_class       = 'db.t2.micro',
  String  $default_allocated_storage       = '100',
  String  $default_backup_retention_period = '7',
  String  $default_engine_version          = '5.7.11',
  String  $default_db_parameter_group      = 'default.mysql5.7',
  String  $default_engine                  = 'mysql',
  String  $default_storage_type            = 'gp2',
  String  $default_master_username         = 'admin',

  String  $default_family                  = 'mysql5.7',

) {

  if $ensure == 'absent' {
    Rds_db_securitygroup<|name == $title|>
    -> Rds_instance<|name == $title|>
  }

  # Default resources, if enabled
  if $create_defaults {
    $default_rds_instances = {
      "${default_vpc_name}-rds" => {
        ensure    => present,
        db_subnet => "${default_vpc_name}-rds", # TODO: Automate creation of
                                                  #       DB subnet groups
      },
    }
    $default_rds_db_securitygroups = {
      #    rds_sg => {
      #  description => 'Default security group',
      #  ip_ranges   => [{'ip_range' => '10.0.0.0/16', 'status' => 'authorized'}],
      #}
    }
    $default_rds_db_parameter_groups = {}

  } else {
    $default_rds_instances = {}
    $default_rds_db_securitygroups = {}
    $default_rds_db_parameter_groups = {}
  }
  $all_rds_instances = $rds_instances+$default_rds_instances
  $all_rds_db_securitygroups = $rds_db_securitygroups+$default_rds_db_securitygroups
  $all_rds_db_parameter_groups = $rds_db_parameter_groups+$default_rds_db_parameter_groups

  # RDS INSTANCES
  $rds_instances_defaults = {
    ensure                          => $ensure,
    region                          => $region,
    allocated_storage               => $default_allocated_storage,
    backup_retention_period         => $default_backup_retention_period,
    db_instance_class               => $default_db_instance_class,
    db_parameter_group              => $default_db_parameter_group,
    engine                          => $default_engine,
    engine_version                  => $default_engine_version,
    license_model                   => 'general-public-license',
    master_username                 => $default_master_username,
    master_user_password            => $default_master_user_password,
    multi_az                        => $multi_az,
    storage_type                    => $default_storage_type,
  }

  if $all_rds_instances != { } {
    create_resources('rds_instance',$all_rds_instances,$rds_instances_defaults)
  }


  # RDS SECURITYGROUPS
  $rds_db_securitygroups_defaults = {
    ensure     => $ensure,
    region     => $region,
  }
  if $all_rds_db_securitygroups != { } {
    create_resources('rds_db_securitygroup',$all_rds_db_securitygroups,$rds_db_securitygroups_defaults)
  }


  # RDS PARAMETER GROUPS
  $rds_db_parameter_groups_defaults = {
    ensure     => $ensure,
    region     => $region,
    family     => $default_family,
  }
  if $all_rds_db_parameter_groups != { } {
    create_resources('rds_db_parameter_group',$all_rds_db_parameter_groups,$rds_db_parameter_groups_defaults)
  }

}