当前位置: 首页>>代码示例>>Python>>正文


Python cfn.CloudFormation类代码示例

本文整理汇总了Python中cfn_sphere.aws.cfn.CloudFormation的典型用法代码示例。如果您正苦于以下问题:Python CloudFormation类的具体用法?Python CloudFormation怎么用?Python CloudFormation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CloudFormation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_stack_calls_cloudformation_api_properly_with_service_role

    def test_create_stack_calls_cloudformation_api_properly_with_service_role(self, _, cloudformation_mock):
        stack = Mock(spec=CloudFormationStack)
        stack.name = "stack-name"
        stack.get_parameters_list.return_value = [('a', 'b')]
        stack.get_tags_list.return_value = [('any-tag', 'any-tag-value')]
        stack.parameters = {}
        stack.template = Mock(spec=CloudFormationTemplate)
        stack.template.name = "template-name"
        stack.template.get_template_json.return_value = {'key': 'value'}
        stack.service_role = "arn:aws:iam::1234567890:role/my-role"
        stack.stack_policy = None
        stack.failure_action = None
        stack.disable_rollback = False
        stack.timeout = 42

        cfn = CloudFormation()
        cfn.create_stack(stack)

        cloudformation_mock.return_value.create_stack.assert_called_once_with(
            Capabilities=['CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM'],
            Parameters=[('a', 'b')],
            StackName='stack-name',
            Tags=[('any-tag', 'any-tag-value')],
            TemplateBody={'key': 'value'},
            RoleARN="arn:aws:iam::1234567890:role/my-role"
        )
开发者ID:matt-wormley,项目名称:cfn-sphere,代码行数:26,代码来源:cfn_tests.py

示例2: test_create_stack_calls_cloudformation_api_properly_with_stack_policy

    def test_create_stack_calls_cloudformation_api_properly_with_stack_policy(self, _, cloudformation_mock):
        stack = Mock(spec=CloudFormationStack)
        stack.name = "stack-name"
        stack.get_parameters_list.return_value = [('a', 'b')]
        stack.get_tags_list.return_value = [('any-tag', 'any-tag-value')]
        stack.parameters = {}
        stack.template = Mock(spec=CloudFormationTemplate)
        stack.template.name = "template-name"
        stack.template.get_template_json.return_value = {'key': 'value'}
        stack.service_role = None
        stack.stack_policy = "{foo:baa}"
        stack.timeout = 42

        cfn = CloudFormation()
        cfn.create_stack(stack)

        cloudformation_mock.return_value.create_stack.assert_called_once_with(
            Capabilities=['CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM'],
            OnFailure='ROLLBACK',
            Parameters=[('a', 'b')],
            StackName='stack-name',
            Tags=[('any-tag', 'any-tag-value')],
            TemplateBody={'key': 'value'},
            StackPolicyBody='"{foo:baa}"'
        )
开发者ID:matey-jack,项目名称:cfn-sphere,代码行数:25,代码来源:cfn_tests.py

示例3: test_validate_stack_is_ready_for_action_passes_if_stack_is_in_rollback_complete_state

    def test_validate_stack_is_ready_for_action_passes_if_stack_is_in_rollback_complete_state(self, get_stack_mock):
        stack_mock = Mock()
        stack_mock.stack_name = "my-stack"
        stack_mock.stack_status = "ROLLBACK_COMPLETE"
        get_stack_mock.return_value = stack_mock

        stack = CloudFormationStack('', [], 'my-stack', 'my-region')

        cfn = CloudFormation()
        cfn.validate_stack_is_ready_for_action(stack)
开发者ID:matey-jack,项目名称:cfn-sphere,代码行数:10,代码来源:cfn_tests.py

示例4: test_validate_stack_is_ready_for_action_raises_proper_exception_on_boto_error

    def test_validate_stack_is_ready_for_action_raises_proper_exception_on_boto_error(self, cloudformation_mock):
        cloudformation_mock.return_value.describe_stacks.side_effect = BotoServerError('400', 'Bad Request')

        stack = CloudFormationStack('', [], 'my-stack', 'my-region')

        cfn = CloudFormation()
        with self.assertRaises(CfnSphereBotoError):
            cfn.validate_stack_is_ready_for_action(stack)

        cloudformation_mock.return_value.describe_stacks.assert_called_once_with('my-stack')
开发者ID:oliver-schoenherr,项目名称:cfn-sphere,代码行数:10,代码来源:cfn_tests.py

