def delete_artifact(self, name, version):
     target_name = self.create_target_file_name(name, version)
     contents = self.s3_client.list_objects(
         Bucket=self.eb_app_env.s3_bucket_name)["Contents"]
     if arr.find_by_attr(contents, 'Key', target_name):
         self.s3_client.delete_object(Bucket=self.eb_app_env.s3_bucket_name,
                                      Key=target_name)
         return True
     return False
 def env_exists(self):
     envs = self.eb_client.describe_environments(
         ApplicationName=self.eb_app_env.application_name)['Environments']
     envs = [
         e for e in envs
         if e["Status"] != "Terminated" and e["Status"] != "Terminating"
     ]
     return arr.find_by_attr(envs, 'EnvironmentName',
                             self.eb_app_env.environment_name) is not None
 def upload_artifact(self, name, version, source_file_path):
     target_name = self.create_target_file_name(name, version)
     self.create_bucket_if_needed()
     response = self.s3_client.list_objects(
         Bucket=self.eb_app_env.s3_bucket_name)
     if "Contents" in response.keys():
         contents = response["Contents"]
     else:
         contents = []
     if not arr.find_by_attr(contents, 'Key', target_name):
         with open(source_file_path, 'rb') as data:
             self.s3_client.put_object(
                 Bucket=self.eb_app_env.s3_bucket_name,
                 Key=target_name,
                 Body=data)
         return True
     return False
 def application_exists(self):
     applications = self.eb_client.describe_applications()['Applications']
     return arr.find_by_attr(applications, 'ApplicationName',
                             self.eb_app_env.application_name) is not None
 def application_version_exists(self, version):
     application_versions = self.eb_client.describe_application_versions(
         ApplicationName=self.eb_app_env.application_name
     )['ApplicationVersions']
     return arr.find_by_attr(application_versions, 'VersionLabel',
                             version) is not None
 def bucket_exists(self):
     buckets = self.s3_client.list_buckets()["Buckets"]
     return arr.find_by_attr(buckets, 'Name',
                             self.eb_app_env.s3_bucket_name) is not None
 def validate_solution_stack_name(self):
     stacks = self.eb_client.list_available_solution_stacks(
     )['SolutionStacks']
     arr.must_find(stacks, self.eb_app_env.solution_stack_name)