Exemplo n.º 1
0
def main():
    """Build template and output to file."""
    args = parse_args()
    print(args)
    model = ApiModel(args)
    output = model.render_terraform()
    with open(args.output, "w") as f:
        f.write(output)
    print(output)
    if args.deploy:
        model.run_terraform()
Exemplo n.º 2
0
def generate(args, model=None):
    model = model if model is not None else ApiModel(args)
    output = model.render_terraform()
    with open(args.output, "w") as f:
        f.write(output)
    if not args.quiet:
        print(output)
Exemplo n.º 3
0
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.model = ApiModel(DteArgs('tests/api.json'))

    def test_load_name(self):
        self.assertEqual(self.model.json['Name'], 'DownToEarthApi')

    def test_load_api(self):
        self.assertEqual(self.model.json['Name'], 'DownToEarthApi')

    def test_auth_type(self):
        self.assertEqual(self.model.json['AuthType'], 'AWS_IAM')

    def test_can_output(self):
        output=self.model.render_terraform()
        test_dir = os.path.dirname(__file__)
        path = os.path.join(test_dir, 'test_api/', "main.tf")
        with open(path, "w") as f:
            f.write(output)
        print(output)
Exemplo n.º 4
0
def terraform_run(args):
    model = ApiModel(args)
    generate(args, model)
    model.run_terraform(args.var)
Exemplo n.º 5
0
def terraform_var(args):
    model = ApiModel(args)
    model.get_lambda_versions_file(args.output)
Exemplo n.º 6
0
def deploy(args):
    model = ApiModel(args)
    model.run_stage_deployment(args.stage)
Exemplo n.º 7
0
 def setUp(self):
     self.model = ApiModel(DteArgs('tests/api.json'))