en-aws-synchronizer 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +64 -12
  3. data/lib/eaglenube/api_wrapper/aws/acm_certificate.rb +28 -0
  4. data/lib/eaglenube/api_wrapper/aws/database.rb +18 -0
  5. data/lib/eaglenube/api_wrapper/aws/db_snapshot.rb +19 -0
  6. data/lib/eaglenube/api_wrapper/aws/elastic_ip.rb +19 -0
  7. data/lib/eaglenube/api_wrapper/aws/iam_certificate.rb +23 -0
  8. data/lib/eaglenube/api_wrapper/aws/internet_gateway.rb +19 -0
  9. data/lib/eaglenube/api_wrapper/aws/key_pair.rb +18 -0
  10. data/lib/eaglenube/api_wrapper/aws/loadbalancer.rb +18 -0
  11. data/lib/eaglenube/api_wrapper/aws/security_group.rb +19 -0
  12. data/lib/eaglenube/api_wrapper/aws/snapshot.rb +19 -0
  13. data/lib/eaglenube/api_wrapper/aws/subnet.rb +18 -0
  14. data/lib/eaglenube/api_wrapper/aws/volume.rb +18 -0
  15. data/lib/eaglenube/api_wrapper/aws/vpc.rb +23 -0
  16. data/lib/eaglenube/aws_agent.rb +16 -18
  17. data/lib/eaglenube/aws_credential_builder.rb +15 -0
  18. data/lib/eaglenube/synchronizer/aws/acm_certificate.rb +32 -0
  19. data/lib/eaglenube/synchronizer/aws/database.rb +32 -0
  20. data/lib/eaglenube/synchronizer/aws/db_snapshot.rb +4 -10
  21. data/lib/eaglenube/synchronizer/aws/elastic_ip.rb +4 -9
  22. data/lib/eaglenube/synchronizer/aws/iam_certificate.rb +32 -0
  23. data/lib/eaglenube/synchronizer/aws/key_pair.rb +32 -0
  24. data/lib/eaglenube/synchronizer/aws/loadbalancer.rb +32 -0
  25. data/lib/eaglenube/synchronizer/aws/security_group.rb +4 -9
  26. data/lib/eaglenube/synchronizer/aws/snapshot.rb +4 -9
  27. data/lib/eaglenube/synchronizer/aws/subnet.rb +4 -9
  28. data/lib/eaglenube/synchronizer/aws/volume.rb +4 -9
  29. data/lib/eaglenube/synchronizer/aws/vpc.rb +6 -21
  30. data/lib/eaglenube/synchronizer/version.rb +1 -1
  31. data/lib/en_aws_synchronizer.rb +3 -0
  32. metadata +25 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb9acf091bb20cffe0b9e7e28ff17ac86cc77ac265038a96697aff13fad93d70
4
- data.tar.gz: 86f767e582ed1e7bff70f8db33cd55d2f0bd33f3c9c655cdc30d839be05c1bd7
3
+ metadata.gz: f89207bf23e6c1319e92436e2d5a5f3bdd5a85ae0dba456547717048b6dd36a8
4
+ data.tar.gz: 22ddb9f225fd2951a7f471bdbf6172fa75f704b9d8964bdddeec8eb89ab921d5
5
5
  SHA512:
6
- metadata.gz: c8e63fcd2832670605f6702962682227964581c80d5ae3481febb787ce5688d137bb2bbccdd15a9a8f3df386e427a0ec250909c737f3867db90b544c152de16b
7
- data.tar.gz: 62a5293e1322fa133da9e13df1678eb193d64219943b5d1f44c013701de60b586958260f9798f9ec676ba052cc3a84beddc6c4ebc9f0f93df8c42bf580863ee8
6
+ metadata.gz: 70da7e4101db37478358aa935aca66d1b849aa55e5fed3295bfb2ae9b19b17d99238d66e7bd17b6cfd22355544401ebd183850d8730dbeae5cb31a748a48a384
7
+ data.tar.gz: 155842d9824f6250790eccd3b77cbe682f5cb5bb22c6f587ee41a749ca2703b46efb8546190d4a5f007f4e6efcc5d7c11a68214b09182807b54e2dd83554d195
data/README.md CHANGED
@@ -1,25 +1,77 @@
1
- # Eaglenube Aws Synchronizer
1
+ # en-aws-synchronizer
2
2
 
