class Awsclient::Connection
Constants
- SERVICES
Attributes
client_options[RW]
credentials[RW]
region[RW]
Public Class Methods
new(client_options = {})
click to toggle source
# File lib/awsclient.rb, line 28 def initialize(client_options = {}) self.client_options = client_options end
Public Instance Methods
account_id()
click to toggle source
# File lib/awsclient.rb, line 92 def account_id iam.get_user.user.arn.split(':')[4] end
acm()
click to toggle source
# File lib/awsclient.rb, line 96 def acm @acm ||= ::Aws::ACM::Client.new( credentials: credentials, region: region ) end
apigateway()
click to toggle source
# File lib/awsclient.rb, line 103 def apigateway @apigateway ||= ::Aws::APIGateway::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
assume_role!(role_name, duration_seconds = 3600)
click to toggle source
# File lib/awsclient.rb, line 57 def assume_role!(role_name, duration_seconds = 3600) role_arn = "arn:aws:iam::#{account_id}:role/#{role_name}" self.credentials = ::Aws::AssumeRoleCredentials.new( client: sts, role_arn: role_arn, role_session_name: random_string(32), duration_seconds: duration_seconds ) end
autoscaling()
click to toggle source
# File lib/awsclient.rb, line 110 def autoscaling @autoscaling ||= ::Aws::AutoScaling::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cloudformation()
click to toggle source
# File lib/awsclient.rb, line 117 def cloudformation @cloudformation ||= ::Aws::CloudFormation::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cloudfront()
click to toggle source
# File lib/awsclient.rb, line 124 def cloudfront @cloudformation ||= ::Aws::CloudFront::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cloudhsm()
click to toggle source
# File lib/awsclient.rb, line 131 def cloudhsm @cloudformation ||= ::Aws::CloudHSM::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cloudsearch()
click to toggle source
# File lib/awsclient.rb, line 138 def cloudsearch @cloudformation ||= ::Aws::CloudSearch::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cloudtrail()
click to toggle source
# File lib/awsclient.rb, line 145 def cloudtrail @cloudtrail ||= ::Aws::CloudTrail::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cloudwatch()
click to toggle source
# File lib/awsclient.rb, line 152 def cloudwatch @cloudwatch ||= ::Aws::CloudWatch::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cloudwatchevents()
click to toggle source
# File lib/awsclient.rb, line 159 def cloudwatchevents @cloudwatchevents ||= ::Aws::CloudWatchEvents::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cloudwatchlogs()
click to toggle source
# File lib/awsclient.rb, line 166 def cloudwatchlogs @cloudwatchlogs ||= ::Aws::CloudWatchLogs::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
codecommit()
click to toggle source
# File lib/awsclient.rb, line 173 def codecommit @codecommit ||= ::Aws::CodeCommit::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
codedeploy()
click to toggle source
# File lib/awsclient.rb, line 180 def codedeploy @codedeploy ||= ::Aws::CodeDeploy::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
codepipeline()
click to toggle source
# File lib/awsclient.rb, line 187 def codepipeline @codepipeline ||= ::Aws::CodePipeline::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cognitoidentity()
click to toggle source
# File lib/awsclient.rb, line 194 def cognitoidentity @cognitoidentity ||= ::Aws::CognitoIdentity::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
cognitosync()
click to toggle source
# File lib/awsclient.rb, line 201 def cognitosync @cognitosync ||= ::Aws::CognitoSync::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
configservice()
click to toggle source
# File lib/awsclient.rb, line 208 def configservice @codedeploy ||= ::Aws::ConfigService::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
credentials=(credentials)
click to toggle source
# File lib/awsclient.rb, line 39 def credentials=(credentials) @credentials = credentials reload end
databasemigrationservice()
click to toggle source
# File lib/awsclient.rb, line 222 def databasemigrationservice @databasemigrationservice ||= ::Aws::DatabaseMigrationService::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
datapipeline()
click to toggle source
# File lib/awsclient.rb, line 215 def datapipeline @datapipeline ||= ::Aws::DataPipeline::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
devicefarm()
click to toggle source
# File lib/awsclient.rb, line 229 def devicefarm @devicefarm ||= ::Aws::DeviceFarm::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
directconnect()
click to toggle source
# File lib/awsclient.rb, line 236 def directconnect @directconnect ||= ::Aws::DirectConnect::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
directoryservice()
click to toggle source
# File lib/awsclient.rb, line 243 def directoryservice @directoryservice ||= ::Aws::DirectoryService::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
dynamodb()
click to toggle source
# File lib/awsclient.rb, line 250 def dynamodb @dynamodb ||= ::Aws::DynamoDB::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
dynamodbstreams()
click to toggle source
# File lib/awsclient.rb, line 257 def dynamodbstreams @dynamodbstreams ||= ::Aws::DynamoDBStreams::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
ec2()
click to toggle source
# File lib/awsclient.rb, line 264 def ec2 @ec2 ||= ::Aws::EC2::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
ecr()
click to toggle source
# File lib/awsclient.rb, line 271 def ecr @ecr ||= ::Aws::ECR::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
ecs()
click to toggle source
# File lib/awsclient.rb, line 278 def ecs @ecs ||= ::Aws::ECS::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
efs()
click to toggle source
# File lib/awsclient.rb, line 285 def efs @efs ||= ::Aws::EFS::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
elasticbeanstalk()
click to toggle source
# File lib/awsclient.rb, line 299 def elasticbeanstalk @elasticbeanstalk ||= ::Aws::ElasticBeanstalk::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
elasticloadbalancing()
click to toggle source
# File lib/awsclient.rb, line 306 def elasticloadbalancing @elasticloadbalancing ||= ::Aws::ElasticLoadBalancing::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
elasticsearchservice()
click to toggle source
# File lib/awsclient.rb, line 320 def elasticsearchservice @elasticsearchservice ||= ::Aws::ElasticsearchService::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
elastictranscoder()
click to toggle source
# File lib/awsclient.rb, line 313 def elastictranscoder @elastictranscoder ||= ::Aws::ElasticTranscoder::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
emr()
click to toggle source
# File lib/awsclient.rb, line 292 def emr @emr ||= ::Aws::EMR::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
firehose()
click to toggle source
# File lib/awsclient.rb, line 327 def firehose @firehose ||= ::Aws::Firehose::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
gamelift()
click to toggle source
# File lib/awsclient.rb, line 334 def gamelift @gamelift ||= ::Aws::GameLift::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
glacier()
click to toggle source
# File lib/awsclient.rb, line 341 def glacier @glacier ||= ::Aws::Glacier::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
iam()
click to toggle source
# File lib/awsclient.rb, line 348 def iam @iam ||= ::Aws::IAM::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
importexport()
click to toggle source
# File lib/awsclient.rb, line 355 def importexport @importexport ||= ::Aws::ImportExport::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
inspector()
click to toggle source
# File lib/awsclient.rb, line 362 def inspector @importexport ||= ::Aws::Inspector::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
instance_profile_credentials()
click to toggle source
# File lib/awsclient.rb, line 53 def instance_profile_credentials ::Aws::InstanceProfileCredentials.new end
iot()
click to toggle source
# File lib/awsclient.rb, line 369 def iot @iot ||= ::Aws::IoT::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
iotdataplane()
click to toggle source
# File lib/awsclient.rb, line 376 def iotdataplane @iotdataplane ||= ::Aws::IoTDataPlane::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
kinesis()
click to toggle source
# File lib/awsclient.rb, line 390 def kinesis @kinesis ||= ::Aws::Kinesis::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
kms()
click to toggle source
# File lib/awsclient.rb, line 383 def kms @kms ||= ::Aws::KMS::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
lambda()
click to toggle source
# File lib/awsclient.rb, line 397 def lambda @lambda ||= ::Aws::Lambda::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
lambdapreview()
click to toggle source
# File lib/awsclient.rb, line 404 def lambdapreview @lambdapreview ||= ::Aws::LambdaPreview::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
load_credentials(profile_name='default')
click to toggle source
# File lib/awsclient.rb, line 44 def load_credentials(profile_name='default') creds = ::Aws::SharedCredentials.new(profile_name: profile_name) if creds.set? load_region_from_profile(profile_name) return creds end instance_profile_credentials end
machinelearning()
click to toggle source
# File lib/awsclient.rb, line 411 def machinelearning @machinelearning ||= ::Aws::MachineLearning::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
marketplacecommerceanalytics()
click to toggle source
# File lib/awsclient.rb, line 418 def marketplacecommerceanalytics @marketplacecommerceanalytics ||= ::Aws::MarketplaceCommerceAnalytics::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
opsworks()
click to toggle source
# File lib/awsclient.rb, line 425 def opsworks @opsworks ||= ::Aws::OpsWorks::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
profile()
click to toggle source
# File lib/awsclient.rb, line 75 def profile credentials.profile_name end
profile=(profile_name)
click to toggle source
# File lib/awsclient.rb, line 79 def profile=(profile_name) load_region_from_profile(profile_name) self.credentials = ::Aws::SharedCredentials.new(profile_name: profile_name) end
profile?()
click to toggle source
# File lib/awsclient.rb, line 71 def profile? credentials.respond_to?(:profile_name) end
rds()
click to toggle source
# File lib/awsclient.rb, line 432 def rds @rds ||= ::Aws::RDS::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
role=(role_name)
click to toggle source
# File lib/awsclient.rb, line 67 def role=(role_name) assume_role!(role_name) end
route53()
click to toggle source
# File lib/awsclient.rb, line 439 def route53 @route53 ||= ::Aws::Route53::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
route53domains()
click to toggle source
# File lib/awsclient.rb, line 446 def route53domains @route53domains ||= ::Aws::Route53Domains::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
s3()
click to toggle source
# File lib/awsclient.rb, line 453 def s3 @s3 ||= ::Aws::S3::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
s3_bucket(name, options = {})
click to toggle source
# File lib/awsclient.rb, line 460 def s3_bucket(name, options = {}) @bucket ||= ::Aws::S3::Bucket.new(name, { credentials: credentials, region: region }.merge(client_options)) end
ses()
click to toggle source
# File lib/awsclient.rb, line 467 def ses @ses ||= ::Aws::SES::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
simpledb()
click to toggle source
# File lib/awsclient.rb, line 509 def simpledb @simpledb ||= ::Aws::SimpleDB::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
sns()
click to toggle source
# File lib/awsclient.rb, line 474 def sns @sns ||= ::Aws::SNS::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
sqs()
click to toggle source
# File lib/awsclient.rb, line 481 def sqs @sqs ||= ::Aws::SQS::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
ssm()
click to toggle source
# File lib/awsclient.rb, line 488 def ssm @ssm ||= ::Aws::SSM::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
storagegateway()
click to toggle source
# File lib/awsclient.rb, line 516 def storagegateway @storagegateway ||= ::Aws::StorageGateway::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
sts()
click to toggle source
# File lib/awsclient.rb, line 495 def sts @sts ||= ::Aws::STS::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
support()
click to toggle source
# File lib/awsclient.rb, line 523 def support @support ||= ::Aws::Support::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
swf()
click to toggle source
# File lib/awsclient.rb, line 502 def swf @swf ||= ::Aws::SWF::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
underscored_region()
click to toggle source
# File lib/awsclient.rb, line 88 def underscored_region region.gsub('-', '_') end
waf()
click to toggle source
# File lib/awsclient.rb, line 530 def waf @waf ||= ::Aws::WAF::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
workspaces()
click to toggle source
# File lib/awsclient.rb, line 537 def workspaces @workspaces ||= ::Aws::WorkSpaces::Client.new({ credentials: credentials, region: region }.merge(client_options)) end
Private Instance Methods
load_region_from_profile(profile_name)
click to toggle source
# File lib/awsclient.rb, line 558 def load_region_from_profile(profile_name) awsconfig = File.read("#{ENV['HOME']}/.aws/config") matcher = awsconfig.match(/\[profile\s#{profile_name}\]\r?\n?region\s*=(.*)/) @region = matcher[1] if matcher end
random_string(length = nil)
click to toggle source
# File lib/awsclient.rb, line 552 def random_string(length = nil) length ||= rand(15..30) o = [('a'..'z'), ('A'..'Z'), (1..9)].map { |i| i.to_a }.flatten (0...length).map { o[rand(o.length)] }.join end
reload()
click to toggle source
# File lib/awsclient.rb, line 546 def reload SERVICES.each do |svc| send("#{svc}=".to_sym, nil) end end