def get_provisioners(self): pacbot_build_script = os.path.join(get_terraform_scripts_dir(), 'build_pacbot.py') upload_dir = self._create_dir_to_store_build_ap() local_execs = [{ 'local-exec': { 'command': pacbot_build_script, 'environment': { 'PROVIDER_FILE': get_terraform_provider_file(), 'APPLICATION_DOMAIN': ApplicationLoadBalancer.get_pacbot_domain_url(), 'PACBOT_CODE_DIR': Settings.PACBOT_CODE_DIR, 'DIST_FILES_UPLOAD_DIR': upload_dir, 'LOG_DIR': Settings.LOG_DIR, 'S3_BUCKET': BucketStorage.get_output_attr('bucket'), 'S3_KEY_PREFIX': Settings.RESOURCE_NAME_PREFIX }, 'interpreter': [Settings.PYTHON_INTERPRETER] } }] return local_execs
def _create_terraform_provider_file(self): terraform_provider_file = get_terraform_provider_file() provider_script = { 'provider': { 'aws': { 'access_key': self.input.aws_access_key, 'secret_key': self.input.aws_secret_key, 'region': self.input.aws_region } } } with open(terraform_provider_file, "w") as jsonfile: json.dump(provider_script, jsonfile, indent=4)
def _create_terraform_provider_file(self): """Terraform provider file is created as part of installation/destruction execution""" terraform_provider_file = get_terraform_provider_file() provider_script = { 'provider': { 'aws': { 'access_key': self.input.aws_access_key, 'secret_key': self.input.aws_secret_key, 'region': self.input.aws_region } } } with open(terraform_provider_file, "w") as jsonfile: json.dump(provider_script, jsonfile, indent=4)
def get_app_provisioners(self): docker_creation_script = os.path.join(get_terraform_scripts_dir(), self.image_creation_script) local_execs = [{ 'local-exec': { 'command': docker_creation_script, 'environment': { 'ECR_REPOSITORY': self.ecr_repo, 'PROVIDER_FILE': get_terraform_provider_file(), 'DOCKER_FILE': 'dockerfile', 'DOCKER_FILE_DIR': os.path.join(self.dest_dir, self.docker_dir), 'LOG_FILE': os.path.join(Settings.LOG_DIR, 'debug.log') }, 'interpreter': [Settings.PYTHON_INTERPRETER] } }] return local_execs
def _create_terraform_provider_file(self): """Terraform provider file is created as part of installation/destruction execution""" terraform_provider_file = get_terraform_provider_file() aws_provider = {'region': self.input.AWS_AUTH_CRED['aws_region']} if self.input.AWS_AUTH_CRED['aws_auth_option'] == 1: aws_provider['access_key'] = self.input.AWS_AUTH_CRED[ 'aws_access_key'] aws_provider['secret_key'] = self.input.AWS_AUTH_CRED[ 'aws_secret_key'] elif self.input.AWS_AUTH_CRED['aws_auth_option'] == 2: aws_provider['assume_role'] = { 'role_arn': self.input.AWS_AUTH_CRED['assume_role_arn'], 'session_name': str(uuid.uuid4()) } provider_script = {'provider': {'aws': aws_provider}} with open(terraform_provider_file, "w") as jsonfile: json.dump(provider_script, jsonfile, indent=4)
def get_provisioners(self): docker_creation_script = os.path.join(get_terraform_scripts_dir(), self.image_creation_script) local_execs = [{ 'local-exec': { 'command': docker_creation_script, 'environment': { 'ECR_REPOSITORY': RuleEngineEcrRepository.get_output_attr('repository_url'), 'PROVIDER_FILE': get_terraform_provider_file(), 'DOCKER_FILE': 'dockerfile', 'DOCKER_FILE_DIR': os.path.join(self.dest_dir, 'batch_docker'), 'LOG_FILE': os.path.join(Settings.LOG_DIR, 'debug.log') }, 'interpreter': [Settings.PYTHON_INTERPRETER] } }] return local_execs
def _delete_terraform_provider_file(self): """Terraform provider file which is created as part of installation/destruction is removed after the execution""" terraform_provider_file = get_terraform_provider_file() if os.path.isfile(terraform_provider_file): os.remove(terraform_provider_file)
def _delete_terraform_provider_file(self): terraform_provider_file = get_terraform_provider_file() if os.path.isfile(terraform_provider_file): os.remove(terraform_provider_file)