Class: VagrantPlugins::AwsDns::Util::AwsUtil
- Inherits:
-
Object
- Object
- VagrantPlugins::AwsDns::Util::AwsUtil
- Defined in:
- lib/vagrant-aws-dns/util/aws_util.rb
Instance Attribute Summary collapse
-
#ec2 ⇒ Object
readonly
Returns the value of attribute ec2.
-
#route53 ⇒ Object
readonly
Returns the value of attribute route53.
Instance Method Summary collapse
- #add_record(hosted_zone_id, record, type, value) ⇒ Object
- #get_private_ip(instance_id) ⇒ Object
- #get_public_ip(instance_id) ⇒ Object
-
#initialize(accesskey, secretkey, region) ⇒ AwsUtil
constructor
A new instance of AwsUtil.
- #is_private_zone(hosted_zone_id) ⇒ Object
- #remove_record(hosted_zone_id, record, type, value) ⇒ Object
Constructor Details
#initialize(accesskey, secretkey, region) ⇒ AwsUtil
Returns a new instance of AwsUtil.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 11 def initialize(accesskey, secretkey, region) credentials = Aws::Credentials.new(accesskey, secretkey) @ec2 = Aws::EC2::Client.new( region: region, credentials: credentials ) @route53 = Aws::Route53::Client.new( region: region, credentials: credentials ) end |
Instance Attribute Details
#ec2 ⇒ Object (readonly)
Returns the value of attribute ec2.
9 10 11 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 9 def ec2 @ec2 end |
#route53 ⇒ Object (readonly)
Returns the value of attribute route53.
9 10 11 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 9 def route53 @route53 end |
Instance Method Details
#add_record(hosted_zone_id, record, type, value) ⇒ Object
35 36 37 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 35 def add_record(hosted_zone_id, record, type, value) change_record(hosted_zone_id, record, type, value, 'UPSERT') end |
#get_private_ip(instance_id) ⇒ Object
27 28 29 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 27 def get_private_ip(instance_id) @ec2.describe_instances({instance_ids: [instance_id]}).reservations[0].instances[0].private_ip_address end |
#get_public_ip(instance_id) ⇒ Object
23 24 25 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 23 def get_public_ip(instance_id) @ec2.describe_instances({instance_ids: [instance_id]}).reservations[0].instances[0].public_ip_address end |
#is_private_zone(hosted_zone_id) ⇒ Object
31 32 33 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 31 def is_private_zone(hosted_zone_id) @route53.get_hosted_zone({id: '/hostedzone/' + hosted_zone_id}).hosted_zone.config.private_zone end |
#remove_record(hosted_zone_id, record, type, value) ⇒ Object
39 40 41 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 39 def remove_record(hosted_zone_id, record, type, value) change_record(hosted_zone_id, record, type, value, 'DELETE') end |