3
- Introducing this powerful gem, designed to seamlessly sync AWS resources to any Rails application model. Our innovative solution streamlines the process of integrating Amazon Web Services' cloud-based resources into your Ruby on Rails projects. With this gem, you can effortlessly connect AWS services like Vpc, Subnet, SecurityGroup, Snapshots, EC2, or RDS to your application models, enabling efficient data synchronization and management. Whether it's handling file storage, cloud computing, or database operations, this gem simplifies AWS resource integration, saving you time and effort. Say goodbye to complex setup processes and hello to a smoother, more streamlined experience, making AWS integration a breeze for your Rails applications.
3
+ `en-aws-synchronizer` is a Ruby gem designed to seamlessly synchronize AWS services to your local database within a Rails application. This gem simplifies the process of fetching AWS resource data and mapping it to your ActiveRecord models.
4
+
5
+ ## Features
6
+
7
+ - Seamless Synchronization: Sync AWS resources like EC2 Volumes to your local database effortlessly.
8
+ - Custom Mappers: Define your custom mappers using YAML files to map AWS resource attributes to your database fields.
9
+ - Extendable: Easily extend the functionality to sync other AWS services by creating custom mappers.
4
10
 
5
11
  ## Installation
6
12
 
7
- Install the gem and add to the application's Gemfile by executing:
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'en-aws-synchronizer'
17
+ ```
18
+ And then execute:
19
+ ```bash
20
+ bundle install
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ 1. Define Your Mapper
26
+ Create a YAML file in __data/cloud_object_mappers/__ directory to map AWS service attributes to your model fields. For example, to map AWS EC2 Volumes, create __data/cloud_object_mappers/volume.yml__:
27
+
28
+ ```yaml
29
+ name: (obj.tags || []).find { |t| t.key.eql?('Name') }.try(:value) || 'Undefined'
30
+ service_id: obj.volume_id
31
+ volume_type: obj.volume_type
32
+ state: obj.state
33
+ tags: obj.tags.to_h
34
+ ```
35
+ 2. Update Your Model
36
+ In your model, include the synchronizer module and reference the mapper YAML file:
37
+
38
+ ```ruby
39
+ require 'eaglenube/synchronizer/aws/volume'
8
40
 
9
- $ bundle add en-aws-synchronizer
41
+ class Volume < ApplicationRecord
10
42
 
11
- If bundler is not being used to manage dependencies, install the gem by executing:
43
+ include Eaglenube::Synchronizer::AWS::Volume
12
44
 
13
- $ gem install en-aws-synchronizer
45
+ cloud_obj_mapper_yml "data/cloud_object_mappers/volume.yml"
14
46
 
15
- ## Contributing
47
+ def self.sync
48
+ credential = Aws::Credentials.new(<access_key_id>, <secret_access_key>)
49
+
50
+ sync_resource(credential, "us-east-1") do |aws_volume|
51
+ db_composite_unique_identifers = { region_id: region.id, aws_service_id: aws_volume.volume_id }
16
52
 
17
- Bug reports and pull requests are welcome on GitHub at https://gitlab.com/eaglenube1/en_aws_synchronizer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/eaglenube1/en_aws_synchronizer/blob/master/CODE_OF_CONDUCT.md).
53
+ extra_attributes = {}
54
+ [object_identifying_attributes, extra_attributes]
55
+ end
56
+ end
57
+ end
58
+ ```
59
+ 3. Synchronize Data
60
+ Call the sync method on your model to sync the AWS resources to your local database:
18
61
 
19
- ## License
62
+ ```ruby
63
+ Volume.sync
64
+ ```
65
+ This will fetch the AWS EC2 Volume data and map the attributes according to the volume.yml mapper file, then save it to your database.
20
66
 
21
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
67
+ Customization
68
+ You can extend this gem to sync other AWS resources by creating appropriate mappers and including the respective synchronizer module in your models.
22
69
 
23
- ## Code of Conduct
70
+ Example
71
+ To sync another AWS resource, such as Vpc, follow these steps:
24
72
 
