Here we are adding the first forking logic into the subnet_nexus.rb. To be able to provision a private subnet like thing in AWS, we need the following resources: - VPC - Subnet in that VPC - Security Group to be able to manage firewalls - InternetGateway to be able to access public network - RouteTable to be able to manage the traffic in the vpc. All of these resources are created in a controlled manner in a different file so that the main logic in the nexus.rb files are left separate.
29 lines
726 B
Ruby
29 lines
726 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../model"
|
|
require "aws-sdk-ec2"
|
|
|
|
class LocationCredential < Sequel::Model
|
|
include ResourceMethods
|
|
many_to_one :project
|
|
many_to_one :location, key: :id
|
|
plugin :column_encryption do |enc|
|
|
enc.column :access_key
|
|
enc.column :secret_key
|
|
end
|
|
|
|
def client
|
|
Aws::EC2::Client.new(access_key_id: access_key, secret_access_key: secret_key, region: location.name)
|
|
end
|
|
end
|
|
|
|
# Table: location_credential
|
|
# Columns:
|
|
# access_key | text | NOT NULL
|
|
# secret_key | text | NOT NULL
|
|
# id | uuid | PRIMARY KEY
|
|
# Indexes:
|
|
# location_credential_pkey | PRIMARY KEY btree (id)
|
|
# Foreign key constraints:
|
|
# location_credential_id_fkey | (id) REFERENCES location(id)
|