./lib/aws/with-stacco-patches.rb in stacco-0.1.23 vs ./lib/aws/with-stacco-patches.rb in stacco-0.1.24
- old
+ new
@@ -67,10 +67,14 @@
def distributions
self.resources_of_type("CloudFront::Distribution").map{ |res| @service_registry[:cloudfront].distributions[res.physical_resource_id] }
end
+ def distribution(cname)
+ self.distributions.find{ |dist| dist.aliases.include?(cname) }
+ end
+
def buckets
self.resources_of_type("S3::Bucket").map{ |res| @service_registry[:s3].buckets[res.physical_resource_id] }.find_all{ |r| r.exists? }
end
def manual_instances
@@ -150,9 +154,20 @@
self.class.hash + self.id.hash
end
def refresh!
@data = @svc.client.get_distribution(id: @data[:id])
+ end
+
+ def invalidate(obj_keys)
+ return false if obj_keys.empty?
+ @svc.client.create_invalidation(distribution_id: self.id, invalidation_batch: {
+ caller_reference: rand(36 ** 32).to_s(36).rjust(32, '0'),
+ paths: {
+ quantity: obj_keys.length,
+ items: obj_keys.map{ |k| k.to_s }
+ }
+ })
end
def aliases
@data[:distribution_config][:aliases][:items]
end