示例5: test_get_stacks_correctly_calls_aws_api

    def test_get_stacks_correctly_calls_aws_api(self, cloudformation_mock):
        stacks = [Mock(spec=Stack), Mock(spec=Stack)]

        result = ResultSet()
        result.extend(stacks)
        result.next_token = None
        cloudformation_mock.connect_to_region.return_value.describe_stacks.return_value = result

        cfn = CloudFormation()
        self.assertListEqual(stacks, cfn.get_stacks())
开发者ID:oliver-schoenherr,项目名称:cfn-sphere,代码行数:10,代码来源:cfn_tests.py

示例6: test_get_stack_parameters_dict_returns_empty_dict_for_empty_parameters

    def test_get_stack_parameters_dict_returns_empty_dict_for_empty_parameters(self, _, get_stack_mock):
        cfn = CloudFormation()

        stack_mock = Mock()
        stack_mock.parameters = []
        get_stack_mock.return_value = stack_mock

        result = cfn.get_stack_parameters_dict('foo')

        self.assertDictEqual({}, result)
开发者ID:matey-jack,项目名称:cfn-sphere,代码行数:10,代码来源:cfn_tests.py

示例7: test_validate_stack_is_ready_for_action_raises_exception_on_create_in_progress

    def test_validate_stack_is_ready_for_action_raises_exception_on_create_in_progress(self, get_stack_mock):
        stack_mock = Mock()
        stack_mock.stack_name = "my-stack"
        stack_mock.stack_status = "CREATE_IN_PROGRESS"
        get_stack_mock.return_value = stack_mock

        stack = CloudFormationStack('', [], 'my-stack', 'my-region')

        cfn = CloudFormation()
        with self.assertRaises(CfnStackActionFailedException):
            cfn.validate_stack_is_ready_for_action(stack)
开发者ID:matey-jack,项目名称:cfn-sphere,代码行数:11,代码来源:cfn_tests.py

示例8: test_validate_stack_is_ready_for_action_raises_exception_on_unknown_stack_state

    def test_validate_stack_is_ready_for_action_raises_exception_on_unknown_stack_state(self, get_stack_mock):
        stack_mock = Mock()
        stack_mock.stack_name = "my-stack"
        stack_mock.stack_status = "FOO"
        get_stack_mock.return_value = stack_mock

        stack = CloudFormationStack('', [], 'my-stack', 'my-region')

        cfn = CloudFormation()
        with self.assertRaises(CfnStackActionFailedException):
            cfn.validate_stack_is_ready_for_action(stack)
开发者ID:matey-jack,项目名称:cfn-sphere,代码行数:11,代码来源:cfn_tests.py

示例9: test_get_stack_parameters_dict_returns_proper_dict

    def test_get_stack_parameters_dict_returns_proper_dict(self, _, get_stack_mock):
        cfn = CloudFormation()

        stack_mock = Mock()
        stack_mock.parameters = [{"ParameterKey": "myKey1", "ParameterValue": "myValue1"},
                                 {"ParameterKey": "myKey2", "ParameterValue": "myValue2"}]
        get_stack_mock.return_value = stack_mock

        result = cfn.get_stack_parameters_dict('foo')

        self.assertDictEqual({'myKey1': 'myValue1', 'myKey2': 'myValue2'}, result)
开发者ID:matey-jack,项目名称:cfn-sphere,代码行数:11,代码来源:cfn_tests.py

示例10: test_validate_stack_is_ready_for_action_passes_if_stack_is_in_good_state

    def test_validate_stack_is_ready_for_action_passes_if_stack_is_in_good_state(self, cloudformation_mock):
        describe_stack_mock = Mock()
        describe_stack_mock.stack_status = "UPDATE_COMPLETE"
        describe_stack_mock.stack_name = "my-stack"

        cloudformation_mock.return_value.describe_stacks.return_value = [describe_stack_mock]

        stack = CloudFormationStack('', [], 'my-stack', 'my-region')

        cfn = CloudFormation()
        cfn.validate_stack_is_ready_for_action(stack)

        cloudformation_mock.return_value.describe_stacks.assert_called_once_with('my-stack')
开发者ID:oliver-schoenherr,项目名称:cfn-sphere,代码行数:13,代码来源:cfn_tests.py

示例11: test_validate_stack_is_ready_for_action_raises_proper_exception_on_boto_error

    def test_validate_stack_is_ready_for_action_raises_proper_exception_on_boto_error(self, get_stack_mock):
        get_stack_mock.side_effect = CfnSphereBotoError(None)

        stack_mock = Mock()
        stack_mock.stack_name = "my-stack"
        stack_mock.stack_status = "UPDATE_COMPLETE"
        get_stack_mock.return_value = stack_mock

        stack = CloudFormationStack('', [], 'my-stack', 'my-region')

        cfn = CloudFormation()
        with self.assertRaises(CfnSphereBotoError):
            cfn.validate_stack_is_ready_for_action(stack)
