Allow actual use of cloudformation input parameters.
This commit is contained in:
parent
56007660d8
commit
1e4df18c42
7 changed files with 114 additions and 22 deletions
|
|
@ -6,13 +6,13 @@ import boto
|
|||
import boto.s3
|
||||
import boto.s3.key
|
||||
import boto.cloudformation
|
||||
from boto.exception import BotoServerError
|
||||
import sure # noqa
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
import tests.backport_assert_raises # noqa
|
||||
from nose.tools import assert_raises
|
||||
|
||||
from moto import mock_cloudformation, mock_s3
|
||||
from moto.cloudformation.exceptions import ValidationError
|
||||
|
||||
dummy_template = {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
|
|
@ -182,7 +182,7 @@ def test_delete_stack_by_id():
|
|||
conn.list_stacks().should.have.length_of(1)
|
||||
conn.delete_stack(stack_id)
|
||||
conn.list_stacks().should.have.length_of(0)
|
||||
with assert_raises(ValidationError):
|
||||
with assert_raises(BotoServerError):
|
||||
conn.describe_stacks("test_stack")
|
||||
|
||||
conn.describe_stacks(stack_id).should.have.length_of(1)
|
||||
|
|
@ -191,10 +191,34 @@ def test_delete_stack_by_id():
|
|||
@mock_cloudformation
|
||||
def test_bad_describe_stack():
|
||||
conn = boto.connect_cloudformation()
|
||||
with assert_raises(ValidationError):
|
||||
with assert_raises(BotoServerError):
|
||||
conn.describe_stacks("bad_stack")
|
||||
|
||||
|
||||
@mock_cloudformation()
|
||||
def test_cloudformation_params():
|
||||
dummy_template = {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "Stack 1",
|
||||
"Resources": {},
|
||||
"Parameters": {
|
||||
"APPNAME": {
|
||||
"Default": "app-name",
|
||||
"Description": "The name of the app",
|
||||
"Type": "String"
|
||||
}
|
||||
}
|
||||
}
|
||||
dummy_template_json = json.dumps(dummy_template)
|
||||
cfn = boto.connect_cloudformation()
|
||||
cfn.create_stack('test_stack1', template_body=dummy_template_json, parameters=[('APPNAME', 'testing123')])
|
||||
stack = cfn.describe_stacks('test_stack1')[0]
|
||||
stack.parameters.should.have.length_of(1)
|
||||
param = stack.parameters[0]
|
||||
param.key.should.equal('APPNAME')
|
||||
param.value.should.equal('testing123')
|
||||
|
||||
|
||||
# @mock_cloudformation
|
||||
# def test_update_stack():
|
||||
# conn = boto.connect_cloudformation()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import boto.cloudformation
|
|||
import boto.ec2
|
||||
import boto.ec2.autoscale
|
||||
import boto.ec2.elb
|
||||
from boto.exception import BotoServerError
|
||||
import boto.iam
|
||||
import boto.vpc
|
||||
import sure # noqa
|
||||
|
|
@ -311,6 +312,7 @@ def test_vpc_single_instance_in_subnet():
|
|||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=template_json,
|
||||
parameters=[("KeyName", "my_key")],
|
||||
)
|
||||
|
||||
vpc_conn = boto.vpc.connect_to_region("us-west-1")
|
||||
|
|
@ -474,6 +476,7 @@ def test_single_instance_with_ebs_volume():
|
|||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=template_json,
|
||||
parameters=[("KeyName", "key_name")]
|
||||
)
|
||||
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
|
|
@ -490,6 +493,16 @@ def test_single_instance_with_ebs_volume():
|
|||
ebs_volume.physical_resource_id.should.equal(volume.id)
|
||||
|
||||
|
||||
@mock_cloudformation()
|
||||
def test_create_template_without_required_param():
|
||||
template_json = json.dumps(single_instance_with_ebs_volume.template)
|
||||
conn = boto.cloudformation.connect_to_region("us-west-1")
|
||||
conn.create_stack.when.called_with(
|
||||
"test_stack",
|
||||
template_body=template_json,
|
||||
).should.throw(BotoServerError)
|
||||
|
||||
|
||||
@mock_ec2()
|
||||
@mock_cloudformation()
|
||||
def test_classic_eip():
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ def test_parse_stack_resources():
|
|||
stack_id="test_id",
|
||||
name="test_stack",
|
||||
template=dummy_template_json,
|
||||
parameters={},
|
||||
region_name='us-west-1')
|
||||
|
||||
stack.resource_map.should.have.length_of(1)
|
||||
|
|
@ -102,6 +103,7 @@ def test_parse_stack_with_name_type_resource():
|
|||
stack_id="test_id",
|
||||
name="test_stack",
|
||||
template=name_type_template_json,
|
||||
parameters={},
|
||||
region_name='us-west-1')
|
||||
|
||||
stack.resource_map.should.have.length_of(1)
|
||||
|
|
@ -115,6 +117,7 @@ def test_parse_stack_with_outputs():
|
|||
stack_id="test_id",
|
||||
name="test_stack",
|
||||
template=output_type_template_json,
|
||||
parameters={},
|
||||
region_name='us-west-1')
|
||||
|
||||
stack.output_map.should.have.length_of(1)
|
||||
|
|
@ -129,6 +132,7 @@ def test_parse_stack_with_get_attribute_outputs():
|
|||
stack_id="test_id",
|
||||
name="test_stack",
|
||||
template=get_attribute_outputs_template_json,
|
||||
parameters={},
|
||||
region_name='us-west-1')
|
||||
|
||||
stack.output_map.should.have.length_of(1)
|
||||
|
|
@ -140,4 +144,4 @@ def test_parse_stack_with_get_attribute_outputs():
|
|||
|
||||
def test_parse_stack_with_bad_get_attribute_outputs():
|
||||
FakeStack.when.called_with(
|
||||
"test_id", "test_stack", bad_output_template_json, "us-west-1").should.throw(BotoServerError)
|
||||
"test_id", "test_stack", bad_output_template_json, {}, "us-west-1").should.throw(BotoServerError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue