Class: F2yAwsTool::Deploy

Inherits:
Object
  • Object
show all
Defined in:
lib/f2y_aws_tool/deploy.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Deploy



4
5
6
# File 'lib/f2y_aws_tool/deploy.rb', line 4

def initialize(options)
  @options = options
end

Instance Method Details

#clientObject



20
21
22
23
24
25
26
27
28
# File 'lib/f2y_aws_tool/deploy.rb', line 20

def client
  @client ||= Aws::OpsWorks::Client.new(
      region: region,
      access_key_id: access_key_id,
      secret_access_key: secret_access_key,
      logger: aws_logger,
      log_level: aws_log_level
  )
end

#runObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/f2y_aws_tool/deploy.rb', line 8

def run
  deploy_id = create_deployment.deployment_id
  deployed_app = describe_deployment(deploy_id)
  log.info(sprintf("ID: %s, STATUS: %s", deploy_id, deployed_app.status))
  if wait?
    client.wait_until(:deployment_successful, deployment_ids: [deploy_id])
    deployed_app = describe_deployment(deploy_id)
    log.info(sprintf("ID: %s, STATUS: %s, DURATION: %s", deploy_id, deployed_app.status, Time.at(deployed_app.duration).utc.strftime("%H:%M:%S")))
  end
  return {deployment_id: deploy_id, status: deployed_app.status.to_sym}
end