Class: Stax::Cmd::Acm

Inherits:
SubCommand show all
Defined in:
lib/stax/mixin/acm.rb

Constant Summary collapse

COLORS =
{
  SUCCESS:            :green,
  PENDING_VALIDATION: :yellow,
}

Instance Method Summary collapse

Methods inherited from SubCommand

#info, stax_info, stax_info_tasks

Instance Method Details

#domainsObject



52
53
54
55
56
57
58
59
60
# File 'lib/stax/mixin/acm.rb', line 52

def domains
  stack_acm_certs.each do |r|
    c = Aws::Acm.describe(r.physical_resource_id)
    debug("Domains for #{c.certificate_arn}")
    print_table c.domain_validation_options.map { |d|
      [ d.domain_name, color(d.validation_status, COLORS), d.validation_method ]
    }
  end
end

#lsObject



43
44
45
46
47
48
49
# File 'lib/stax/mixin/acm.rb', line 43

def ls
  print_table stack_acm_certs.map { |r|
    c = Aws::Acm.describe(r.physical_resource_id)
    in_use = c.in_use_by.empty? ? 'not in use' : 'in use'
    [ c.domain_name, color(c.status, COLORS), c.issuer, in_use, c.created_at ]
  }
end

#usageObject



82
83
84
85
86
87
88
# File 'lib/stax/mixin/acm.rb', line 82

def usage
  stack_acm_certs.each do |r|
    c = Aws::Acm.describe(r.physical_resource_id)
    debug("Resources associated with #{c.certificate_arn}")
    puts c.in_use_by
  end
end

#validationObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/stax/mixin/acm.rb', line 64

def validation
  stack_acm_certs.each do |r|
    c = Aws::Acm.describe(r.physical_resource_id)
    c.domain_validation_options.uniq do |d|
      d.resource_record
    end.each do |d|
      next if d.validation_status == 'SUCCESS'
      debug("Pending validation for #{d.domain_name}")
      if options[:cli]
        puts "aws route53 change-resource-record-sets --change-batch '#{route53_change_batch(d.resource_record)}' --hosted-zone-id ..."
      else
        puts([d.resource_record.name, d.resource_record.type, d.resource_record.value].join(' '))
      end
    end
  end
end