25
- Everyone interacting in the EnAwsSynchronizer project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/eaglenube1/en_aws_synchronizer/blob/master/CODE_OF_CONDUCT.md).
73
+ Create a new mapper YAML file, e.g., data/cloud_object_mappers/vpc.yml.
74
+ Include the appropriate synchronizer module in your model.
75
+ Implement the sync method in your model, similar to the Volume example.
76
+ Contributing
77
+ Bug reports and pull requests are welcome on GitHub at https://github.com/your-username/en-aws-synchronizer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module AcmCertificate
9
+
10
+ def list_certificates(credential, region_code)
11
+ agent = Eaglenube::AWSAgent.get_acm_agent(credential, region_code)
12
+ agent.list_certificates.try(:certificate_summary_list)
13
+ end
14
+
15
+ def get_certificate(credential, region_code, certificate_arn)
16
+ agent = Eaglenube::AWSAgent.get_acm_agent(credential, region_code)
17
+ agent.get_certificate({ certificate_arn: certificate_arn })
18
+ end
19
+
20
+ def describe_certificate(credential, region_code, certificate_arn)
21
+ agent = Eaglenube::AWSAgent.get_acm_agent(credential, region_code)
22
+ agent.describe_certificate({ certificate_arn: certificate_arn })
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module Database
9
+
10
+ def describe_db_instances(credential, region_code)
11
+ agent = Eaglenube::AWSAgent.get_rds_agent(credential, region_code)
12
+ agent.describe_db_instances.try(:db_instances)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module DbSnapshot
9
+ include Eaglenube::AWSAgent
10
+
11
+ def describe_db_snapshots(credential, region_code, **options)
12
+ agent = Eaglenube::AWSAgent.get_rds_agent(credential, region_code)
13
+ agent.describe_db_snapshots(options).try(:db_snapshots)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module ElasticIp
9
+ include Eaglenube::AWSAgent
10
+
11
+ def describe_addresses(credential, region_code)
12
+ agent = Eaglenube::AWSAgent.get_compute_agent(credential, region_code)
13
+ agent.describe_addresses.try(:addresses)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module IamCertificate
9
+
10
+ def list_server_certificates(credential, region_code)
11
+ agent = Eaglenube::AWSAgent.get_iam_agent(credential, region_code)
12
+ agent.list_server_certificates.try(:server_certificate_metadata_list)
13
+ end
14
+
15
+ def get_server_certificate(credential, region_code, certificate_name)
16
+ agent = Eaglenube::AWSAgent.get_iam_agent(credential, region_code)
17
+ agent.get_server_certificate({ server_certificate_name: certificate_name })
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module InternetGateway
9
+ include Eaglenube::AWSAgent
10
+
11
+ def describe_internet_gateways(credential, region_code)
12
+ agent = Eaglenube::AWSAgent.get_compute_agent(credential, region_code)
13
+ agent.describe_internet_gateways.try(:internet_gateways)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module KeyPair
9
+
10
+ def describe_key_pairs(credential, region_code)
11
+ agent = Eaglenube::AWSAgent.get_compute_agent(credential, region_code)
12
+ agent.describe_key_pairs.try(:key_pairs)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module Loadbalancer
9
+
10
+ def describe_load_balancers(credential, region_code)
11
+ agent = Eaglenube::AWSAgent.get_elb_agent(credential, region_code)
12
+ agent.describe_load_balancers.try(:load_balancers) || []
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module SecurityGroup
9
+ include Eaglenube::AWSAgent
10
+
11
+ def describe_security_groups(credential, region_code)
12
+ agent = Eaglenube::AWSAgent.get_compute_agent(credential, region_code)
13
+ agent.describe_security_groups.try(:security_groups)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module Snapshot
9
+ include Eaglenube::AWSAgent
10
+
11
+ def describe_snapshots(credential, region_code, **options)
12
+ agent = Eaglenube::AWSAgent.get_compute_agent(credential, region_code)
13
+ agent.describe_snapshots(options).try(:snapshots)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module Subnet
9
+
10
+ def describe_subnets(credential, region_code)
11
+ agent = Eaglenube::AWSAgent.get_compute_agent(credential, region_code)
12
+ agent.describe_subnets.try(:subnets)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module Volume
9
+
10
+ def describe_volumes(credential, region_code)
11
+ agent = Eaglenube::AWSAgent.get_compute_agent(credential, region_code)
12
+ agent.describe_volumes.try(:volumes)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/aws_agent"
4
+
5
+ module Eaglenube
6
+ module ApiWrapper
7
+ module AWS
8
+ module Vpc
9
+
10
+ def describe_vpcs(credential, region_code)
11
+ agent = Eaglenube::AWSAgent.get_compute_agent(credential, region_code)
12
+ agent.describe_vpcs.try(:vpcs)
13
+ end
14
+
15
+ def describe_vpc_attribute(credential, region_code, **options)
16
+ agent = Eaglenube::AWSAgent.get_compute_agent(credential, region_code)
17
+ agent.describe_vpc_attribute(options)
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,57 +1,55 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "eaglenube/aws_credential_builder"
4
+
3
5
  module Eaglenube
4
6
  module AWSAgent
5
- def get_compute_agent(customer_cred, region_code = "us-east-1")
7
+
8
+ extend Eaglenube::AWSCredentialBuilder
9
+
10
+ def self.get_compute_agent(customer_cred, region_code = "us-east-1")
6
11
  Aws::EC2::Client.new(region: region_code, credentials: build_credential(customer_cred))
7
12
  end
8
13
 
9
- def get_rds_agent(customer_cred, region_code = "us-east-1")
14
+ def self.get_rds_agent(customer_cred, region_code = "us-east-1")
10
15
  Aws::RDS::Client.new(region: region_code, credentials: build_credential(customer_cred))