开发者ID:matey-jack,项目名称:cfn-sphere,代码行数:13,代码来源:cfn_tests.py

示例12: test_validate_stack_is_ready_for_action_raises_exception_on_bad_stack_state

    def test_validate_stack_is_ready_for_action_raises_exception_on_bad_stack_state(self, cloudformation_mock):
        describe_stack_mock = Mock()
        describe_stack_mock.stack_status = "UPDATE_IN_PROGRESS"
        describe_stack_mock.stack_name = "my-stack"

        cloudformation_mock.return_value.describe_stacks.return_value = [describe_stack_mock]

        stack = CloudFormationStack('', [], 'my-stack', 'my-region')

        cfn = CloudFormation()
        with self.assertRaises(CfnStackActionFailedException):
            cfn.validate_stack_is_ready_for_action(stack)

        cloudformation_mock.return_value.describe_stacks.assert_called_once_with('my-stack')
开发者ID:oliver-schoenherr,项目名称:cfn-sphere,代码行数:14,代码来源:cfn_tests.py

示例13: test_handle_stack_event_raises_exception_on_rollback_complete

    def test_handle_stack_event_raises_exception_on_rollback_complete(self, _):
        event = {
            'PhysicalResourceId': 'arn:aws:sns:eu-west-1:1234567890:my-topic',
            'StackName': 'my-stack',
            'LogicalResourceId': 'VPC',
            'StackId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id',
            'ResourceType': 'AWS::CloudFormation::Stack',
            'Timestamp': datetime.datetime(2016, 4, 1, 8, 3, 27, 548000, tzinfo=tzutc()),
            'EventId': 'my-event-id',
            'ResourceStatus': 'ROLLBACK_COMPLETE'
        }
        valid_from_timestamp = datetime.datetime(2016, 4, 1, 8, 3, 25, 548000, tzinfo=tzutc())
        cfn = CloudFormation()

        with self.assertRaises(CfnStackActionFailedException):
            cfn.handle_stack_event(event, valid_from_timestamp, "CREATE_COMPLETE")
开发者ID:matey-jack,项目名称:cfn-sphere,代码行数:16,代码来源:cfn_tests.py

示例14: test_handle_stack_event_returns_none_if_event_is_no_stack_event

    def test_handle_stack_event_returns_none_if_event_is_no_stack_event(self, _):
        event = {
            'PhysicalResourceId': 'arn:aws:sns:eu-west-1:1234567890:my-topic',
            'StackName': 'my-stack',
            'LogicalResourceId': 'Topic',
            'StackId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id',
            'ResourceType': 'AWS::SNS::Topic',
            'Timestamp': datetime.datetime(2016, 4, 1, 8, 3, 27, 548000, tzinfo=tzutc()),
            'EventId': 'my-event-id',
            'ResourceStatus': 'CREATE_COMPLETE'
        }
        valid_from_timestamp = datetime.datetime(2016, 4, 1, 8, 3, 25, 548000, tzinfo=tzutc())
        cfn = CloudFormation()

        result = cfn.handle_stack_event(event, valid_from_timestamp, "CREATE_COMPLETE", "my-stack")
        self.assertIsNone(result)
开发者ID:matt-wormley,项目名称:cfn-sphere,代码行数:16,代码来源:cfn_tests.py

示例15: test_get_stacks_correctly_aggregates_paged_results

    def test_get_stacks_correctly_aggregates_paged_results(self, cloudformation_mock):
        stacks_1 = [Mock(spec=Stack), Mock(spec=Stack)]
        stacks_2 = [Mock(spec=Stack), Mock(spec=Stack)]

        result_1 = ResultSet()
        result_1.extend(stacks_1)
        result_1.next_token = "my-next-token"

        result_2 = ResultSet()
        result_2.extend(stacks_2)
        result_2.next_token = None

        cloudformation_mock.connect_to_region.return_value.describe_stacks.side_effect = [result_1, result_2]

        cfn = CloudFormation()
        self.assertListEqual(stacks_1 + stacks_2, cfn.get_stacks())
开发者ID:oliver-schoenherr,项目名称:cfn-sphere,代码行数:16,代码来源:cfn_tests.py


注:本文中的cfn_sphere.aws.cfn.CloudFormation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。