Skip to content

Commit

Permalink
Merge pull request #62 from kaushik/35-configurable-role
Browse files Browse the repository at this point in the history
Make code deploy role configurable
  • Loading branch information
askreet committed Mar 10, 2016
2 parents 77b1ada + 8182817 commit 04ad1c5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/moonshot/deployment_mechanism/code_deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ class Moonshot::DeploymentMechanism::CodeDeploy # rubocop:disable ClassLength
# @param asg [String]
# The logical name of the AutoScalingGroup to create and manage a Deployment
# Group for in CodeDeploy.
# @param role [String]
# IAM role with AWSCodeDeployRole policy. CodeDeployRole is considered as
# default role if its not specified.
# @param app_name [String, nil] (nil)
# The name of the CodeDeploy Application and Deployment Group. By default,
# this is the same as the stack name, and probably what you want. If you
# have multiple deployments in a single Stack, they must have unique names.
def initialize(asg:, app_name: nil)
def initialize(asg:, role: 'CodeDeployRole', app_name: nil)
@asg_logical_id = asg
@app_name = app_name
@codedeploy_role = role
end

def post_create_hook
Expand Down Expand Up @@ -180,9 +184,9 @@ def deployment_group_ok?
end

def role
iam_client.get_role(role_name: 'CodeDeployRole').role
iam_client.get_role(role_name: @codedeploy_role).role
rescue Aws::IAM::Errors::NoSuchEntity
raise Thor::Error, 'Did not find an IAM Role: CodeDeployRole'
raise Thor::Error, "Did not find an IAM Role: #{@codedeploy_role}"
end

def delete_deployment_group
Expand Down Expand Up @@ -281,16 +285,16 @@ def s3_revision_for(artifact_repo, version_name)
end

def doctor_check_code_deploy_role
iam_client.get_role(role_name: 'CodeDeployRole').role
success('CodeDeployRole exists.')
iam_client.get_role(role_name: @codedeploy_role).role
success("#{@codedeploy_role} exists.")
rescue => e
help = <<-EOF
Error: #{e.message}
For information on provisioning an account for use with CodeDeploy, see:
http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-create-service-role.html
EOF
critical('Could not find CodeDeployRole, ', help)
critical("Could not find #{@codedeploy_role}, ", help)
end

def doctor_check_auto_scaling_resource_defined
Expand Down

0 comments on commit 04ad1c5

Please sign in to comment.