11
16
  end
12
17
 
13
- def get_elb_agent(customer_cred, region_code = "us-east-1")
18
+ def self.get_elb_agent(customer_cred, region_code = "us-east-1")
14
19
  Aws::ElasticLoadBalancing::Client.new(region: region_code, credentials: build_credential(customer_cred))
15
20
  end
16
21
 
17
- def get_auto_scaling_agent(customer_cred, region_code = "us-east-1")
22
+ def self.get_auto_scaling_agent(customer_cred, region_code = "us-east-1")
18
23
  Aws::AutoScaling::Client.new(region: region_code, credentials: build_credential(customer_cred))
19
24
  end
20
25
 
21
- def get_s3_agent(customer_cred, region_code = "us-east-1")
26
+ def self.get_s3_agent(customer_cred, region_code = "us-east-1")
22
27
  Aws::S3::Client.new(region: region_code, credentials: build_credential(customer_cred))
23
28
  end
24
29
 
25
- def get_cloud_watch_agent(customer_cred, region_code = "us-east-1")
30
+ def self.get_cloud_watch_agent(customer_cred, region_code = "us-east-1")
26
31
  Aws::CloudWatch::Client.new(region: region_code, credentials: build_credential(customer_cred))
27
32
  end
28
33
 
29
- def get_redshift_agent(customer_cred, region_code = "us-east-1")
34
+ def self.get_redshift_agent(customer_cred, region_code = "us-east-1")
30
35
  Aws::Redshift::Client.new(region: region_code, credentials: build_credential(customer_cred))
31
36
  end
32
37
 
33
- def get_kms_agent(customer_cred, region_code = "us-east-1")
38
+ def self.get_kms_agent(customer_cred, region_code = "us-east-1")
34
39
  Aws::KMS::Client.new(region: region_code, credentials: build_credential(customer_cred))
35
40
  end
36
41
 
37
- def get_ecs_agent(customer_cred, region_code = "us-east-1")
42
+ def self.get_ecs_agent(customer_cred, region_code = "us-east-1")
38
43
  Aws::ECS::Client.new(region: region_code, credentials: build_credential(customer_cred))
39
44
  end
40
45
 
41
- def get_iam_agent(customer_cred, region_code = "us-east-1")
46
+ def self.get_iam_agent(customer_cred, region_code = "us-east-1")
42
47
  Aws::IAM::Client.new(region: region_code, credentials: build_credential(customer_cred))
43
48
  end
44
49
 
45
- def get_acm_agent(customer_cred, region_code = "us-east-1")
50
+ def self.get_acm_agent(customer_cred, region_code = "us-east-1")
46
51
  Aws::ACM::Client.new(region: region_code, credentials: build_credential(customer_cred))
47
52
  end
48
53
 
49
- def build_credential(credential)
50
- if credential[:session_token].blank?
51
- Aws::Credentials.new(credential[:access_key_id], credential[:secret_access_key])
52
- else
53
- Aws::Credentials.new(credential[:access_key_id], credential[:secret_access_key], credential[:session_token])
54
- end
55
- end
56
54
  end
57
55
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Eaglenube
4
+ module AWSCredentialBuilder
5
+
6
+ def build_credential(credential)
7
+ if credential[:session_token].blank?
8
+ Aws::Credentials.new(credential[:access_key_id], credential[:secret_access_key])
9
+ else
10
+ Aws::Credentials.new(credential[:access_key_id], credential[:secret_access_key], credential[:session_token])
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/api_wrapper/aws/acm_certificate"
4
+ require "eaglenube/synchronizer/aws"
5
+ require "eaglenube/cloud_object_mapper/aws"
6
+
7
+ # Eaglenube::Synchronizer::AWS::AcmCertificate
8
+ module Eaglenube
9
+ module Synchronizer
10
+ module AWS
11
+ module AcmCertificate
12
+ def self.included(receiver)
13
+ receiver.extend Eaglenube::Synchronizer::AWS::CommonMethods
14
+ receiver.extend AcmSyncMethods
15
+ end
16
+
17
+ module AcmSyncMethods
18
+ include Eaglenube::ApiWrapper::AWS::AcmCertificate
19
+ include Eaglenube::CloudObjectMapper::AWS
20
+
21
+ def sync_resource(credential, region_code)
22
+ remote_acm_certificates = list_certificates(credential, region_code)
23
+ remote_acm_certificates.each do |remote_acm_certificate|
24
+ object_identifying_attributes, optional_attributes = yield(remote_acm_certificate)
25
+ create_or_update(remote_acm_certificate, object_identifying_attributes, **optional_attributes)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/api_wrapper/aws/database"
4
+ require "eaglenube/synchronizer/aws"
5
+ require "eaglenube/cloud_object_mapper/aws"
6
+
7
+ # Eaglenube::Synchronizer::AWS::Database
8
+ module Eaglenube
9
+ module Synchronizer
10
+ module AWS
11
+ module Database
12
+ def self.included(receiver)
13
+ receiver.extend Eaglenube::Synchronizer::AWS::CommonMethods
14
+ receiver.extend AcmSyncMethods
15
+ end
16
+
17
+ module AcmSyncMethods
18
+ include Eaglenube::ApiWrapper::AWS::Database
19
+ include Eaglenube::CloudObjectMapper::AWS
20
+
21
+ def sync_resource(credential, region_code)
22
+ remote_db_instances = describe_db_instances(credential, region_code)
23
+ remote_db_instances.each do |remote_db_instance|
24
+ object_identifying_attributes, optional_attributes = yield(remote_db_instance)
25
+ create_or_update(remote_db_instance, object_identifying_attributes, **optional_attributes)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "eaglenube/aws_agent"
3
+ require "eaglenube/api_wrapper/aws/db_snapshot"
4
4
  require "eaglenube/synchronizer/aws"
