Class: RubyAemAws::Component::StackManagerResources

Inherits:
Object
  • Object
show all
Includes:
AbstractStackManager, DynamoDB, MetricVerifier, S3Access, SNSTopic
Defined in:
lib/ruby_aem_aws/component/stack_manager_resources.rb

Overview

Interface to the AWS StackManager to send out commands

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from S3Access

#get_s3_bucket, #get_s3_bucket_object, #get_s3_object

Methods included from SNSTopic

#publish

Methods included from MetricVerifier

#alarm?, #component_alarm?, #component_ec2_metric?, #component_log_event?, #component_log_stream?, #component_loggroup?, #component_metric?, #log_event?, #log_stream?, #loggroup?, #metric?

Methods included from RubyAemAws::CloudwatchClient

#get_alarm, #get_log_event, #get_log_streams, #get_metrics

Methods included from DynamoDB

#query, #scan

Constructor Details

#initialize(params) ⇒ Object

  • CloudWatchClient: AWS Cloudwatch Client.

  • CloudWatchLogsClient: AWS Cloudwatch Logs Client.

  • DynamoDBClient: AWS DynamoDB Client.

  • S3Client: AWS S3 Client.

  • S3Resource: AWS S3 Resource connection.

Parameters:

  • params

    Array of AWS Clients and Resource connections:



39
40
41
42
43
44
45
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 39

def initialize(params)
  @dynamodb_client = params[:DynamoDBClient]
  @s3_client = params[:S3Client]
  @s3_resource = params[:S3Resource]
  @cloud_watch_client = params[:CloudWatchLogsClient]
  @cloud_watch_log_client = params[:CloudWatchLogsClient]
end

Instance Attribute Details

#cloud_watch_clientObject (readonly)

Returns the value of attribute cloud_watch_client.



25
26
27
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 25

def cloud_watch_client
  @cloud_watch_client
end

#cloud_watch_log_clientObject (readonly)

Returns the value of attribute cloud_watch_log_client.



25
26
27
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 25

def cloud_watch_log_client
  @cloud_watch_log_client
end

#dynamodb_clientObject (readonly)

Returns the value of attribute dynamodb_client.



25
26
27
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 25

def dynamodb_client
  @dynamodb_client
end

#s3_clientObject (readonly)

Returns the value of attribute s3_client.



25
26
27
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 25

def s3_client
  @s3_client
end

#s3_resourceObject (readonly)

Returns the value of attribute s3_resource.



25
26
27
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 25

def s3_resource
  @s3_resource
end

Instance Method Details

#dyn_db_cmd_query(dynamodb_tablename, attribute_value) ⇒ Object

Returns Command state.

Parameters:

  • dynamodb_tablename

    AWS DynamoDB table name

  • attribute_value

    Attribute value to query for

Returns:

  • Command state



67
68
69
70
71
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 67

def dyn_db_cmd_query(dynamodb_tablename, attribute_value)
  key_attribute_value = attribute_value.items[0]['command_id']
  state = query(filter_for_db_query(dynamodb_tablename, key_attribute_value))
  state.items[0]['state']
end

#dyn_db_msg_scan(dynamodb_tablename, attribute_value) ⇒ Object

Returns Scan result.

Parameters:

  • dynamodb_tablename

    AWS DynamoDB table name

  • attribute_value

    Attribute value to scan for

Returns:

  • Scan result



60
61
62
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 60

def dyn_db_msg_scan(dynamodb_tablename, attribute_value)
  scan(filter_for_db_scan(dynamodb_tablename, attribute_value))
end

#s3_download_object(s3_bucket_name, s3_object_name, dest_path = nil) ⇒ Object

Returns AWS S3 client object.

Parameters:

  • s3_bucket_name

    S3 bucketname

  • s3_object_name

    S3 Object name

  • dest_path (defaults to: nil)

    local download path, default: nil

Returns:

  • AWS S3 client object



84
85
86
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 84

def s3_download_object(s3_bucket_name, s3_object_name, dest_path = nil)
  get_s3_object(s3_bucket_name, s3_object_name, dest_path)
end

#s3_resource_object(s3_bucket_name, s3_object_name) ⇒ Object

Returns AWS S3 resource object.

Parameters:

  • s3_bucket_name

    S3 bucketname

  • s3_object_name

    S3 Object name

Returns:

  • AWS S3 resource object



76
77
78
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 76

def s3_resource_object(s3_bucket_name, s3_object_name)
  get_s3_bucket_object(s3_bucket_name, s3_object_name)
end

#sns_publish(topicarn, task, stack_prefix, details) ⇒ Object

Returns AWS SNS publish message id.

Parameters:

  • topicarn

    AWS SNS-Topic ARN

  • task

    AEM StackManager task

  • stack_prefix

    AEM Stack-Prefix

  • details

    AEM StackManager task detail message

Returns:

  • AWS SNS publish message id



52
53
54
55
# File 'lib/ruby_aem_aws/component/stack_manager_resources.rb', line 52

def sns_publish(topicarn, task, stack_prefix, details)
  details = JSON.generate(details).tr('\"', '\'')
  publish(topicarn, message_for_sns_publish(task, stack_prefix, details))
end