Skip to content

AWS S3 ​

Overview ​

The S3 exporter will collect the data and create a new file in a specific folder everytime we send the data.

Everytime the FlushInterval or MaxEventInMemory is reached a new file will be added to AWS S3.

NOTE

If for some reason the AWS S3 upload fails, we will keep the data in memory and retry to add the next time we reach FlushInterval or MaxEventInMemory.

Configure the relay proxy ​

To configure your relay proxy to use the AWS S3 exporter, you need to add the following configuration to your relay proxy configuration file:

yaml
# ...
exporters:
  - kind: s3
    bucket: evaluation-data-bucket
# ...

NOTE

If you are using the S3 exporter, the easiest way to provide credentials is to set environment variables. It will be used by Semaphore to identify to your S3 bucket.

shell
export AWS_SECRET_ACCESS_KEY=xxxx
export AWS_ACCESS_KEY_ID=xxx
export AWS_DEFAULT_REGION=eu-west-1
Field nameMandatoryTypeDefaultDescription
kindYesstringnone(mandatory) Value should be s3.
This field is mandatory and describes which retriever you are using.
bucketYesstringnone(mandatory) Name of your S3 Bucket.
flushIntervalNoint60000The interval in millisecond between 2 calls to the webhook (if the maxEventInMemory is reached before the flushInterval we will call the exporter before).
maxEventInMemoryNoint100000If we hit that limit we will call the exporter.
formatNostringJSONFormat is the output format you want in your exported file. Available format: JSON, CSV, Parquet.
filenameNostringflag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}You can use a config template to define the name of your exported files. Available replacements are {{ .Hostname}}, {{ .Timestamp}} and {{ .Format}
csvTemplateNostring{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}};{{ .Source}}\nCsvTemplate is used if your output format is CSV.
This field will be ignored if you are using format other than CSV.
You can decide which fields you want in your CSV line with a go-template syntax, please check exporter/feature_event.go to see what are the fields available.
pathNostringbucket root levelThe location of the directory in S3.
parquetCompressionCodecNostringSNAPPYParquetCompressionCodec is the parquet compression codec for better space efficiency. Available options

Compatibility with S3-Compatible Solutions ​

The S3 exporter also works with S3-compatible object stores such as MinIO, Ceph or Garage: keep kind: s3 and point the AWS SDK at your server with AWS_ENDPOINT_URL_S3.

NOTE

Read the MinIO page for the full setup, including the bucket addressing gotcha you will hit if your endpoint is a hostname rather than an IP address.

Configure the GO Module ​

To configure your GO module to use the AWS S3 exporter, you need to add the following configuration to your ffclient.Config{} object:

NOTE

The S3 Exporter v2 will use the aws-sdk-go-v2 to store your evaluation data in an S3 bucket.

The S3 Retriever v1 will use the deprecated aws-sdk-go to access your flag in an S3 bucket.

AWS has announce end-of-support for AWS SDK for Go v1, and it's recommended to migrate from S3 Retriever v1 to v2.

go
awsConfig, _ := config.LoadDefaultConfig(context.Background())
config := ffclient.Config{
    // ...
   DataExporter: ffclient.DataExporter{
        // ...
        Exporter: &s3exporterv2.Exporter{
            Format: "csv",
            FileName: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}",
            CsvTemplate: "{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}};{{ .Source}}\n",
            Bucket:    "my-bucket",
            S3Path:    "/go-feature-flag/variations/",
            Filename:  "flag-variation-{{ .Timestamp}}.{{ .Format}}",
            AwsConfig: &awsConfig,
        },
    },
    // ...
}
client, err := ffclient.New(config)
defer client.Close()
Field nameMandatoryDefaultDescription
BucketYesnoneName of your S3 Bucket.
AwsConfigNoconfig.LoadDefaultConfig()An instance of aws.Config that configures your access to AWS (see this documentation for more info).
If not set, config.LoadDefaultConfig() is called for you, which reads the standard AWS environment variables and shared config files.
FlushIntervalNo60000`The interval in millisecond between 2 calls to the webhook (if the maxEventInMemory is reached before the flushInterval we will call the exporter before).
MaxEventInMemoryNo100000If we hit that limit we will call the exporter.
FormatNoJSONFormat is the output format you want in your exported file. Available format: JSON, CSV, Parquet.
FilenameNoflag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}You can use a config template to define the name of your exported files. Available replacements are {{ .Hostname}}, {{ .Timestamp}} and {{ .Format}
CsvTemplateNo{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}};{{ .Source}}\nCsvTemplate is used if your output format is CSV.
This field will be ignored if you are using format other than CSV.
You can decide which fields you want in your CSV line with a go-template syntax, please check exporter/feature_event.go to see what are the fields available.
PathNobucket root levelThe location of the directory in S3.
ParquetCompressionCodecNoSNAPPYParquetCompressionCodec is the parquet compression codec for better space efficiency. Available options

Released under the MIT License.