5
5
  require "eaglenube/cloud_object_mapper/aws"
6
6
 
@@ -15,17 +15,11 @@ module Eaglenube
15
15
  end
16
16
 
17
17
  module DbSnapshotSyncMethods
18
- include Eaglenube::AWSAgent
18
+ include Eaglenube::ApiWrapper::AWS::DbSnapshot
19
19
  include Eaglenube::CloudObjectMapper::AWS
20
20
 
21
- def list_all_remote_db_snapshots(credential, region_code)
22
- agent = get_rds_agent(credential, region_code)
23
- agent.describe_db_snapshots({ include_public: false, include_shared: true,
24
- snapshot_type: "manual" }).try(:db_snapshots)
25
- end
26
-
27
- def sync(credential, region_code)
28
- remote_db_snapshots = list_all_remote_db_snapshots(credential, region_code)
21
+ def sync_resource(credential, region_code, **options)
22
+ remote_db_snapshots = describe_db_snapshots(credential, region_code, **options)
29
23
  remote_db_snapshots.each do |remote_db_snapshot|
30
24
  object_identifying_attributes, optional_attributes = yield(remote_db_snapshot)
31
25
  create_or_update(remote_db_snapshot, object_identifying_attributes, **optional_attributes)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "eaglenube/aws_agent"
3
+ require "eaglenube/api_wrapper/aws/elastic_ip"
4
4
  require "eaglenube/synchronizer/aws"
5
5
  require "eaglenube/cloud_object_mapper/aws"
6
6
 
@@ -15,16 +15,11 @@ module Eaglenube
15
15
  end
16
16
 
17
17
  module EipSyncMethods
18
- include Eaglenube::AWSAgent
18
+ include Eaglenube::ApiWrapper::AWS::ElasticIp
19
19
  include Eaglenube::CloudObjectMapper::AWS
20
20
 
21
- def list_all_elastic_ips(credential, region_code)
22
- agent = get_compute_agent(credential, region_code)
23
- agent.describe_addresses.try(:addresses)
24
- end
25
-
26
- def sync(credential, region_code)
27
- remote_eips = list_all_elastic_ips(credential, region_code)
21
+ def sync_resource(credential, region_code)
22
+ remote_eips = describe_addresses(credential, region_code)
28
23
  remote_eips.each do |remote_eip|
29
24
  object_identifying_attributes, optional_attributes = yield(remote_eip)
