Sha256: 8c491158653d8d17e566f1de4988f9ee5df692d9cf8659ca735e536db3c315d4
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'aws-sdk' require 'json' require_relative 'contracted_object' require_relative 'iam' require_relative 'route53' module Deputy53 # Assigns control of a zone to an identity class Assigner < ContractedObject Contract None => IAM def iam @iam ||= IAM.new end Contract None => Route53 def route53 @route53 ||= Route53.new end Contract String => String def policy(subdomain) zone = route53.id(subdomain).sub(%r{^/}, '') document = { 'Version' => '2012-10-17', 'Statement' => [ 'Effect' => 'Allow', 'Action' => ['route53domains:*', 'route53:*'], 'Resource' => "arn:aws:route53:::#{zone}" ] } JSON.dump document end Contract String, String => Bool def assign(subdomain, identity) identity = iam.identity identity true if iam.api.method("put_#{identity.type}_policy").call( :"#{identity.type}_name" => identity.name, policy_name: "manage-dns@#{subdomain}", policy_document: policy(subdomain) ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
deputy53-0.13.5 | lib/deputy53/assigner.rb |
deputy53-0.13.0 | lib/deputy53/assigner.rb |