Skip to content

Commit 644461f

Browse files
committed
docs: Update README file
1 parent de0e023 commit 644461f

File tree

1 file changed

+93
-11
lines changed

1 file changed

+93
-11
lines changed

README.md

Lines changed: 93 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ SDK, the Go version.
3232
- [Kafka specific configuration](#kafka-specific-configuration)
3333
- [Cache](#cache)
3434
- [Redis](#redis-specific-configuration)
35+
- [AWS configuration](#aws-configuration)
36+
- [AWS Common configuration](#aws-common-configuration)
37+
- [AWS Service configuration](#aws-service-configuration)
3538
- [APM & Instrumentation](#apm---instrumentation)
3639
- [Request ID middleware](#request-id-middleware)
3740
- [HTTP server Request ID middleware](#http-server-request-id-middleware)
@@ -97,11 +100,12 @@ The list of predefined top-level configurations:
97100
`config/logger.yml` configuration file.
98101
* `Database`, containing the application database configuration, expects a
99102
`config/database.yml` configuration file.
100-
* `Redis`, containing the application Redis configuration, expects a
101-
`config/redis.yml` configuration file. (TBD)
103+
* `Cache`, containing the application Cache configuration, expects a
104+
`config/cache.yml` configuration file.
102105
* `PubSub`, containing the application pubsub configuration, expects a
103106
`config/pubsub.yml` configuration file.
104-
* <insert new configuration here>
107+
* `AWS`, containing the application AWS configuration, expects a
108+
`config/aws.yml` configuration file.
105109

106110
For example, to get the host and the port at which the HTTP server listens on
107111
in an application:
@@ -983,6 +987,80 @@ To secure the requests to Redis, Go SDK provides a configuration set for TLS:
983987
| Passphrase | Passphrase is used in case the private key needs to be decrypted | `passphrase` | `APP_CACHE_REDIS_TLS_PASSPHRASE` | string | pass phrase |
984988
| Skip TLS verification | Turn on / off TLS verification | `insecure_skip_verify` | `APP_CACHE_REDIS_TLS_INSECURE_SKIP_VERIFY` | bool | true, false |
985989

990+
991+
### AWS configuration
992+
993+
`go-sdk` provides a convenient way to create an AWS configuration.
994+
995+
Configuration contains the common configuration for AWS configuration and specific configuration for services.
996+
997+
Service configuration is split by the service name to facilitate the configuration of multiple services per service type.
998+
999+
```yaml
1000+
common: &common
1001+
config:
1002+
region: "us-east-2"
1003+
s3:
1004+
default:
1005+
# APP_AWS_S3_DEFAULT_REGION
1006+
region: "us-east-1"
1007+
credentials:
1008+
assume_role:
1009+
# APP_AWS_S3_DEFAULT_CREDENTIALS_ASSUME_ROLE_ARN
1010+
arn: ""
1011+
example:
1012+
# APP_AWS_S3_EXAMPLE_REGION
1013+
region: "us-west-2"
1014+
credentials:
1015+
static:
1016+
# APP_AWS_S3_EXAMPLE_CREDENTIALS_STATIC_ACCESS_KEY_ID
1017+
access_key_id: ""
1018+
# APP_AWS_S3_EXAMPLE_CREDENTIALS_STATIC_SECRET_ACCESS_KEY
1019+
secret_access_key: ""
1020+
# APP_AWS_S3_EXAMPLE_CREDENTIALS_STATIC_SESSION_TOKEN
1021+
session_token: ""
1022+
```
1023+
1024+
#### AWS common configuration
1025+
1026+
Common configuration contains the following options:
1027+
1028+
| Setting | Description | YAML variable | Environment variable (ENV) | Type | Possible Values |
1029+
|----------------------------|--------------------------------------------------------|------------------|--------------------------------------|--------|-----------------|
1030+
| Region | AWS region to use | `region` | `APP_AWS_REGION` | string | us-west-2 |
1031+
| HTTP client max idle conns | Maximum number of idle connections in the HTTP client. | `max_idle_conns` | `APP_AWS_HTTP_CLIENT_MAX_IDLE_CONNS` | int | 100 |
1032+
1033+
#### AWS Service configuration
1034+
1035+
Currently, `go-sdk` supports the following AWS service types: `s3`, `sagemakerruntime`, `sfn` and `sqs`.
1036+
1037+
To facilitate the configuration of multiple services per service type, the configuration is split by the service name.
1038+
To override the settings specified in the YAML via the environment variables, the following naming convention is used:
1039+
1040+
```
1041+
APP_AWS_<SERVICE_TYPE>_<SERVICE_NAME>_*
1042+
```
1043+
1044+
Where `SERVICE_TYPE` is the service type (s3, sqs etc.) and `SERVICE_NAME` is the service name (default, example etc.).
1045+
1046+
It is possible to specify region and HTTP client settings for each service, which will override the common configuration.
1047+
1048+
For each service, it is possible to specify credentials. Currently, `go-sdk` supports two types of credentials: `assume_role` and `static`.
1049+
1050+
`assume_role` credentials are used to assume a role to get credentials using AWS STS service. The following options are available:
1051+
1052+
| Setting | Description | YAML variable | Environment variable (ENV) | Type | Possible Values |
1053+
|---------|------------------------------------------------------|---------------|--------------------------------------------------|--------|------------------------------------------|
1054+
| ARN | The Amazon Resource Name (ARN) of the role to assume | `arn` | `APP_AWS_S3_DEFAULT_CREDENTIALS_ASSUME_ROLE_ARN` | string | arn:aws:iam::123456789012:role/role-name |
1055+
1056+
`static` credentials are used to specify the access key ID, secret access key and session token. The following options are available:
1057+
1058+
| Setting | Description | YAML variable | Environment variable (ENV) | Type | Possible Values |
1059+
|-------------------|-----------------------|---------------------|-----------------------------------------------------------|--------|-------------------|
1060+
| Access Key ID | The access key ID | `access_key_id` | `APP_AWS_S3_EXAMPLE_CREDENTIALS_STATIC_ACCESS_KEY_ID` | string | access-key-id |
1061+
| Secret Access Key | The secret access key | `secret_access_key` | `APP_AWS_S3_EXAMPLE_CREDENTIALS_STATIC_SECRET_ACCESS_KEY` | string | secret-access-key |
1062+
| Session Token | The session token | `session_token` | `APP_AWS_S3_EXAMPLE_CREDENTIALS_STATIC_SESSION_TOKEN` | string | session-token |
1063+
9861064
## APM & Instrumentation
9871065

9881066
The `go-sdk` provides an easy way to add application performance monitoring
@@ -1192,25 +1270,29 @@ import (
11921270
"context"
11931271
"log"
11941272
1195-
"github.com/aws/aws-sdk-go-v2/aws"
1196-
awscfg "github.com/aws/aws-sdk-go-v2/config"
1197-
"github.com/aws/aws-sdk-go-v2/service/s3"
1198-
1273+
sdkaws "github.com/scribd/go-sdk/pkg/aws"
1274+
sdkconfig "github.com/scribd/go-sdk/pkg/configuration"
11991275
instrumentation "github.com/scribd/go-sdk/pkg/instrumentation"
12001276
)
12011277
12021278
func main() {
1203-
cfg, err := awscfg.LoadDefaultConfig(context.Background, awscfg.WithRegion("us-west-2"))
1279+
config, err := sdkconfig.NewConfig()
12041280
if err != nil {
1205-
log.Fatalf("error: %v", err)
1281+
log.Fatalf("Failed to load SDK config: %s", err)
12061282
}
12071283
1284+
awsBuilder := sdkaws.NewBuilder(config.AWS)
1285+
1286+
cfg, err := awsBuilder.LoadConfig(context.Background())
1287+
if err != nil {
1288+
log.Fatalf("error: %v", err)
1289+
}
12081290
instrumentation.InstrumentAWSClient(cfg, instrumentation.Settings{
12091291
AppName: applicationName,
12101292
})
12111293
1212-
// Use the AWS configuration to create clients, such as AWS S3...
1213-
s3client := s3.NewFromConfig(cfg)
1294+
// Create an S3 service client with the service name "default"
1295+
s3client := awsBuilder.NewS3Service(cfg, "default")
12141296
}
12151297
```
12161298

0 commit comments

Comments
 (0)