30
25
  create_or_update(remote_eip, object_identifying_attributes, **optional_attributes)
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/api_wrapper/aws/iam_certificate"
4
+ require "eaglenube/synchronizer/aws"
5
+ require "eaglenube/cloud_object_mapper/aws"
6
+
7
+ # Eaglenube::Synchronizer::AWS::IamCertificate
8
+ module Eaglenube
9
+ module Synchronizer
10
+ module AWS
11
+ module IamCertificate
12
+ def self.included(receiver)
13
+ receiver.extend Eaglenube::Synchronizer::AWS::CommonMethods
14
+ receiver.extend IamCertificateSyncMethods
15
+ end
16
+
17
+ module IamCertificateSyncMethods
18
+ include Eaglenube::ApiWrapper::AWS::IamCertificate
19
+ include Eaglenube::CloudObjectMapper::AWS
20
+
21
+ def sync_resource(credential, region_code)
22
+ remote_iam_certificates = list_server_certificates(credential, region_code)
23
+ remote_iam_certificates.each do |remote_iam_certificate|
24
+ object_identifying_attributes, optional_attributes = yield(remote_iam_certificate)
25
+ create_or_update(remote_iam_certificate, object_identifying_attributes, **optional_attributes)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/api_wrapper/aws/key_pair"
4
+ require "eaglenube/synchronizer/aws"
5
+ require "eaglenube/cloud_object_mapper/aws"
6
+
7
+ # Eaglenube::Synchronizer::AWS::KeyPair
8
+ module Eaglenube
9
+ module Synchronizer
10
+ module AWS
11
+ module KeyPair
12
+ def self.included(receiver)
13
+ receiver.extend Eaglenube::Synchronizer::AWS::CommonMethods
14
+ receiver.extend KeyPairSyncMethods
15
+ end
16
+
17
+ module KeyPairSyncMethods
18
+ include Eaglenube::ApiWrapper::AWS::KeyPair
19
+ include Eaglenube::CloudObjectMapper::AWS
20
+
21
+ def sync_resource(credential, region_code)
22
+ remote_key_pairs = describe_key_pairs(credential, region_code)
23
+ remote_key_pairs.each do |remote_key_pair|
24
+ object_identifying_attributes, optional_attributes = yield(remote_key_pair)
25
+ create_or_update(remote_key_pair, object_identifying_attributes, **optional_attributes)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "eaglenube/api_wrapper/aws/loadbalancer"
4
+ require "eaglenube/synchronizer/aws"
5
+ require "eaglenube/cloud_object_mapper/aws"
6
+
7
+ # Eaglenube::Synchronizer::AWS::Loadbalancer
8
+ module Eaglenube
9
+ module Synchronizer
10
+ module AWS
11
+ module Loadbalancer
12
+ def self.included(receiver)
13
+ receiver.extend Eaglenube::Synchronizer::AWS::CommonMethods
14
+ receiver.extend LbSyncMethods
15
+ end
16
+
17
+ module LbSyncMethods
18
+ include Eaglenube::ApiWrapper::AWS::Loadbalancer
19
+ include Eaglenube::CloudObjectMapper::AWS
20
+
21
+ def sync_resource(credential, region_code)
22
+ remote_load_balancers = describe_load_balancers(credential, region_code)
23
+ remote_load_balancers.each do |remote_load_balancer|
24
+ object_identifying_attributes, optional_attributes = yield(remote_load_balancer)
25
+ create_or_update(remote_load_balancer, object_identifying_attributes, **optional_attributes)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "eaglenube/aws_agent"
3
+ require "eaglenube/api_wrapper/aws/security_group"
4
4
  require "eaglenube/cloud_object_mapper/aws"
5
5
 
6
6
  module Eaglenube
@@ -13,16 +13,11 @@ module Eaglenube
13
13
  end
14
14
 
15
15
  module SecurityGroupSyncMethods
16
- include Eaglenube::AWSAgent
16
+ include Eaglenube::ApiWrapper::AWS::SecurityGroup
17
17
  include Eaglenube::CloudObjectMapper::AWS
18
18
 
19
- def list_all_remote_security_groups(credential, region_code)
20
- agent = get_compute_agent(credential, region_code)
21
- agent.describe_security_groups.try(:security_groups)
22
- end
23
-
24
- def sync(credential, region_code)
25
- remote_security_groups = list_all_remote_security_groups(credential, region_code)
19
+ def sync_resource(credential, region_code)
20
+ remote_security_groups = describe_security_groups(credential, region_code)
26
21
  remote_security_groups.each do |remote_security_group|
27
22
  object_identifying_attributes, optional_attributes = yield(remote_security_group)
28
23
  create_or_update(remote_security_group, object_identifying_attributes, **optional_attributes)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "eaglenube/aws_agent"
3
+ require "eaglenube/api_wrapper/aws/snapshot"
4
4
  require "eaglenube/synchronizer/aws"
5
5
  require "eaglenube/cloud_object_mapper/aws"
6
6
 
@@ -15,16 +15,11 @@ module Eaglenube
15
15
  end
16
16
 
17
17
  module SnapshotSyncMethods
18
- include Eaglenube::AWSAgent
18
+ include Eaglenube::ApiWrapper::AWS::Snapshot
19
19
  include Eaglenube::CloudObjectMapper::AWS
20
20
 
21
- def list_all_remote_snapshots(credential, region_code, aws_account_id)
22
- agent = get_compute_agent(credential, region_code)
23
- agent.describe_snapshots({ owner_ids: [aws_account_id] }).try(:snapshots)
24
- end
25
-
26
- def sync(credential, region_code, aws_account_id)
27
- remote_snapshots = list_all_remote_snapshots(credential, region_code, aws_account_id)
21
+ def sync_resource(credential, region_code, **options)
22
+ remote_snapshots = describe_snapshots(credential, region_code, **options)
28
23
  remote_snapshots.each do |remote_snapshot|
