def test_export_basic_stack(self): """Should be able to create and export a simple stack example.""" stack = Stack() stack.Resources["SomeName"] = SimpleResource() output = stack.export("yaml") assert output == dedent(""" --- AWSTemplateFormatVersion: '2010-09-09' Resources: SomeName: Type: NameSpace::Service::Resource """)
def test_export_basic_stack(self): """Should be able to create and export a simple stack example.""" stack = Stack() stack.Resources["SomeName"] = SimpleResource() output = stack.export("yaml") assert output == dedent(""" --- AWSTemplateFormatVersion: '2010-09-09' Metadata: FlyingCircus: version: {} Resources: SomeName: Type: NameSpace::Service::SimpleResource """.format(flyingcircus.__version__))
def test_stack_yaml_output(self): """An integration test, yay!""" # Setup data = SingleAttributeObject(one=42) stack = Stack(Resources=dict(Foo=data, Bar=Ref(data))) del stack.Metadata # Exercise output = stack.export("yaml") # Verify assert output == dedent(""" --- AWSTemplateFormatVersion: '2010-09-09' Resources: Bar: !Ref Foo Foo: one: 42 """)
def test_yaml_output_with_nested_function(self): """Nested YAML functions can't both use the ! short form.""" # Setup func = ImportValue(Sub("${AWS::Region}-SharedLogBucket")) data = SingleAttributeObject(one=func) stack = Stack(Resources=dict(SomeResource=data)) del stack.Metadata # Exercise output = stack.export("yaml") # Verify assert output == dedent(""" --- AWSTemplateFormatVersion: '2010-09-09' Resources: SomeResource: one: Fn::ImportValue: !Sub '${AWS::Region}-SharedLogBucket' """)
def test_yaml_output_with_nested_function(self): """Nested YAML functions can't both use the ! short form.""" # Setup func = GetAZs(Ref(AWS_Region)) data = SingleAttributeObject(one=func) stack = Stack(Resources=dict(SomeResource=data)) del stack.Metadata # Exercise output = stack.export("yaml") # Verify assert output == dedent(""" --- AWSTemplateFormatVersion: '2010-09-09' Resources: SomeResource: one: Fn::GetAZs: !Ref AWS::Region """)
def test_yaml_output_with_nested_function(self): """Nested YAML functions can't both use the ! short form.""" # TODO #37 do this with a Sub to be more realistic # Setup func = Base64(Ref(AWS_StackName)) data = SingleAttributeObject(one=func) stack = Stack(Resources=dict(SomeResource=data)) del stack.Metadata # Exercise output = stack.export("yaml") # Verify assert output == dedent(""" --- AWSTemplateFormatVersion: '2010-09-09' Resources: SomeResource: one: Fn::Base64: !Ref AWS::StackName """)
def test_yaml_output_with_nested_function(self): # Setup data = SingleAttributeObject(one=42) stack = Stack(Resources=dict( Foo=data, Bar=GetAtt(data, "ResourceAttrib1", Ref(AWS_Region)))) del stack.Metadata # Exercise output = stack.export("yaml") # Verify assert output == dedent(""" --- AWSTemplateFormatVersion: '2010-09-09' Resources: Bar: Fn::GetAtt: - Foo - ResourceAttrib1 - !Ref AWS::Region Foo: one: 42 """)
def _write_cfn_template(output, appconfig: dict, stack: Stack): """Write the CloudFormation template""" output.write(stack.export("yaml"))