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
Setting | Description | Default |
---|---|---|
assume_role | If defined, this role will be used to gain access | "" |
backoff.cancel_delay | If the request get canceled, how long should the cancel delayed | 1s |
backoff.initial_interval | The initial duration to wait before retrying the request on error | 50ms |
backoff.max_attempts | How many attempts should be done | 10 (0 means retry forever) |
backoff.max_interval | Max duration between 2 calls when retrying | 10s |
backoff.max_elapsed_time | For how long the service should retry the request | 10m (0m means retry forever) |
endpoint | Which service endpoint should be called | http://localhost:4566 |
http_client.timeout | After what duration the request should be canceled, if the server doesn't respond | 0s (no timeout) |
profile | If defined, this aws profile will be used to fetch credentials | "" |
region | The region in use | eu-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}"