29
24
  object_identifying_attributes, optional_attributes = yield(remote_snapshot)
30
25
  create_or_update(remote_snapshot, object_identifying_attributes, **optional_attributes)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "eaglenube/aws_agent"
3
+ require "eaglenube/api_wrapper/aws/subnet"
4
4
  require "eaglenube/synchronizer/aws"
5
5
  require "eaglenube/cloud_object_mapper/aws"
6
6
 
@@ -14,16 +14,11 @@ module Eaglenube
14
14
  end
15
15
 
16
16
  module SubnetSyncMethods
17
- include Eaglenube::AWSAgent
17
+ include Eaglenube::ApiWrapper::AWS::Subnet
18
18
  include Eaglenube::CloudObjectMapper::AWS
19
19
 
20
- def list_all_remote_subnets(credential, region_code)
21
- agent = get_compute_agent(credential, region_code)
22
- agent.describe_subnets.try(:subnets)
23
- end
24
-
25
- def sync(credential, region_code, &_block)
26
- remote_subnets = list_all_remote_subnets(credential, region_code)
20
+ def sync_resource(credential, region_code, &_block)
21
+ remote_subnets = describe_subnets(credential, region_code)
27
22
  remote_subnets.each do |remote_subnet|
28
23
  object_identifying_attributes, optional_attributes = yield(remote_subnet)
29
24
  create_or_update(remote_subnet, object_identifying_attributes, **optional_attributes)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "eaglenube/aws_agent"
3
+ require "eaglenube/api_wrapper/aws/volume"
4
4
  require "eaglenube/synchronizer/aws"
5
5
  require "eaglenube/cloud_object_mapper/aws"
6
6
 
@@ -15,16 +15,11 @@ module Eaglenube
15
15
  end
16
16
 
17
17
  module VolumeSyncMethods
18
- include Eaglenube::AWSAgent
18
+ include Eaglenube::ApiWrapper::AWS::Volume
19
19
  include Eaglenube::CloudObjectMapper::AWS
20
20
 
21
- def list_all_remote_volumes(credential, region_code)
22
- agent = get_compute_agent(credential, region_code)
23
- agent.describe_volumes.try(:volumes)
24
- end
25
-
26
- def sync(credential, region_code, &_block)
27
- remote_volumes = list_all_remote_volumes(credential, region_code)
21
+ def sync_resource(credential, region_code, &_block)
22
+ remote_volumes = describe_volumes(credential, region_code)
28
23
  remote_volumes.each do |remote_volume|
29
24
  object_identifying_attributes, optional_attributes = yield(remote_volume)
30
25
  create_or_update(remote_volume, object_identifying_attributes, **optional_attributes)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "eaglenube/aws_agent"
3
+ require "eaglenube/api_wrapper/aws/vpc"
4
4
  require "eaglenube/synchronizer/aws"
5
5
  require "eaglenube/cloud_object_mapper/aws"
6
6
 
@@ -10,30 +10,16 @@ module Eaglenube
10
10
  module AWS
11
11
  module Vpc
12
12
  def self.included(receiver)
13
- puts "receiver module name: #{receiver}"
14
- # module_name = Eaglenube::Synchronizer.config.find_sync_module(receiver)
15
- # puts "module name to extend: #{module_name}"
16
- # receiver.extend module_name if defined?(receiver)
17
13
  receiver.extend Eaglenube::Synchronizer::AWS::CommonMethods
18
14
  receiver.extend VpcSyncMethods
19
15
  end
20
16
 
21
17
  module VpcSyncMethods
22
- include Eaglenube::AWSAgent
18
+ include Eaglenube::ApiWrapper::AWS::Vpc
23
19
  include Eaglenube::CloudObjectMapper::AWS
24
20
 
25
- def list_all_remote_vpcs(credential, region_code)
26
- agent = get_compute_agent(credential, region_code)
27
- agent.describe_vpcs.try(:vpcs)
28
- end
29
-
30
- def list_all_remote_igs(credential, region_code)
31
- agent = get_compute_agent(credential, region_code)
32
- agent.describe_internet_gateways.try(:internet_gateways)
33
- end
34
-
35
- def sync(credential, region_code)
36
- remote_vpcs = list_all_remote_vpcs(credential, region_code)
21
+ def sync_resource(credential, region_code)
22
+ remote_vpcs = describe_vpcs(credential, region_code)
37
23
  describe_vpc_attribute_permisssion_error = false
38
24
  remote_vpcs.each do |remote_vpc|
39
25
  object_identifying_attributes, optional_attributes = yield(remote_vpc)
