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_public_ip(instance_id) ⇒ Object
-
#initialize(accesskey, secretkey) ⇒ AwsUtil
constructor
A new instance of AwsUtil.
- #remove_record(hosted_zone_id, record, type, value) ⇒ Object
Constructor Details
#initialize(accesskey, secretkey) ⇒ 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) credentials = Aws::Credentials.new(accesskey, secretkey) @ec2 = Aws::EC2::Client.new( region: 'eu-west-1', credentials: credentials ) @route53 = Aws::Route53::Client.new( region: 'eu-west-1', 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
27 28 29 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 27 def add_record(hosted_zone_id, record, type, value) change_record(hosted_zone_id, record, type, value, 'UPSERT') 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 |
#remove_record(hosted_zone_id, record, type, value) ⇒ Object
31 32 33 |
# File 'lib/vagrant-aws-dns/util/aws_util.rb', line 31 def remove_record(hosted_zone_id, record, type, value) change_record(hosted_zone_id, record, type, value, 'DELETE') end |