Documentation ¶
Overview ¶
Package aws provides a simplified interface for various AWS services.
Index ¶
- Constants
- Variables
- func GetDefaultAWSConfig() *aws.Config
- func GetQueueURL(ctx context.Context, logger log.Log, queueName string, sqsClient *sqs.Client) (*string, error)
- func NewKMSClientWithConfig(awsConfig aws.Config) *kms.Client
- func NewS3ClientWithConfig(awsConfig aws.Config) *s3.Client
- func NewSNSClientWithConfig(awsConfig *aws.Config) *sns.Client
- func NewSQSClientWithConfig(awsConfig aws.Config) *sqs.Client
- func NewSecretManagerClientWithSession(awsConfig aws.Config) *secretsmanager.Client
- func SetDefaultAWSConfig(defaultConfig aws.Config, t Tracer)
- type BatchQueueMessage
- type KMS
- type PIITempFile
- type S3
- func (s *S3) GetFile(ctx context.Context, s3Bucket, s3Key, localFilePath string) error
- func (s *S3) GetObject(ctx context.Context, s3Bucket, s3Key string) (*s3.GetObjectOutput, error)
- func (s *S3) PresignGetObject(ctx context.Context, s3Bucket, s3Key string, expireTimeInSeconds int64) (*v4.PresignedHTTPRequest, error)
- func (s *S3) PresignPutObject(ctx context.Context, s3Bucket, s3Key string, expireTimeInSeconds int64) (*v4.PresignedHTTPRequest, error)
- func (s *S3) PutFile(ctx context.Context, s3Bucket, s3Key, localFilePath string) (*s3.PutObjectOutput, error)
- func (s *S3) PutObject(ctx context.Context, s3Bucket, s3Key string, body io.Reader, mimeType string, ...) (*s3.PutObjectOutput, error)
- type S3Crypto
- func (s *S3Crypto) GetFile(ctx context.Context, s3Bucket, s3Key, localFilePath string) error
- func (s *S3Crypto) GetFileCache(ctx context.Context, s3Bucket, s3Key, tempPathPart string) (*PIITempFile, error)
- func (s *S3Crypto) GetObject(ctx context.Context, s3Bucket, s3Key string) ([]byte, error)
- func (s *S3Crypto) PutFile(ctx context.Context, s3Bucket, s3Key, localFilePath string) error
- func (s *S3Crypto) PutObject(ctx context.Context, s3Bucket, s3Key string, body io.Reader, mimeType string) error
- type SNS
- type SQS
- func (s *SQS) DeleteMessage(ctx context.Context, receiptHandler *string) (*sqs.DeleteMessageOutput, error)
- func (s *SQS) DeleteMessageBatch(ctx context.Context, receiptHandlerMap map[string]*string) (*sqs.DeleteMessageBatchOutput, error)
- func (s *SQS) GenerateAttribute(ctx context.Context, attribute map[string]interface{}) map[string]types.MessageAttributeValue
- func (s *SQS) IsFIFO() bool
- func (s *SQS) ReceiveMessage(ctx context.Context, timeoutInSeconds int32, maxNumberOfMessages int32, ...) (*sqs.ReceiveMessageOutput, error)
- func (s *SQS) SendMessage(ctx context.Context, message *utils.Message, attribute map[string]interface{}, ...) (*sqs.SendMessageOutput, error)
- func (s *SQS) SendMessageBatch(ctx context.Context, messageList []*BatchQueueMessage, delayInSeconds int32) (*sqs.SendMessageBatchOutput, error)
- func (s *SQS) SendMessageFIFO(ctx context.Context, message *utils.Message, attribute map[string]interface{}, ...) (*sqs.SendMessageOutput, error)
- type SecretManager
- type Tracer
Constants ¶
const ( // MetadataKMSARN represents the key for KMS ARN metadata. MetadataKMSARN = "x-kms-arn" // MetadataEncryptionAlgorithm represents the key for encryption algorithm metadata. MetadataEncryptionAlgorithm = "x-encryption-algorithm" // MetadataContentKey represents the key for content key metadata. MetadataContentKey = "x-content-key" // EncryptionAlgorithmAESGCM represents the AES GCM encryption algorithm. EncryptionAlgorithmAESGCM = "AES-GCM-256" )
Variables ¶
var DefaultMaxMessages int64 = 10
DefaultMaxMessages is the default maximum number of messages.
var ErrTooManyMessageToDelete = fmt.Errorf("too many messages in receiptHandlerMap (should be less than 10)")
ErrTooManyMessageToDelete is an error indicating too many messages to delete.
Functions ¶
func GetDefaultAWSConfig ¶
GetDefaultAWSConfig retrieves the default AWS configuration.
func GetQueueURL ¶
func GetQueueURL(ctx context.Context, logger log.Log, queueName string, sqsClient *sqs.Client) (*string, error)
GetQueueURL returns the URL of the queue with the given name.
func NewKMSClientWithConfig ¶
NewKMSClientWithConfig creates a new KMS client with the provided AWS configuration.
func NewS3ClientWithConfig ¶
NewS3ClientWithConfig creates a new S3 client with the provided AWS configuration.
func NewSNSClientWithConfig ¶
NewSNSClientWithConfig creates a new SNS client with the provided AWS configuration.
func NewSQSClientWithConfig ¶
NewSQSClientWithConfig creates a new SQS client with the provided AWS configuration.
func NewSecretManagerClientWithSession ¶
func NewSecretManagerClientWithSession(awsConfig aws.Config) *secretsmanager.Client
NewSecretManagerClientWithSession creates a new Secrets Manager client with the provided AWS configuration.
func SetDefaultAWSConfig ¶
SetDefaultAWSConfig sets the default AWS configuration and applies tracing if provided.
Types ¶
type BatchQueueMessage ¶
type BatchQueueMessage struct { ID *string Message *utils.Message Attribute map[string]interface{} MessageDeduplicationID *string MessageGroupID *string }
BatchQueueMessage represents a message to be sent in a batch to SQS.
type KMS ¶
KMS provides an interface to interact with AWS Key Management Service (KMS).
func GetDefaultKMSClient ¶
GetDefaultKMSClient retrieves the default KMS client using the provided logger and key ARN.
func NewKMSClient ¶
NewKMSClient creates a new KMS client with the provided logger, client, and key ARN.
type PIITempFile ¶
type PIITempFile struct { Request *v4.PresignedHTTPRequest `json:"req"` ExpiresAt time.Time `json:"expiresAt"` ContentType *string `json:"contentType"` }
PIITempFile contains information about a temporary presigned URL for a file.
type S3 ¶
type S3 struct { *s3.Client *s3.PresignClient // contains filtered or unexported fields }
S3 provides an interface for interacting with AWS Simple Storage Service (S3).
func GetDefaultS3Client ¶
GetDefaultS3Client retrieves the default S3 client using the provided logger.
func NewS3Client ¶
NewS3Client creates a new S3 client with the provided client and logger.
func (*S3) PresignGetObject ¶
func (s *S3) PresignGetObject(ctx context.Context, s3Bucket, s3Key string, expireTimeInSeconds int64) (*v4.PresignedHTTPRequest, error)
PresignGetObject creates a presigned URL for downloading an object from S3.
func (*S3) PresignPutObject ¶
func (s *S3) PresignPutObject(ctx context.Context, s3Bucket, s3Key string, expireTimeInSeconds int64) (*v4.PresignedHTTPRequest, error)
PresignPutObject creates a presigned URL for uploading an object to S3.
type S3Crypto ¶
type S3Crypto struct { *S3 // contains filtered or unexported fields }
S3Crypto extends S3 with client-side object encryption.
func GetDefaultS3CryptoClient ¶
GetDefaultS3CryptoClient retrieves the default S3 Crypto client using the provided logger and KMS key ARN.
func NewS3CryptoClient ¶
NewS3CryptoClient creates a new S3 Crypto client with the provided S3 client, KMS client, and logger.
func (*S3Crypto) GetFile ¶
GetFile retrieves an encrypted file from S3, decrypts its content, and writes it to a local file specified by the localFilePath argument. It takes a context, S3 bucket name, S3 object key, and local file path as input. If an error occurs during retrieval, decryption, or file writing, it returns an error.
func (*S3Crypto) GetFileCache ¶
func (s *S3Crypto) GetFileCache(ctx context.Context, s3Bucket, s3Key, tempPathPart string) (*PIITempFile, error)
GetFileCache retrieves an encrypted file from S3, creates a temporary presigned URL for it, and caches the URL for future use. It returns a PIITempFile object containing the presigned URL information and other metadata. It takes a context, S3 bucket name, S3 object key, and a string for generating a unique part of the temporary path as input. If an error occurs during retrieval or URL generation, it returns an error.
func (*S3Crypto) GetObject ¶
GetObject retrieves an encrypted object from S3 and decrypts its content. It takes a context, S3 bucket name, and S3 object key as input and returns the decrypted content of the object as a byte slice. If an error occurs during retrieval or decryption, it returns an error.
type SNS ¶
SNS provides methods to interact with AWS Simple Notification Service (SNS).
func GetDefaultSNSClient ¶
GetDefaultSNSClient returns the default SNS client using the provided logger.
func NewSNSClient ¶
NewSNSClient creates a new SNS instance with the provided logger and SNS client.
func (*SNS) GenerateAttribute ¶
func (s *SNS) GenerateAttribute(ctx context.Context, attribute map[string]interface{}) map[string]types.MessageAttributeValue
GenerateAttribute generates SNS message attributes based on the provided map. It extracts correlation parameters from the context and includes them in the message attributes.
func (*SNS) Publish ¶
func (s *SNS) Publish(ctx context.Context, topicArn, subject *string, payload *utils.Message, attributes map[string]interface{}) (*sns.PublishOutput, error)
Publish publishes a message to the specified SNS topic. It returns the publish output and an error if the operation fails.
type SQS ¶
SQS provides methods to interact with AWS Simple Queue Service (SQS).
func GetDefaultSQSClient ¶
GetDefaultSQSClient returns the default SQS client using the provided logger and queue URL.
func NewSQSClient ¶
NewSQSClient creates a new SQS instance with the provided logger, SQS client, and queue URL.
func (*SQS) DeleteMessage ¶
func (s *SQS) DeleteMessage(ctx context.Context, receiptHandler *string) (*sqs.DeleteMessageOutput, error)
DeleteMessage deletes a message from the SQS queue.
func (*SQS) DeleteMessageBatch ¶
func (s *SQS) DeleteMessageBatch(ctx context.Context, receiptHandlerMap map[string]*string) (*sqs.DeleteMessageBatchOutput, error)
DeleteMessageBatch deletes multiple messages from the SQS queue.
func (*SQS) GenerateAttribute ¶
func (s *SQS) GenerateAttribute(ctx context.Context, attribute map[string]interface{}) map[string]types.MessageAttributeValue
GenerateAttribute generates message attributes from the given attribute map.
func (*SQS) ReceiveMessage ¶
func (s *SQS) ReceiveMessage(ctx context.Context, timeoutInSeconds int32, maxNumberOfMessages int32, waitTimeInSeconds int32) (*sqs.ReceiveMessageOutput, error)
ReceiveMessage receives messages from the SQS queue.
func (*SQS) SendMessage ¶
func (s *SQS) SendMessage(ctx context.Context, message *utils.Message, attribute map[string]interface{}, delayInSeconds int32) (*sqs.SendMessageOutput, error)
SendMessage sends a message to the SQS queue with optional attributes and delay.
func (*SQS) SendMessageBatch ¶
func (s *SQS) SendMessageBatch(ctx context.Context, messageList []*BatchQueueMessage, delayInSeconds int32) (*sqs.SendMessageBatchOutput, error)
SendMessageBatch sends multiple messages in a batch to the SQS queue.
func (*SQS) SendMessageFIFO ¶
func (s *SQS) SendMessageFIFO(ctx context.Context, message *utils.Message, attribute map[string]interface{}, delayInSeconds int32, messageDeduplicationID, messageGroupID *string) (*sqs.SendMessageOutput, error)
SendMessageFIFO sends a message to the FIFO SQS queue with optional attributes, delay, and deduplication/group ID.
type SecretManager ¶
type SecretManager struct { *secretsmanager.Client // contains filtered or unexported fields }
SecretManager provides methods to interact with AWS Secrets Manager service.
func GetDefaultSecretManagerClient ¶
func GetDefaultSecretManagerClient(logger log.Log) *SecretManager
GetDefaultSecretManagerClient returns the default Secrets Manager client using the provided logger.
func NewSecretManagerClient ¶
func NewSecretManagerClient(logger log.Log, client *secretsmanager.Client) *SecretManager
NewSecretManagerClient creates a new SecretManager instance with the provided logger and Secrets Manager client.
func (*SecretManager) GetSecretMap ¶
func (s *SecretManager) GetSecretMap(ctx context.Context, secretArn string) (map[string]interface{}, error)
GetSecretMap retrieves the secret value associated with the provided secret ARN as a map[string]interface{}. It unmarshals the secret value JSON string into a map. It returns the secret data as a map or an error if the retrieval or unmarshalling fails.
func (*SecretManager) GetSecretString ¶
GetSecretString retrieves the secret value associated with the provided secret ARN. If the secret is cached and the cache is not expired, it returns the cached secret. Otherwise, it fetches the secret from AWS Secrets Manager and caches it. It returns the secret value as a string or an error if the retrieval fails.