def grafana(self, func, grafana_password): ami_account = self.plateform['account'] if 'ami-account' in self.plateform[self.blocname]: ami_account = self.plateform[self.blocname]['ami-account'] grafana = ComponentWeb(self.plateform) web={ 'name': 'grafana', 'ami-name': 'grafana-*', 'ami-account': ami_account, 'port': '3000', 'health-check': '/api/health', 'health-check-port': '3000', 'attach_cw_ro': True, 'efs-enable': False, 'node-count': 1, 'min-node-count': 1, 'max-node-count': 1, 'ips_whitelist': self.plateform[self.blocname]['ips_whitelist'], 'enable_cognito': True, 'user-data': ''' #!/bin/bash -x exec > /tmp/userdata-grafana.log 2>&1 grafana-cli admin reset-admin-password {password} '''.format(password=grafana_password) } grafana.compute_var(web, func)
def alertmanager(self, func, sns_arn): ami_account = self.plateform['account'] if 'ami-account' in self.plateform[self.blocname]: ami_account = self.plateform[self.blocname]['ami-account'] alertmanager = ComponentWeb(self.plateform) web={ 'name': 'alertmanager', 'ami-name': 'alertmanager-*', 'ami-account': ami_account, 'port': '9093', 'health-check': '/-/ready', 'attach_sns_pub': True, 'efs-enable': False, 'node-count': 1, 'min-node-count': 1, 'max-node-count': 1, 'ips_whitelist': self.plateform[self.blocname]['ips_whitelist'], 'enable_cognito': False, 'enable_private_alb': True, 'enable_public_alb': True, 'user-data': ''' #!/bin/bash -x exec > /tmp/userdata-alertmanager.log 2>&1 sudo sed -i.bak 's/alertmanager-sns-to-email/{sns_arn}/g' /etc/alertmanager/alertmanager.yml sudo systemctl restart alertmanager.service '''.format(sns_arn=sns_arn.replace('\n', '')) } alertmanager.compute_var(web, func)
def compute_var_web(self, web, func): web_component = ComponentWeb(self.plateform) rds_component = ComponentRDS(self.plateform) self.var = { 'bucket_component_state': self.plateform['bucket-component-state'], 'workspace-web': web_component.get_workspace(web['name']), 'workspace-rds': rds_component.get_workspace(web['link-rds']) } func(working_dir='../terraform/component_link/link_web', workspace_name=self.get_workspace_web(web['name'], web['link-rds']), var_component=self.var)
def tracing(self, func): ami_account = self.plateform['account'] if 'ami-account' in self.plateform[self.blocname]: ami_account = self.plateform[self.blocname]['ami-account'] tracing = ComponentWeb(self.plateform) web={ 'name': 'tracing', 'ami-name': 'jaeger-*', 'ami-account': ami_account, 'port': '16686', 'health-check': '/', 'health-check-port': '16687', 'attach_cw_ro': False, 'efs-enable': False, 'node-count': 1, 'min-node-count': 1, 'max-node-count': 1, 'ips_whitelist': self.plateform[self.blocname]['ips_whitelist'], 'enable_cognito': True } tracing.compute_var(web, func)
def prometheus(self, func): ami_account = self.plateform['account'] if 'ami-account' in self.plateform[self.blocname]: ami_account = self.plateform[self.blocname]['ami-account'] prometheus = ComponentWeb(self.plateform) web={ 'name': 'prometheus', 'ami-name': 'prometheus-*', 'ami-account': ami_account, 'port': '9090', 'health-check': '/-/ready', 'attach_cw_ro': False, 'attach_ec2_ro': True, 'efs-enable': False, 'node-count': 1, 'min-node-count': 1, 'max-node-count': 1, 'ips_whitelist': self.plateform[self.blocname]['ips_whitelist'], 'enable_cognito': False, 'enable_private_alb': True, 'enable_public_alb': True } prometheus.compute_var(web, func)
print("create from file: " + name_file) else: sys.exit() with open(name_file, 'r') as stream: try: plateform = yaml.load(stream, Loader=Loader) start_time = time.time() print("Load components...") base = ComponentBase(plateform) bastion = ComponentBastion(plateform) eks = ComponentEKS(plateform) network = ComponentNetwork(plateform) web = ComponentWeb(plateform) link = ComponentLink(plateform) obs = ComponentObservability(plateform) rds = ComponentRDS(plateform) load_finish_time = time.time() # check if credential is always available print("check is always connected...") is_always_connected() print("Will create plateform: " + plateform['name'] + " in account:" + plateform['account']) base.apply() base_finish_time = time.time()
name_file = input("Nom du fichier: ") try: from yaml import CLoader as Loader, CDumper as Dumper except ImportError: from yaml import Loader, Dumper with open(name_file, 'r') as stream: try: plateform = yaml.load(stream, Loader=Loader) base = ComponentBase(plateform) bastion = ComponentBastion(plateform) eks = ComponentEKS(plateform) network = ComponentNetwork(plateform) web = ComponentWeb(plateform) link = ComponentLink(plateform) obs = ComponentObservability(plateform) rds = ComponentRDS(plateform) # check if credential is always available print("check is always connected...") is_always_connected() print("Will delete plateform: " + plateform['name'] + " in account:" + plateform['account']) print("link destroy") link.destroy() print("obs destroy") obs.destroy()
print("create from file: " + name_file) else: sys.exit() with open(name_file, 'r') as stream: try: plateform = yaml.load(stream, Loader=Loader) start_time = time.time() print("Load components...") base = ComponentBase(plateform) bastion = ComponentBastion(plateform) eks = ComponentEKS(plateform) network = ComponentNetwork(plateform) web = ComponentWeb(plateform) link = ComponentLink(plateform) obs = ComponentObservability(plateform) rds = ComponentRDS(plateform) load_finish_time = time.time() # check if credential is always available print("check is always connected...") is_always_connected() print("Will create plateform: " + plateform['name'] + " in account:" + plateform['account']) base.plan() base_finish_time = time.time()