@@ -54,11 +40,10 @@ module Eaglenube
54
40
  end
55
41
 
56
42
  def sync_addtional_attributes(credential, region_code, vpc_id)
57
- agent = get_compute_agent(credential, region_code)
58
43
  dns_support_attrs = { vpc_id: vpc_id, attribute: "enableDnsSupport" }
59
- dns_support = agent.describe_vpc_attribute(dns_support_attrs).try(:enable_dns_support).try(:value)
44
+ dns_support = describe_vpc_attribute(credential, region_code, **dns_support_attrs).try(:enable_dns_support).try(:value)
60
45
  dns_hostname_attrs = { vpc_id: vpc_id, attribute: "enableDnsHostnames" }
61
- dns_hostname = agent.describe_vpc_attribute(dns_hostname_attrs).try(:enable_dns_hostnames).try(:value)
46
+ dns_hostname = describe_vpc_attribute(credential, region_code, **dns_hostname_attrs).try(:enable_dns_hostnames).try(:value)
62
47
  [dns_support, dns_hostname]
63
48
  end
64
49
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Eaglenube
4
4
  module Synchronizer
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -5,3 +5,6 @@ require "eaglenube/cloud_object_mapper/aws"
5
5
  require "eaglenube/synchronizer/aws"
6
6
 
7
7
  require "eaglenube/synchronizer"
8
+
9
+ require "eaglenube/api_wrapper/aws"
10
+ require "eaglenube/api_wrapper"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: en-aws-synchronizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eaglenube
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-20 00:00:00.000000000 Z
11
+ date: 2024-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-acm
@@ -179,12 +179,31 @@ files:
179
179
  - README.md
180
180
  - Rakefile
181
181
  - en_aws_synchronizer.gemspec
182
+ - lib/eaglenube/api_wrapper/aws/acm_certificate.rb
183
+ - lib/eaglenube/api_wrapper/aws/database.rb
184
+ - lib/eaglenube/api_wrapper/aws/db_snapshot.rb
185
+ - lib/eaglenube/api_wrapper/aws/elastic_ip.rb
186
+ - lib/eaglenube/api_wrapper/aws/iam_certificate.rb
187
+ - lib/eaglenube/api_wrapper/aws/internet_gateway.rb
188
+ - lib/eaglenube/api_wrapper/aws/key_pair.rb
189
+ - lib/eaglenube/api_wrapper/aws/loadbalancer.rb
190
+ - lib/eaglenube/api_wrapper/aws/security_group.rb
191
+ - lib/eaglenube/api_wrapper/aws/snapshot.rb
192
+ - lib/eaglenube/api_wrapper/aws/subnet.rb
193
+ - lib/eaglenube/api_wrapper/aws/volume.rb
194
+ - lib/eaglenube/api_wrapper/aws/vpc.rb
182
195
  - lib/eaglenube/aws_agent.rb
196
+ - lib/eaglenube/aws_credential_builder.rb
183
197
  - lib/eaglenube/cloud_object_mapper/aws.rb
184
198
  - lib/eaglenube/synchronizer.rb
185
199
  - lib/eaglenube/synchronizer/aws.rb
200
+ - lib/eaglenube/synchronizer/aws/acm_certificate.rb
201
+ - lib/eaglenube/synchronizer/aws/database.rb
186
202
  - lib/eaglenube/synchronizer/aws/db_snapshot.rb
187
203
  - lib/eaglenube/synchronizer/aws/elastic_ip.rb
204
+ - lib/eaglenube/synchronizer/aws/iam_certificate.rb
205
+ - lib/eaglenube/synchronizer/aws/key_pair.rb
206
+ - lib/eaglenube/synchronizer/aws/loadbalancer.rb
188
207
  - lib/eaglenube/synchronizer/aws/security_group.rb
189
208
  - lib/eaglenube/synchronizer/aws/snapshot.rb
190
209
  - lib/eaglenube/synchronizer/aws/subnet.rb
@@ -202,7 +221,7 @@ licenses:
202
221
  metadata:
203
222
  homepage_uri: https://gitlab.com/eaglenube1/en_aws_synchronizer
204
223
  source_code_uri: https://gitlab.com/eaglenube1/en_aws_synchronizer
205
- post_install_message:
224
+ post_install_message:
206
225
  rdoc_options: []
207
226
  require_paths:
208
227
  - lib
@@ -217,8 +236,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
236
  - !ruby/object:Gem::Version
218
237
  version: '0'
219
238
  requirements: []
220
- rubygems_version: 3.4.19
221
- signing_key:
239
+ rubygems_version: 3.4.10
240
+ signing_key:
222
241
  specification_version: 4
223
242
  summary: Synchronize your aws resource to your rails model
224
243
  test_files: []