Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/functional/cloudformation/test_create_stack.py
1567 views
1
#!/usr/bin/env python
2
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License"). You
5
# may not use this file except in compliance with the License. A copy of
6
# the License is located at
7
#
8
# http://aws.amazon.com/apache2.0/
9
#
10
# or in the "license" file accompanying this file. This file is
11
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
# ANY KIND, either express or implied. See the License for the specific
13
# language governing permissions and limitations under the License.
14
from awscli.testutils import BaseAWSCommandParamsTest
15
16
17
class TestCreateStack(BaseAWSCommandParamsTest):
18
19
prefix = 'cloudformation create-stack'
20
21
def test_basic_create_stack(self):
22
cmdline = self.prefix
23
cmdline += ' --stack-name test-stack --template-url http://foo'
24
result = {'StackName': 'test-stack', 'TemplateURL': 'http://foo'}
25
self.assert_params_for_cmd(cmdline, result)
26
27
def test_create_stack_string_params(self):
28
cmdline = self.prefix
29
cmdline += ' --stack-name test-stack --template-url http://foo'
30
cmdline += ' --parameters ParameterKey=foo,ParameterValue=bar'
31
cmdline += ' ParameterKey=foo2,ParameterValue=bar2'
32
result = {'StackName': 'test-stack', 'TemplateURL': 'http://foo',
33
'Parameters': [
34
{'ParameterKey': 'foo', 'ParameterValue': 'bar'},
35
{'ParameterKey': 'foo2', 'ParameterValue': 'bar2'},
36
]}
37
self.assert_params_for_cmd(cmdline, result)
38
39
def test_create_stack_for_csv_params_escaping(self):
40
# If a template is specified as a comma delimited list,
41
# we need to be able to quote the value or escape the comma.
42
cmdline = self.prefix
43
cmdline += ' --stack-name test-stack --template-url http://foo'
44
cmdline += ' --parameters ParameterKey=foo,ParameterValue=one\,two'
45
result = {'StackName': 'test-stack', 'TemplateURL': 'http://foo',
46
'Parameters': [{'ParameterKey': 'foo',
47
'ParameterValue': 'one,two'}]}
48
self.assert_params_for_cmd(cmdline, result)
49
50
def test_create_stack_for_csv_with_quoting(self):
51
cmdline = self.prefix
52
cmdline += ' --stack-name test-stack --template-url http://foo'
53
# Note how we're quoting the value of parameter_value.
54
cmdline += ' --parameters ParameterKey=foo,ParameterValue="one,two"'
55
result = {'StackName': 'test-stack', 'TemplateURL': 'http://foo',
56
'Parameters': [{'ParameterKey': 'foo',
57
'ParameterValue': 'one,two'}]}
58
self.assert_params_for_cmd(cmdline, result)
59
60
def test_can_handle_empty_parameters(self):
61
cmdline = self.prefix
62
cmdline += ' --stack-name test --parameters --template-url http://foo'
63
result = {'StackName': 'test', 'TemplateURL': 'http://foo',
64
'Parameters': []}
65
self.assert_params_for_cmd(cmdline, result)
66
67