class Stax::Cmd::Rds

Constants

COLORS

Public Instance Methods

clusters() click to toggle source
# File lib/stax/mixin/rds.rb, line 46
def clusters
  debug("RDS DB clusters for #{my.stack_name}")
  print_table stack_rds_clusters.map { |c|
    [c.db_cluster_identifier, c.engine, c.engine_version, color(c.status, COLORS), c.cluster_create_time]
  }
end
endpoints() click to toggle source
# File lib/stax/mixin/rds.rb, line 73
def endpoints
  stack_rds_clusters.each do |c|
    debug("RDS DB endpoints for cluster #{c.db_cluster_identifier}")
    print_table [
      ['writer', c.endpoint,        c.port, c.hosted_zone_id],
      ['reader', c.reader_endpoint, c.port, c.hosted_zone_id],
    ]
  end

  debug("RDS DB instance endpoints for #{my.stack_name}")
  print_table stack_rds_instances.map { |i|
    [i.db_instance_identifier, i.endpoint&.address, i.endpoint&.port, i.endpoint&.hosted_zone_id]
  }
end
instances() click to toggle source
# File lib/stax/mixin/rds.rb, line 65
def instances
  debug("RDS DB instances for #{my.stack_name}")
  print_table stack_rds_instances.map { |i|
    [i.db_instance_identifier, i.engine, i.engine_version, color(i.db_instance_status, COLORS), i.db_instance_class, i.db_subnet_group&.vpc_id, i.availability_zone]
  }
end
members() click to toggle source
# File lib/stax/mixin/rds.rb, line 54
def members
  stack_rds_clusters.each do |c|
    debug("RDS DB members for cluster #{c.db_cluster_identifier}")
    print_table c.db_cluster_members.map { |m|
      role = m.is_cluster_writer ? 'writer' : 'reader'
      [m.db_instance_identifier, role, m.db_cluster_parameter_group_status]
    }
  end
end
stack_db_clusters() click to toggle source
# File lib/stax/mixin/rds.rb, line 22
def stack_db_clusters
  Aws::Cfn.resources_by_type(my.stack_name, 'AWS::RDS::DBCluster')
end
stack_db_instances() click to toggle source
# File lib/stax/mixin/rds.rb, line 26
def stack_db_instances
  Aws::Cfn.resources_by_type(my.stack_name, 'AWS::RDS::DBInstance')
end
stack_db_subnet_groups() click to toggle source
# File lib/stax/mixin/rds.rb, line 40
def stack_db_subnet_groups
  Aws::Cfn.resources_by_type(my.stack_name, 'AWS::RDS::DBSubnetGroup')
end
stack_rds_clusters() click to toggle source
# File lib/stax/mixin/rds.rb, line 30
def stack_rds_clusters
  filter = { name: 'db-cluster-id', values: stack_db_clusters.map(&:physical_resource_id) }
  Aws::Rds.clusters(filters: [filter])
end
stack_rds_instances() click to toggle source
# File lib/stax/mixin/rds.rb, line 35
def stack_rds_instances
  filter = { name: 'db-instance-id', values: stack_db_instances.map(&:physical_resource_id) }
  Aws::Rds.instances(filters: [filter])
end
subnets() click to toggle source
# File lib/stax/mixin/rds.rb, line 89
def subnets
  stack_db_subnet_groups.map do |r|
    Aws::Rds.subnet_groups(db_subnet_group_name: r.physical_resource_id)
  end.flatten.each do |g|
    debug("Subnets for group #{g.db_subnet_group_name}")
    print_table g.subnets.map { |s|
      [s&.subnet_availability_zone&.name, s&.subnet_identifier, color(s&.subnet_status, COLORS)]
    }
  end
end