Skip to main content

Package cloud/aws

The cloud/aws package

Configuration

The AWS SDK v2 based services use the following default settings for region and endpoint, meaning you get those values for every requested client if you don't specify anything else for the client.

cloud:
aws:
defaults:
region: "eu-central-1"
endpoint: "http://localhost:4566" #localstack

General service config

AWS service clients are created and configured by name. The pattern here is:

func ProvideClient(ctx context.Context, config cfg.Config, logger log.Logger, name string, optFns ...func(options *awsCfg.LoadOptions) error) (*serviceX.Client, error)

The resulting client can be configured by:

cloud:
aws:
serviceX:
clients:
default: # name of the client
assume_role: ""
backoff:
cancel_delay: 0s
initial_interval: 50ms
max_attempts: 10
max_elapsed_time: 10m0s
max_interval: 10s
credentials:
access_key_id: justtrack
secret_access_key: justtrack
session_token: ""
endpoint: http://localhost:4566
http_client:
timeout: 0s
profile: ""
region: eu-central-1

SettingDescriptionDefault
assume_roleIf defined, this role will be used to gain access""
backoff.cancel_delayIf the request get canceled, how long should the cancel delayed1s
backoff.initial_intervalThe initial duration to wait before retrying the request on error50ms
backoff.max_attemptsHow many attempts should be done10 (0 means retry forever)
backoff.max_intervalMax duration between 2 calls when retrying10s
backoff.max_elapsed_timeFor how long the service should retry the request10m (0m means retry forever)
endpointWhich service endpoint should be calledhttp://localhost:4566
http_client.timeoutAfter what duration the request should be canceled, if the server doesn't respond0s (no timeout)
profileIf defined, this aws profile will be used to fetch credentials""
regionThe region in useeu-central-1

Cloudwatch

Call

import(
gosoCloudwatch "github.com/justtrackio/gosoline/pkg/cloud/aws/cloudwatch"
)

cloudwatchClient := gosoCloudwatch.ProvideClient(ctx, config, logger , "default")

to get the default cloudwatch client. You don't have to provide any config if you want to go with the default settings. The default settings are:

cloud:
aws:
cloudwatch:
clients:
default:
assume_role: ""
backoff:
cancel_delay: 0s
initial_interval: 50ms
max_attempts: 10
max_elapsed_time: 10m0s
max_interval: 10s
credentials:
access_key_id: justtrack
secret_access_key: justtrack
session_token: ""
endpoint: http://localhost:4566
http_client:
timeout: 0s
profile: ""
region: eu-central-1

These are the default values which are used if you don't provide any config by yourself.

Full reference

cloud:
aws:
defaults:
assume_role: "arn:aws:iam::123456789012:role/gosoline-test-role"
credentials:
access_key_id: "justtrack"
secret_access_key: "justtrack"
session_token: "justtrack"
profile: "sdlc-dev-account"
endpoint: "http://localhost:4566"
region: "eu-central-1"
cloudwatch:
clients:
default:
assume_role: "arn:aws:iam::123456789012:role/gosoline-test-role"
credentials:
access_key_id: "justtrack"
secret_access_key: "justtrack"
session_token: "justtrack"
profile: "sdlc-dev-account"
endpoint: "http://localhost:4566"
region: "eu-central-1"
http_client:
timeout: 0s
backoff:
cancel_delay: 1s
initial_interval: 50ms
max_attempts: 10
max_elapsed_time: 15m0s
max_interval: 10s
dynamodb:
clients:
default:
naming:
pattern: "{env}-{group}-{modelId}"

kinesis:
clients:
default:
credentials:
access_key_id: "*******************"
secret_access_key: "****************************************"
session_token: "********************************************************************"
s3:
clients:
default:
usePathStyle: false
credentials:
endpoint: "https://s3.eu-central-1.amazonaws.com"
sqs:
clients:
default:
naming:
pattern: "{env}-{group}-{queueId}"