New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

en-aws-synchronizer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

en-aws-synchronizer

  • 0.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

en-aws-synchronizer

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.

Features

  • Seamless Synchronization: Sync AWS resources like EC2 Volumes to your local database effortlessly.
  • Custom Mappers: Define your custom mappers using YAML files to map AWS resource attributes to your database fields.
  • Extendable: Easily extend the functionality to sync other AWS services by creating custom mappers.

Installation

Add this line to your application's Gemfile:

gem 'en-aws-synchronizer'

And then execute:

bundle install

Usage

  1. Define Your Mapper 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:
name: (obj.tags || []).find { |t| t.key.eql?('Name') }.try(:value) || 'Undefined'
service_id: obj.volume_id
volume_type: obj.volume_type
state: obj.state
tags: obj.tags.to_h
  1. Update Your Model In your model, include the synchronizer module and reference the mapper YAML file:
require 'eaglenube/synchronizer/aws/volume'

class Volume < ApplicationRecord

  include Eaglenube::Synchronizer::AWS::Volume

  cloud_obj_mapper_yml "data/cloud_object_mappers/volume.yml"

  def self.sync
    credential = Aws::Credentials.new(<access_key_id>, <secret_access_key>)
    
    sync_resource(credential, "us-east-1") do |aws_volume|
      db_composite_unique_identifers = { region_id: region.id, aws_service_id: aws_volume.volume_id }

      extra_attributes = {}
      [object_identifying_attributes, extra_attributes]
    end
  end
end
  1. Synchronize Data Call the sync method on your model to sync the AWS resources to your local database:
Volume.sync

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.

Customization You can extend this gem to sync other AWS resources by creating appropriate mappers and including the respective synchronizer module in your models.

Example To sync another AWS resource, such as Vpc, follow these steps:

Create a new mapper YAML file, e.g., data/cloud_object_mappers/vpc.yml. Include the appropriate synchronizer module in your model. Implement the sync method in your model, similar to the Volume example. Contributing 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.

FAQs

Package last updated on 15 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc