Exemplo n.º 1
0
    def test_transform_taupage_user_data_key(self):
        input = {
            "application_id": "stackName",
            "application_version": "imageVersion",
            "environment": {
                "SSO_KEY": "mySsoKey",
                "QUEUE_URL": {"ref": "myQueueUrl"}
            }
        }
        expected = {'Fn::Base64':
            {
                'Fn::Join':
                    ['\n', ['#taupage-ami-config',
                            {'Fn::Join': [': ', ['application_id', 'stackName']]},
                            {'Fn::Join': [': ', ['application_version', 'imageVersion']]},
                            'environment:',
                            {'Fn::Join': [': ', ['  QUEUE_URL', {'ref': 'myQueueUrl'}]]},
                            {'Fn::Join': [': ', ['  SSO_KEY', 'mySsoKey']]}]
                     ]
            }
        }

        key, value = CloudFormationTemplateTransformer.transform_taupage_user_data_key('@taupageUserData@', input)
        self.assertEqual("UserData", key)
        self.assertEqual(expected, value)
Exemplo n.º 2
0
    def test_transform_taupage_user_data_key(self):
        input = {
            "application_id": "stackName",
            "application_version": "imageVersion",
            "environment": {
                "SSO_KEY": "mySsoKey",
                "QUEUE_URL": {
                    "ref": "myQueueUrl"
                }
            }
        }
        expected = {
            'Fn::Base64': {
                'Fn::Join': [
                    '\n',
                    [
                        '#taupage-ami-config', {
                            'Fn::Join':
                            [': ', ['application_id', 'stackName']]
                        }, {
                            'Fn::Join':
                            [': ', ['application_version', 'imageVersion']]
                        }, 'environment:', {
                            'Fn::Join':
                            [': ', ['  QUEUE_URL', {
                                'ref': 'myQueueUrl'
                            }]]
                        }, {
                            'Fn::Join': [': ', ['  SSO_KEY', 'mySsoKey']]
                        }
                    ]
                ]
            }
        }

        key, value = CloudFormationTemplateTransformer.transform_taupage_user_data_key(
            '@taupageUserData@', input)
        self.assertEqual("UserData", key)
        self.assertEqual(expected, value)
    def test_transform_taupage_user_data_key(self):
        input = {
            "application_id": "stackName",
            "application_version": "imageVersion",
            "environment": {
                "SSO_KEY": "mySsoKey",
                "QUEUE_URL": {
                    "ref": "myQueueUrl"
                }
            }
        }
        expected = {
            "Fn::Base64": {
                "Fn::Join": [
                    "\n",
                    [
                        "#taupage-ami-config", {
                            "Fn::Join":
                            [": ", ["application_id", "stackName"]]
                        }, {
                            "Fn::Join":
                            [": ", ["application_version", "imageVersion"]]
                        }, "environment:", {
                            "Fn::Join": [": ", ["  SSO_KEY", "mySsoKey"]]
                        }, {
                            "Fn::Join":
                            [": ", ["  QUEUE_URL", {
                                "ref": "myQueueUrl"
                            }]]
                        }
                    ]
                ]
            }
        }

        key, value = CloudFormationTemplateTransformer.transform_taupage_user_data_key(
            '@taupageUserData@', input)
        self.assertEqual("UserData", key)
        six.assertCountEqual(self, expected, value)
    def test_transform_taupage_user_data_key(self):
        input = {
            "application_id": "stackName",
            "application_version": "imageVersion",
            "environment": {
                "SSO_KEY": "mySsoKey",
                "QUEUE_URL": {"ref": "myQueueUrl"}
            }
        }
        expected = {
            "Fn::Base64": {
                "Fn::Join": [
                    "\n",
                    [
                        "#taupage-ami-config",
                        {
                            "Fn::Join": [
                                ": ",
                                [
                                    "application_id",
                                    "stackName"
                                ]
                            ]
                        },
                        {
                            "Fn::Join": [
                                ": ",
                                [
                                    "application_version",
                                    "imageVersion"
                                ]
                            ]
                        },
                        "environment:",
                        {
                            "Fn::Join": [
                                ": ",
                                [
                                    "  SSO_KEY",
                                    "mySsoKey"
                                ]
                            ]
                        },
                        {
                            "Fn::Join": [
                                ": ",
                                [
                                    "  QUEUE_URL",
                                    {
                                        "ref": "myQueueUrl"
                                    }
                                ]
                            ]
                        }
                    ]
                ]
            }
        }

        key, value = CloudFormationTemplateTransformer.transform_taupage_user_data_key('@taupageUserData@', input)
        self.assertEqual("UserData", key)
        six.assertCountEqual(self, expected, value)
