Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.3.3
- Fix aliases 'ec2_start_instance' and 'ec2_stop_instance'

## 1.3.2
- Solved the bug regarding `aws_session_token` parameter for `boto3` cross account authentication in `actions.py`.

Expand Down
4 changes: 3 additions & 1 deletion aliases/ec2_get_all_instances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ pack: "aws"
description: "get all instances"
action_ref: "aws.ec2_get_all_instances"
formats:
- "aws ec2 get"
- display: "aws ec2 get"
representation:
- "aws ec2 get"
ack:
enabled: false
append_url: false
Expand Down
10 changes: 7 additions & 3 deletions aliases/ec2_start_instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ pack: "aws"
description: "start instance"
action_ref: "aws.ec2_start_instances"
formats:
- "aws ec2 start {{instance_ids}}"
- display: "aws ec2 start <InstanceIds>"
representation:
- "aws ec2 start {{InstanceIds}}"
ack:
enabled: false
append_url: false
Expand All @@ -15,6 +17,8 @@ result:
color: "#00ad52" # aka Slack 'good'
footer: "AWS Pack"
format: |
{% for ec2 in execution.result.result -%}
• {{ ec2.id }} - {{ ec2.state }}
{% for line in execution.result.result -%}
{% for ec2 in line.StartingInstances -%}
• {{ ec2.InstanceId }} - {{ ec2.CurrentState.Name }}
{% endfor %}
{%+ endfor %}
10 changes: 7 additions & 3 deletions aliases/ec2_stop_instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ pack: "aws"
description: "stop instance"
action_ref: "aws.ec2_stop_instances"
formats:
- "aws ec2 stop {{instance_ids}}"
- display: "aws ec2 stop <InstanceIds>"
representation:
- "aws ec2 stop {{InstanceIds}}"
ack:
enabled: true
append_url: true
Expand All @@ -14,6 +16,8 @@ result:
color: "#00ad52" # aka Slack 'good'
footer: "AWS Pack"
format: |
{% for ec2 in execution.result.result -%}
• {{ ec2.id }} - {{ ec2.state }}
{% for line in execution.result.result -%}
{% for ec2 in line.StoppingInstances -%}
• {{ ec2.InstanceId }} - {{ ec2.CurrentState.Name }}
{% endfor %}
{%+ endfor %}
2 changes: 1 addition & 1 deletion pack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ keywords:
- SQS
- lambda
- kinesis
version : 1.3.2
version : 1.3.3
author : StackStorm, Inc.
email : info@stackstorm.com
python_versions:
Expand Down
74 changes: 74 additions & 0 deletions tests/test_action_aliases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and

from st2tests.base import BaseActionAliasTestCase


class EC2Get(BaseActionAliasTestCase):
action_alias_name = "ec2_get_all_instances"

def test_alias_ec2_get(self):
format_string = self.action_alias_db.formats[0]['representation'][0]
format_strings = self.action_alias_db.get_format_strings()

command = "aws ec2 get"
expected_parameters = {
}

self.assertExtractedParametersMatch(format_string=format_string,
command=command,
parameters=expected_parameters)
self.assertCommandMatchesExactlyOneFormatString(
format_strings=format_strings,
command=command)


class EC2Start(BaseActionAliasTestCase):
action_alias_name = "ec2_start_instances"

def test_alias_ec2_start(self):
format_string = self.action_alias_db.formats[0]['representation'][0]
format_strings = self.action_alias_db.get_format_strings()

command = "aws ec2 start i-01234"
expected_parameters = {
'InstanceIds': 'i-01234'
}

self.assertExtractedParametersMatch(format_string=format_string,
command=command,
parameters=expected_parameters)
self.assertCommandMatchesExactlyOneFormatString(
format_strings=format_strings,
command=command)


class EC2Stop(BaseActionAliasTestCase):
action_alias_name = "ec2_stop_instances"

def test_alias_ec2_stop(self):
format_string = self.action_alias_db.formats[0]['representation'][0]
format_strings = self.action_alias_db.get_format_strings()

command = "aws ec2 stop i-01234"
expected_parameters = {
'InstanceIds': 'i-01234'
}

self.assertExtractedParametersMatch(format_string=format_string,
command=command,
parameters=expected_parameters)
self.assertCommandMatchesExactlyOneFormatString(
format_strings=format_strings,
command=command)