Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag-based stack start/stop #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lohgannash
Copy link
Contributor

No description provided.

@Guslington Guslington linked an issue Dec 21, 2021 that may be closed by this pull request
CfnManage::CloudFormation::EnvironmentRunStop.new().stop_environment($options['STACK_NAME'], 'stack')
elsif $options['STACK_TAG']
CfnManage::CloudFormation::EnvironmentRunStop.new().stop_environment($options['STACK_TAG'], 'tag')
end
Copy link
Contributor

@Guslington Guslington Dec 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show the user an error if either STACK_NAME or STACK_TAG isn't supplied

CfnManage::CloudFormation::EnvironmentRunStop.new().start_environment($options['STACK_NAME'], 'stack')
elsif $options['STACK_TAG']
CfnManage::CloudFormation::EnvironmentRunStop.new().start_environment($options['STACK_TAG'], 'tag')
end
Copy link
Contributor

@Guslington Guslington Dec 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show the user an error if either STACK_NAME or STACK_TAG isn't supplied

elsif arg_type == 'stack'
stacks.push(arg)
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw an error if no stacks are found


tag_key = tag.split('=')[0]
tag_value = tag.split('=')[1]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle --stack-tag input if format is not equal to key=value and return error to user

Copy link
Contributor

@Samseppiol Samseppiol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few comments/suggestions. Likely being a little fussy


lookup_results = []

tag_key = tag.split('=')[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly being pedantic but could you simplify to
tag_key, tag_value = tag.split('=')
Unless you're expecting more than two elements?

tag_value = tag.split('=')[1]

cf_resource = Aws::CloudFormation::Resource.new()
stack_collection = cf_resource.stacks.each { |stack|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why assign the loop to a variable?

cf_resource = Aws::CloudFormation::Resource.new()
stack_collection = cf_resource.stacks.each { |stack|
next if !stack.root_id.nil?
stack.tags.each { |tag|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use .select here instead of .each

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add ability to lookup multiple cloudformation stacks by tag
3 participants