Exemplo n.º 5
0
    def test_transform_taupage_user_data_key(self):
        input = {
            "notify_cfn": {
                "resource": "asg",
                "stack": {
                    "Ref": "AWS::StackName"
                }
            },
            "cloudwatch_logs": {
                "/var/log/application.log": {
                    "Ref": "applicationLog"
                },
                "/var/log/syslog": {
                    "Ref": "syslog"
                }
            },
            "environment": {
                "DYNAMODB_INDEX_NAME": {
                    "Ref": "dynamodbIndexName"
                },
                "JAVA_OPTS": "-Xmx3g",
                "METRICS_NAMESPACE": {
                    "Ref": "AWS::StackName"
                },
                "ELASTICSEARCH_URL": {
                    "Ref": "elasticsearchUrl"
                },
                "IMPORT_QUEUE_URL": {
                    "Ref": "importQueue"
                }
            },
            "application_id": {
                "Ref": "AWS::StackName"
            },
            "health_check_port": 8080,
            "health_check_timeout_seconds": 9000,
            "ports": {
                "8080": 9000
            },
            "health_check_path": "/status",
            "root": True,
            "ecr": {
                "region": {
                    "Ref": "AWS::Region"
                }
            },
            "runtime": "Docker",
            "healthcheck": {
                "type": "elb",
                "loadbalancer_name": {
                    "Ref": "elb"
                }
            },
            "application_version": {
                "Ref": "dockerImageVersion"
            },
            "source": {
                "Fn::Join": [
                    ":",
                    [
                        "my-docker-repo/my-app-image", {
                            "Ref": "dockerImageVersion"
                        }
                    ]
                ]
            }
        }

        expected = {
            "Fn::Base64": {
                "Fn::Join": [
                    "\n",
                    [
                        "#taupage-ami-config", "application_id:", {
                            "Fn::Join":
                            ["", ["  ", {
                                "Ref": "AWS::StackName"
                            }]]
                        }, "application_version:", {
                            "Fn::Join":
                            ["", ["  ", {
                                "Ref": "dockerImageVersion"
                            }]]
                        }, "cloudwatch_logs:", "  /var/log/application.log:", {
                            "Fn::Join":
                            ["", ["    ", {
                                "Ref": "applicationLog"
                            }]]
                        }, "  /var/log/syslog:", {
                            "Fn::Join": ["", ["    ", {
                                "Ref": "syslog"
                            }]]
                        }, "ecr:", "  region:", {
                            "Fn::Join": ["", ["    ", {
                                "Ref": "AWS::Region"
                            }]]
                        }, "environment:", "  DYNAMODB_INDEX_NAME:", {
                            "Fn::Join":
                            ["", ["    ", {
                                "Ref": "dynamodbIndexName"
                            }]]
                        }, "  ELASTICSEARCH_URL:", {
                            "Fn::Join":
                            ["", ["    ", {
                                "Ref": "elasticsearchUrl"
                            }]]
                        }, "  IMPORT_QUEUE_URL:", {
                            "Fn::Join": ["", ["    ", {
                                "Ref": "importQueue"
                            }]]
                        }, "  JAVA_OPTS: '-Xmx3g'", "  METRICS_NAMESPACE:", {
                            "Fn::Join":
                            ["", ["    ", {
                                "Ref": "AWS::StackName"
                            }]]
                        }, "health_check_path: '/status'",
                        "health_check_port: 8080",
                        "health_check_timeout_seconds: 9000", "healthcheck:",
                        "  loadbalancer_name:", {
                            "Fn::Join": ["", ["    ", {
                                "Ref": "elb"
                            }]]
                        }, "  type: 'elb'", "notify_cfn:", "  resource: 'asg'",
                        "  stack:", {
                            "Fn::Join":
                            ["", ["    ", {
                                "Ref": "AWS::StackName"
                            }]]
                        }, "ports:", "  8080: 9000", "root: True",
                        "runtime: 'Docker'", "source:", {
                            "Fn::Join": [
                                "",
                                [
                                    "  ", {
                                        "Fn::Join": [
                                            ":",
                                            [
                                                "my-docker-repo/my-app-image",
                                                {
                                                    "Ref": "dockerImageVersion"
                                                }
                                            ]
                                        ]
                                    }
                                ]
                            ]
                        }
                    ]
                ]
            }
        }

        key, value = CloudFormationTemplateTransformer.transform_taupage_user_data_key(
            "@taupageUserData@", input)
        print(json.dumps(value, indent=4))
        self.assertEqual("UserData", key)
        self.assertEqual(expected, value)