Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Added service hook for AWS OpsWorks
Browse files Browse the repository at this point in the history
  • Loading branch information
jansiwy authored and kdaigle committed Dec 12, 2013
1 parent 9906e1b commit 47661bd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion github-services.gemspec
Expand Up @@ -54,7 +54,7 @@ Gem::Specification.new do |spec|
# Softlayer Messaging
spec.add_dependency "softlayer_messaging", "~> 1.0.2"

# Amazon SNS, Amazon SQS
# Amazon SNS, Amazon SQS, AWS OpsWorks
spec.add_dependency "aws-sdk", "~> 1.27"
spec.add_dependency "httparty", "0.7.4"

Expand Down
32 changes: 32 additions & 0 deletions lib/services/aws_ops_works.rb
@@ -0,0 +1,32 @@
require 'aws/ops_works'

class Service::AwsOpsWorks < Service::HttpPost
self.title = 'AWS OpsWorks'

string :stack_id, # see StackId at http://docs.aws.amazon.com/opsworks/latest/APIReference/API_Stack.html
:app_id, # see AppId at http://docs.aws.amazon.com/opsworks/latest/APIReference/API_App.html
:branch_name, # see Revision at http://docs.aws.amazon.com/opsworks/latest/APIReference/API_Source.html
:aws_access_key_id # see AWSAccessKeyID at http://docs.aws.amazon.com/opsworks/latest/APIReference/CommonParameters.html
password :aws_secret_access_key

white_list :stack_id,
:app_id,
:branch_name,
:aws_access_key_id

def receive_event
create_deployment if branch_name == required_config_value('branch_name')
end

def create_deployment
ops_works_client.create_deployment stack_id: required_config_value('stack_id'),
app_id: required_config_value('app_id'),
command: { name: 'deploy' }
end

def ops_works_client
AWS::OpsWorks::Client.new access_key_id: required_config_value('aws_access_key_id'),
secret_access_key: required_config_value('aws_secret_access_key')
end

end

0 comments on commit 47661bd

Please sign in to comment.