예제 #1
0
    def _configure_tf(self, component: str, cfgs: dict):
        ''' updates the terraform auto configuration and main.tf '''
        auto_tf = self.constants['auto_tf']
        auto_cfgs = get_json(auto_tf)
        for k, v in cfgs.items():
            if k in self.tf_vars:
                auto_cfgs[k] = v
        put_json(auto_tf, auto_cfgs)

        # render main.tf with terraform variables alone
        tf_cfgs = {}
        for component in self.configs:
            tf_cfgs[component] = {}
            for k, v in self.configs[component].items():
                if k in self.tf_vars:
                    tf_cfgs[component][k] = v

        render_j2_template(
            self.constants['tf_dir'],
            self.constants['main_tf'],
            tf_cfgs,
        )
        render_j2_template(
            self.constants['tf_dir'],
            self.constants['vars_tf'],
            self.tf_vars,
        )
예제 #2
0
 def commit(self, component):
     set_aws_configs(self.aws_vars, self.configs[component])
     self._configure_tf(component, self.configs[component])
     put_json(self._get_config_fn(component), self.configs[component])