class AWS::CloudFormation::Stack

Attributes

service_registry[RW]

Public Instance Methods

autoscaled_instances() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 84
def autoscaled_instances
  self.resources_of_type("AutoScaling::AutoScalingGroup").map{ |res| @service_registry[:autoscaling].groups[res.physical_resource_id].ec2_instances.to_a }.flatten
end
buckets() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 76
def buckets
  self.resources_of_type("S3::Bucket").map{ |res| @service_registry[:s3].buckets[res.physical_resource_id] }.find_all{ |r| r.exists? }
end
cancel_update() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 60
def cancel_update
  self.client.cancel_update_stack(stack_name: self.name)
end
distribution(cname) click to toggle source
# File lib/aws/with-stacco-patches.rb, line 72
def distribution(cname)
  self.distributions.find{ |dist| dist.aliases.include?(cname) }
end
distributions() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 68
def distributions
  self.resources_of_type("CloudFront::Distribution").map{ |res| @service_registry[:cloudfront].distributions[res.physical_resource_id] }
end
elastic_ips() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 92
def elastic_ips
  self.resources_of_type("EC2::EIP").map{ |res| @service_registry[:ec2].elastic_ips[res.physical_resource_id] }
end
instances() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 88
def instances
  self.manual_instances + self.autoscaled_instances
end
manual_instances() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 80
def manual_instances
  self.resources_of_type("EC2::Instance").map{ |res| @service_registry[:ec2].instances[res.physical_resource_id] }
end
rds_instances() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 96
def rds_instances
  self.resources_of_type("RDS::DBInstance").inject({}){ |h, res| h[res.logical_resource_id] = @service_registry[:rds].instances[res.physical_resource_id]; h }
end
resources_of_type(type_name) click to toggle source
# File lib/aws/with-stacco-patches.rb, line 64
def resources_of_type(type_name)
  self.resources.find_all{ |r| r.resource_type == "AWS::#{type_name}" && r.resource_status =~ /_COMPLETE/ && r.resource_status != "DELETE_COMPLETE" }
end
server_certificates(opts = {}) click to toggle source
# File lib/aws/with-stacco-patches.rb, line 100
def server_certificates(opts = {})
  certs = @service_registry[:iam].server_certificates.find_all{ |cert| cert.path == "/cloudfront/#{self.name}/" }

  if cnames = opts.delete(:domain)
    certs = Hash[ *(certs.map{ |cert| [cert.name, cert] }.flatten) ]

    cnames = [cnames] unless cnames.kind_of?(Array)
    cnames = cnames.flatten

    possible_cert_names = cnames.map{ |cname| parts = cname.split('.').reverse; (1..parts.length).map{ |len| parts[0, len].reverse.join('.') }.reverse }.flatten

    possible_cert_names.map{ |cname| certs[cname] }.compact
  else
    certs
  end
end