diff --git a/aws/s3/s3.go b/aws/s3/s3.go index 1cd6baf..c418c31 100644 --- a/aws/s3/s3.go +++ b/aws/s3/s3.go @@ -271,6 +271,16 @@ func (s *S3) PutWithMetadata(bucket, key string, object []byte, metadata Meta) e return err } +// checks if the given S3 bucket exists. +func (s *S3) CheckBucketExists(bucketName string) error { + // Check if the bucket exists. + _, err := s.client.HeadBucket(context.TODO(), &s3.HeadBucketInput{ + Bucket: aws.String(bucketName), + }) + + return err +} + // Exists checks if an object for key already exists in the bucket. func (s *S3) Exists(bucket, key string) (bool, error) { diff --git a/aws/sqs/sqs.go b/aws/sqs/sqs.go index bd7f21c..d02fac0 100644 --- a/aws/sqs/sqs.go +++ b/aws/sqs/sqs.go @@ -320,6 +320,16 @@ func (s *SQS) CreateQueue(queueName string, isFifoQueue bool) (string, error) { return aws.ToString(queue.QueueUrl), err } +// checks if the given SQS queue exists. +func (s *SQS) CheckQueueExists(queueName string) error { + // Check if the queue exists. + _, err := s.client.GetQueueUrl(context.TODO(), &sqs.GetQueueUrlInput{ + QueueName: aws.String(queueName), + }) + + return err +} + // DeleteQueue deletes an Amazon SQS queue. func (s *SQS) DeleteQueue(queueUrl string) error { _, err := s.client.DeleteQueue(context.TODO(), &sqs.DeleteQueueInput{