From ed39a6eab13dbd1551d22ab2a190532f6db1fd46 Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Fri, 11 Oct 2024 14:22:33 +0200 Subject: [PATCH] feat(aws-lambda): Support ApiGatewayV1 and ALB integration in AWS lambda. (#2497) * feat: Manage multiple handlers for AWS Lambda * feat: Support all type of AWS Lambda usage * doc: Add lambda adapter doc * Renaming to follow lint guidelines --- cmd/relayproxy/api/lambda_handler.go | 43 ++- cmd/relayproxy/api/lambda_handler_test.go | 125 +++++++++ cmd/relayproxy/api/server.go | 9 +- cmd/relayproxy/config/config.go | 5 + .../docs/relay_proxy/configure_relay_proxy.md | 245 +++++++++--------- .../docs/relay_proxy/deploy_relay_proxy.md | 37 ++- 6 files changed, 321 insertions(+), 143 deletions(-) create mode 100644 cmd/relayproxy/api/lambda_handler_test.go diff --git a/cmd/relayproxy/api/lambda_handler.go b/cmd/relayproxy/api/lambda_handler.go index 4eef6bbdb94..cdf39285fb5 100644 --- a/cmd/relayproxy/api/lambda_handler.go +++ b/cmd/relayproxy/api/lambda_handler.go @@ -2,31 +2,54 @@ package api import ( "context" + "strings" "github.com/aws/aws-lambda-go/events" - "github.com/aws/aws-lambda-go/lambda" echoadapter "github.com/awslabs/aws-lambda-go-api-proxy/echo" "github.com/labstack/echo/v4" ) -// newAwsLambdaHandler is creating a new awsLambdaHandler struct with the echoadapter +// newAwsLambdaHandlerManager is creating a new awsLambdaHandler struct with the echoadapter // to proxy all lambda event to echo. -func newAwsLambdaHandler(echoInstance *echo.Echo) awsLambdaHandler { +func newAwsLambdaHandlerManager(echoInstance *echo.Echo) awsLambdaHandler { return awsLambdaHandler{ - adapter: echoadapter.NewV2(echoInstance), + adapterAPIGtwV2: echoadapter.NewV2(echoInstance), + adapterALB: echoadapter.NewALB(echoInstance), + adapterAPIGtwV1: echoadapter.New(echoInstance), } } type awsLambdaHandler struct { - adapter *echoadapter.EchoLambdaV2 + adapterAPIGtwV2 *echoadapter.EchoLambdaV2 + adapterAPIGtwV1 *echoadapter.EchoLambda + adapterALB *echoadapter.EchoLambdaALB } -func (h *awsLambdaHandler) Start() { - lambda.Start(h.Handler) +func (h *awsLambdaHandler) GetAdapter(mode string) interface{} { + switch strings.ToUpper(mode) { + case "APIGATEWAYV1": + return h.HandlerAPIGatewayV1 + case "ALB": + return h.HandlerALB + default: + return h.HandlerAPIGatewayV2 + } } -// Handler is the function that proxy the lambda events to echo calls. -func (h *awsLambdaHandler) Handler(ctx context.Context, req events.APIGatewayV2HTTPRequest) ( +// HandlerAPIGatewayV2 is the function that proxy the lambda events to echo calls for API Gateway V2. +func (h *awsLambdaHandler) HandlerAPIGatewayV2(ctx context.Context, req events.APIGatewayV2HTTPRequest) ( events.APIGatewayV2HTTPResponse, error) { - return h.adapter.ProxyWithContext(ctx, req) + return h.adapterAPIGtwV2.ProxyWithContext(ctx, req) +} + +// HandlerAPIGatewayV1 is the function that proxy the lambda events to echo calls for API Gateway V1. +func (h *awsLambdaHandler) HandlerAPIGatewayV1(ctx context.Context, req events.APIGatewayProxyRequest) ( + events.APIGatewayProxyResponse, error) { + return h.adapterAPIGtwV1.ProxyWithContext(ctx, req) +} + +// HandlerALB is the function that proxy the lambda events to echo calls for API Gateway V1. +func (h *awsLambdaHandler) HandlerALB(ctx context.Context, req events.ALBTargetGroupRequest) ( + events.ALBTargetGroupResponse, error) { + return h.adapterALB.ProxyWithContext(ctx, req) } diff --git a/cmd/relayproxy/api/lambda_handler_test.go b/cmd/relayproxy/api/lambda_handler_test.go new file mode 100644 index 00000000000..39b4e39af64 --- /dev/null +++ b/cmd/relayproxy/api/lambda_handler_test.go @@ -0,0 +1,125 @@ +package api + +import ( + "context" + "encoding/json" + "strings" + "testing" + + "github.com/aws/aws-lambda-go/events" + "github.com/aws/aws-lambda-go/lambda" + "github.com/stretchr/testify/require" + "github.com/thomaspoignant/go-feature-flag/cmd/relayproxy/config" + "github.com/thomaspoignant/go-feature-flag/cmd/relayproxy/metric" + "github.com/thomaspoignant/go-feature-flag/cmd/relayproxy/service" + "github.com/thomaspoignant/go-feature-flag/notifier" + "go.uber.org/zap" +) + +func TestAwsLambdaHandler_GetAdapter(t *testing.T) { + type test struct { + name string + mode string + request interface{} + } + + tests := []test{ + { + name: "APIGatewayV2 event handler", + mode: "APIGatewayV2", + request: events.APIGatewayV2HTTPRequest{ + RequestContext: events.APIGatewayV2HTTPRequestContext{ + HTTP: events.APIGatewayV2HTTPRequestContextHTTPDescription{ + Method: "GET", + Path: "/health", + }, + }, + Headers: map[string]string{ + "Content-Type": "application/json", + }, + Body: "", + }, + }, + { + name: "APIGatewayV1 event handler", + mode: "APIGatewayV1", + request: events.APIGatewayProxyRequest{ + HTTPMethod: "GET", + Path: "/health", + RequestContext: events.APIGatewayProxyRequestContext{ + Path: "/health", + HTTPMethod: "GET", + }, + Headers: map[string]string{ + "Content-Type": "application/json", + }, + Body: "", + }, + }, + { + name: "ALB event handler", + mode: "ALB", + request: events.ALBTargetGroupRequest{ + HTTPMethod: "GET", + Path: "/health", + Headers: map[string]string{ + "Content-Type": "application/json", + }, + Body: "", + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + z, err := zap.NewProduction() + require.NoError(t, err) + c := &config.Config{ + StartAsAwsLambda: true, + AwsLambdaAdapter: tt.mode, + Retriever: &config.RetrieverConf{ + Kind: "file", + Path: "../../../testdata/flag-config.yaml", + }, + } + goff, err := service.NewGoFeatureFlagClient(c, z, []notifier.Notifier{}) + require.NoError(t, err) + apiServer := New(c, service.Services{ + MonitoringService: service.NewMonitoring(goff), + WebsocketService: service.NewWebsocketService(), + GOFeatureFlagService: goff, + Metrics: metric.Metrics{}, + }, z) + + reqJSON, err := json.Marshal(tt.request) + require.NoError(t, err) + + // Create a Lambda handler + handler := lambda.NewHandler(apiServer.getLambdaHandler()) + + // Invoke the handler with the mock event + response, err := handler.Invoke(context.Background(), reqJSON) + require.NoError(t, err) + + switch strings.ToLower(tt.mode) { + case "apigatewayv2": + var res events.APIGatewayV2HTTPResponse + err = json.Unmarshal(response, &res) + require.NoError(t, err) + require.Equal(t, 200, res.StatusCode) + case "apigatewayv1": + var res events.APIGatewayProxyResponse + err = json.Unmarshal(response, &res) + require.NoError(t, err) + require.Equal(t, 200, res.StatusCode) + case "alb": + var res events.ALBTargetGroupResponse + err = json.Unmarshal(response, &res) + require.NoError(t, err) + require.Equal(t, 200, res.StatusCode) + default: + require.Fail(t, "not implemented") + } + }) + } +} diff --git a/cmd/relayproxy/api/server.go b/cmd/relayproxy/api/server.go index 85a69f2e44a..d0680fa3e19 100644 --- a/cmd/relayproxy/api/server.go +++ b/cmd/relayproxy/api/server.go @@ -8,6 +8,7 @@ import ( "strings" "time" + "github.com/aws/aws-lambda-go/lambda" "github.com/labstack/echo-contrib/echoprometheus" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" @@ -143,8 +144,12 @@ func (s *Server) Start() { // StartAwsLambda is starting the relay proxy as an AWS Lambda func (s *Server) StartAwsLambda() { - adapter := newAwsLambdaHandler(s.apiEcho) - adapter.Start() + lambda.Start(s.getLambdaHandler()) +} + +func (s *Server) getLambdaHandler() interface{} { + handlerMngr := newAwsLambdaHandlerManager(s.apiEcho) + return handlerMngr.GetAdapter(s.config.AwsLambdaAdapter) } // Stop shutdown the API server diff --git a/cmd/relayproxy/config/config.go b/cmd/relayproxy/config/config.go index def206883df..9ba30be9929 100644 --- a/cmd/relayproxy/config/config.go +++ b/cmd/relayproxy/config/config.go @@ -216,6 +216,11 @@ type Config struct { // StartAsAwsLambda (optional) if true, the relay proxy will start ready to be launched as AWS Lambda StartAsAwsLambda bool `mapstructure:"startAsAwsLambda" koanf:"startasawslambda"` + // AwsLambdaAdapter (optional) is the adapter to use when the relay proxy is started as an AWS Lambda. + // Possible values are "APIGatewayV1", "APIGatewayV2" and "ALB" + // Default: "APIGatewayV2" + AwsLambdaAdapter string `mapstructure:"awsLambdaAdapter" koanf:"awslambdaadapter"` + // EvaluationContextEnrichment (optional) will be merged with the evaluation context sent during the evaluation. // It is useful to add common attributes to all the evaluations, such as a server version, environment, ... // diff --git a/website/docs/relay_proxy/configure_relay_proxy.md b/website/docs/relay_proxy/configure_relay_proxy.md index 38d7b0c9e3b..06993a4b289 100644 --- a/website/docs/relay_proxy/configure_relay_proxy.md +++ b/website/docs/relay_proxy/configure_relay_proxy.md @@ -7,9 +7,11 @@ description: How to configure the relay proxy to serve your feature flags. # Configure the relay proxy ## Getting Started + The configuration of the **relay proxy** is based on a configuration file that you have to provide. -The only mandatory information you need to start the server is to provide where to retrieve your feature flags configuration. +The only mandatory information you need to start the server is to provide where to retrieve your feature flags +configuration. ```yaml retriever: @@ -25,43 +27,44 @@ You can override file configurations using environment variables. Note that all environment variables should be uppercase. If you want to replace a nested fields, please use `_` to separate each field _(ex: `RETRIEVER_KIND`)_. -In case of an array of string, you can add multiple values separated by a comma _(ex: `AUTHORIZEDKEYS_EVALUATION=my-first-key,my-second-key`)_. +In case of an array of string, you can add multiple values separated by a comma _( +ex: `AUTHORIZEDKEYS_EVALUATION=my-first-key,my-second-key`)_. ::: - -| Field name | Type | Default | Description | -|------------------------------------|-----------------------------------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `retriever` | [retriever](#retriever) | **none** | **(mandatory)** This is the configuration on how to retrieve the configuration of the files.

_Note: this field is mandatory only if `retrievers` is not set._ | | -| `retrievers` | [[]retriever](#retriever) | **none** | **(mandatory)** Exactly the same things as `retriever` except that you can provide more than 1 retriever.

_Note: this field is mandatory only if `retriever` is not set._ | -| `listen` | int | `1031` | This is the port used by the relay proxy when starting the HTTP server. | -| `pollingInterval` | int | `60000` | This is the time interval **in millisecond** when the relay proxy is reloading the configuration file.
The minimum time accepted is 1000 millisecond. | -| `enablePollingJitter` | boolean | `false` | Set to true if you want to avoid having true periodicity when retrieving your flags. It is useful to avoid having spike on your flag configuration storage in case your application is starting multiple instance at the same time.
We ensure a deviation that is maximum ±10% of your polling interval.
Default: false | -| `hideBanner` | boolean | `false` | Should we display the beautiful **go-feature-flag** banner when starting the relay proxy | -| `enableSwagger` | boolean | `false` | Enables Swagger for testing the APIs directly. If you are enabling Swagger you will have to provide the `host` configuration and the Swagger UI will be available at `http://:/swagger/`. | -| `host` | string | `localhost` | This is the DNS you will use to access the relay proxy. This field is used by Swagger to query the API at the right place. | -| `restApiTimeout` | int | `5000` | Timeout in milliseconds for API calls. | -| `logLevel` | string | `info` | The log level to use for the relay proxy.
Available values are `ERROR`, `WARN`, `INFO`, `DEBUG`. | -| `fileFormat` | string | `yaml` | This is the format of your `go-feature-flag` configuration file. Acceptable values are `yaml`, `json`, `toml`. | -| `startWithRetrieverError` | boolean | `false` | By default the **relay proxy** will crash if it is not able to retrieve the flags from the configuration.
If you don't want your relay proxy to crash, you can set `startWithRetrieverError` to true. Until the flag is retrievable the relay proxy will only answer with default values. | -| `exporter` | [exporter](#exporter) | **none** | Exporter is the configuration used to export data. | -| `notifier` | [notifier](#notifier) | **none** | Notifiers is the configuration on where to notify a flag change. | -| `authorizedKeys` | [authorizedKeys](#type-authorizedkeys) | **none** | List of authorized API keys. | -| `evaluationContextEnrichment` | object | **none** | It is a free field that will be merged with the evaluation context sent during the evaluation. It is useful to add common attributes to all the evaluations, such as a server version, environment, etc.

These fields will be included in the custom attributes of the evaluation context.

If in the evaluation context you have a field with the same name, it will be override by the `evaluationContextEnrichment`. | -| `openTelemetryOtlpEndpoint` | string | **none** | Endpoint of your OpenTelemetry OTLP collector, used to send traces to it and you will be able to forward them to your OpenTelemetry solution with the appropriate provider. | -| `kafka` | object | **none** | Settings for the Kafka exporter. Mandatory when using the 'kafka' exporter type, and ignored otherwise. | -| `projectID` | string | **none** | ID of GCP project. Mandatory when using PubSub exporter. | -| `topic` | string | **none** | Name of PubSub topic on which messages will be published. Mandatory when using PubSub exporter. | -| `persistentFlagConfigurationFile` | string | **none** | If set GO Feature Flag will store the flags configuration in this file to be able to serve the flags even if none of the retrievers is available during starting time.
By default, the flag configuration is not persisted and stays on the retriever system. By setting a file here, you ensure that GO Feature Flag will always start with a configuration but which can be out-dated.

_(example: `/tmp/goff_persist_conf.yaml`)_ | - +| Field name | Type | Default | Description | +|-----------------------------------|----------------------------------------|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `retriever` | [retriever](#retriever) | **none** | **(mandatory)** This is the configuration on how to retrieve the configuration of the files.

_Note: this field is mandatory only if `retrievers` is not set._ | | +| `retrievers` | [[]retriever](#retriever) | **none** | **(mandatory)** Exactly the same things as `retriever` except that you can provide more than 1 retriever.

_Note: this field is mandatory only if `retriever` is not set._ | +| `listen` | int | `1031` | This is the port used by the relay proxy when starting the HTTP server. | +| `pollingInterval` | int | `60000` | This is the time interval **in millisecond** when the relay proxy is reloading the configuration file.
The minimum time accepted is 1000 millisecond. | +| `enablePollingJitter` | boolean | `false` | Set to true if you want to avoid having true periodicity when retrieving your flags. It is useful to avoid having spike on your flag configuration storage in case your application is starting multiple instance at the same time.
We ensure a deviation that is maximum ±10% of your polling interval.
Default: false | +| `hideBanner` | boolean | `false` | Should we display the beautiful **go-feature-flag** banner when starting the relay proxy | +| `enableSwagger` | boolean | `false` | Enables Swagger for testing the APIs directly. If you are enabling Swagger you will have to provide the `host` configuration and the Swagger UI will be available at `http://:/swagger/`. | +| `host` | string | `localhost` | This is the DNS you will use to access the relay proxy. This field is used by Swagger to query the API at the right place. | +| `restApiTimeout` | int | `5000` | Timeout in milliseconds for API calls. | +| `logLevel` | string | `info` | The log level to use for the relay proxy.
Available values are `ERROR`, `WARN`, `INFO`, `DEBUG`. | +| `fileFormat` | string | `yaml` | This is the format of your `go-feature-flag` configuration file. Acceptable values are `yaml`, `json`, `toml`. | +| `startWithRetrieverError` | boolean | `false` | By default the **relay proxy** will crash if it is not able to retrieve the flags from the configuration.
If you don't want your relay proxy to crash, you can set `startWithRetrieverError` to true. Until the flag is retrievable the relay proxy will only answer with default values. | +| `exporter` | [exporter](#exporter) | **none** | Exporter is the configuration used to export data. | +| `notifier` | [notifier](#notifier) | **none** | Notifiers is the configuration on where to notify a flag change. | +| `authorizedKeys` | [authorizedKeys](#type-authorizedkeys) | **none** | List of authorized API keys. | +| `evaluationContextEnrichment` | object | **none** | It is a free field that will be merged with the evaluation context sent during the evaluation. It is useful to add common attributes to all the evaluations, such as a server version, environment, etc.

These fields will be included in the custom attributes of the evaluation context.

If in the evaluation context you have a field with the same name, it will be override by the `evaluationContextEnrichment`. | +| `openTelemetryOtlpEndpoint` | string | **none** | Endpoint of your OpenTelemetry OTLP collector, used to send traces to it and you will be able to forward them to your OpenTelemetry solution with the appropriate provider. | +| `kafka` | object | **none** | Settings for the Kafka exporter. Mandatory when using the 'kafka' exporter type, and ignored otherwise. | +| `projectID` | string | **none** | ID of GCP project. Mandatory when using PubSub exporter. | +| `topic` | string | **none** | Name of PubSub topic on which messages will be published. Mandatory when using PubSub exporter. | +| `persistentFlagConfigurationFile` | string | **none** | If set GO Feature Flag will store the flags configuration in this file to be able to serve the flags even if none of the retrievers is available during starting time.
By default, the flag configuration is not persisted and stays on the retriever system. By setting a file here, you ensure that GO Feature Flag will always start with a configuration but which can be out-dated.

_(example: `/tmp/goff_persist_conf.yaml`)_ | +| `startAsAwsLambda` | boolean | **`false`** | If set GO Feature Flag start the relay-proxy as a AWS Lambda, it means that it will start the server to receive request in the AWS format _(see `awsLambdaAdapter` to set the request/response format you are using)_. | +| `awsLambdaAdapter` | string | **`APIGatewayV2`** | This param is used only if `startAsAwsLambda` is `true`.
This parameter allow you to decide which type of AWS lambda handler you wan to use.
Accepted values are `APIGatewayV2`, `APIGatewayV1`, `ALB`. | ## type `authorizedKeys` To be able to control who can access your relay proxy, you can set a list of authorized keys. -| Field name | Type | Default | Description | -|--------------|----------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `evaluation` | []string | **none** | If set, we will check for each evaluation if an authorized key is provided.
Each request will need to provide one of authorized key inside `Authorization` header with format `Bearer `.

_Note: there will be no authorization when this config is not set._ | -| `admin` | []string | **none** | You need to set API keys in this field if you want to access the `/v1/admin/*` endpoints.
If no api key is configured the endpoint will be unreachable.
Each request will need to provide one of authorized key inside `Authorization` header with format `Bearer `. | +| Field name | Type | Default | Description | +|--------------|----------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `evaluation` | []string | **none** | If set, we will check for each evaluation if an authorized key is provided.
Each request will need to provide one of authorized key inside `Authorization` header with format `Bearer `.

_Note: there will be no authorization when this config is not set._ | +| `admin` | []string | **none** | You need to set API keys in this field if you want to access the `/v1/admin/*` endpoints.
If no api key is configured the endpoint will be unreachable.
Each request will need to provide one of authorized key inside `Authorization` header with format `Bearer `. | @@ -72,7 +75,7 @@ In this section we will present all the available retriever configurations avail ### S3 -If you are using the S3 provider, the easiest way to provide credentials is to set environment variables. +If you are using the S3 provider, the easiest way to provide credentials is to set environment variables. It will be used by GO Feature Flag to identify to your S3 bucket. ```shell @@ -87,7 +90,6 @@ export AWS_DEFAULT_REGION=eu-west-1 | `bucket` | string | **none** | **(mandatory)** This is the name of your S3 bucket _(ex: `my-featureflag-bucket`)_. | | `item` | string | **none** | **(mandatory)** Path to the file inside the bucket _(ex: `config/flag/my-flags.yaml`)_. | - ### GitHub :::tip @@ -98,7 +100,7 @@ If the rate limit is reached, the retriever will return an error and will stop p | Field name | Type | Default | Description | |------------------|--------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`github`**.
_This field is mandatory and describes which retriever you are using._ | +| `kind` | string | **none** | **(mandatory)** Value should be **`github`**.
_This field is mandatory and describes which retriever you are using._ | | `repositorySlug` | string | **none** | **(mandatory)** The repository slug of the GitHub repository where your file is located _(ex: `thomaspoignant/go-feature-flag`)_. | | `path` | string | **none** | **(mandatory)** Path to the file inside the repository _(ex: `config/flag/my-flags.yaml`)_. | | `branch` | string | `main` | The branch we should check in the repository. | @@ -109,7 +111,7 @@ If the rate limit is reached, the retriever will return an error and will stop p | Field name | Type | Default | Description | |------------------|--------|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`gitlab`**.
_This field is mandatory and describes which retriever you are using._ | +| `kind` | string | **none** | **(mandatory)** Value should be **`gitlab`**.
_This field is mandatory and describes which retriever you are using._ | | `repositorySlug` | string | **none** | **(mandatory)** The repository slug of the GitLab repository where your file is located _(ex: `thomaspoignant/go-feature-flag`)_. | | `path` | string | **none** | **(mandatory)** Path to the file inside the repository _(ex: `config/flag/my-flags.yaml`)_. | | `baseUrl` | string | `https://gitlab.com` | The base URL of your GitLab instance. | @@ -117,50 +119,47 @@ If the rate limit is reached, the retriever will return an error and will stop p | `token` | string | **none** | GitLab personal access token used to access a private repository ([Create a personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token)). | | `timeout` | string | `10000` | Timeout in millisecond used when calling GitLab. | - ### File -| Field name | Type | Default | Description | -|------------|--------|----------|----------------------------------------------------------------------------------------------------------------------| +| Field name | Type | Default | Description | +|------------|--------|----------|------------------------------------------------------------------------------------------------------------------------| | `kind` | string | **none** | **(mandatory)** Value should be **`file`**.
_This field is mandatory and describes which retriever you are using._ | -| `path` | string | **none** | **(mandatory)** Path to the file in your local computer _(ex: `/goff/my-flags.yaml`)_. | - +| `path` | string | **none** | **(mandatory)** Path to the file in your local computer _(ex: `/goff/my-flags.yaml`)_. | ### HTTP -| Field name | Type | Default | Description | -|------------|---------------------|----------|----------------------------------------------------------------------------------------------------------------------| +| Field name | Type | Default | Description | +|------------|---------------------|----------|------------------------------------------------------------------------------------------------------------------------| | `kind` | string | **none** | **(mandatory)** Value should be **`http`**.
_This field is mandatory and describes which retriever you are using._ | -| `url` | string | **none** | **(mandatory)** Location to retrieve the file. | -| `method` | string | `GET` | The HTTP Method you are using to call the HTTP endpoint. | -| `body` | string | **none** | The HTTP Body you are using to call the HTTP endpoint. | -| `headers` | map[string][]string | **none** | The HTTP headers used when calling the HTTP endpoint (useful for authorization). | -| `timeout` | string | `10000` | Timeout in millisecond when calling the HTTP endpoint. | - +| `url` | string | **none** | **(mandatory)** Location to retrieve the file. | +| `method` | string | `GET` | The HTTP Method you are using to call the HTTP endpoint. | +| `body` | string | **none** | The HTTP Body you are using to call the HTTP endpoint. | +| `headers` | map[string][]string | **none** | The HTTP headers used when calling the HTTP endpoint (useful for authorization). | +| `timeout` | string | `10000` | Timeout in millisecond when calling the HTTP endpoint. | ### Google Storage -| Field name | Type | Default | Description | -|------------|--------|----------|-------------------------------------------------------------------------------------------------------------------------------| +| Field name | Type | Default | Description | +|------------|--------|----------|---------------------------------------------------------------------------------------------------------------------------------| | `kind` | string | **none** | **(mandatory)** Value should be **`googleStorage`**.
_This field is mandatory and describes which retriever you are using._ | -| `bucket` | string | **none** | **(mandatory)** This is the name of your Google Storage bucket _(ex: `my-featureflag-bucket`)_. | -| `object` | string | **none** | **(mandatory)** Path to the file inside the bucket _(ex: `config/flag/my-flags.yaml`)_. | - +| `bucket` | string | **none** | **(mandatory)** This is the name of your Google Storage bucket _(ex: `my-featureflag-bucket`)_. | +| `object` | string | **none** | **(mandatory)** Path to the file inside the bucket _(ex: `config/flag/my-flags.yaml`)_. | ### Kubernetes ConfigMap _Note that relay proxy is only supporting this while running inside the kubernetes cluster._ -| Field name | Type | Default | Description | -|-------------|--------|----------|---------------------------------------------------------------------------------------------------------------------------| +| Field name | Type | Default | Description | +|-------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------------| | `kind` | string | **none** | **(mandatory)** Value should be **`configmap`**.
_This field is mandatory and describes which retriever you are using._ | -| `namespace` | string | **none** | **(mandatory)** This is the name of the namespace where your **configmap** is located _(ex: `default`)_. | -| `configmap` | string | **none** | **(mandatory)** Name of the **configmap** we should read _(ex: `feature-flag`)_. | -| `key` | string | **none** | **(mandatory)** Name of the `key` in the **configmap** which contains the flag. | +| `namespace` | string | **none** | **(mandatory)** This is the name of the namespace where your **configmap** is located _(ex: `default`)_. | +| `configmap` | string | **none** | **(mandatory)** Name of the **configmap** we should read _(ex: `feature-flag`)_. | +| `key` | string | **none** | **(mandatory)** Name of the `key` in the **configmap** which contains the flag. | ### MongoDB -_To understand the format in which a flag needs to be configured in MongoDB, check the [example](https://github.com/thomaspoignant/go-feature-flag/examples/retriever_mongodb) available._ +_To understand the format in which a flag needs to be configured in MongoDB, check +the [example](https://github.com/thomaspoignant/go-feature-flag/examples/retriever_mongodb) available._ | Field name | Type | Default | Description | |--------------|--------|----------|---------------------------------------------------------------------------------------------------------------------------| @@ -169,15 +168,16 @@ _To understand the format in which a flag needs to be configured in MongoDB, che | `database` | string | **none** | **(mandatory)** Name of the **database** where flags are stored. | | `collection` | string | **none** | **(mandatory)** Name of the **collection** where flags are stored. | - ### Redis -_To understand the format in which a flag needs to be configured in **Redis**, check the [doc](../go_module/store_file/redis#expected-format) available._ -| Field name | Type | Default | Description | -|--------------|--------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`redis`**.
_This field is mandatory and describes which retriever you are using._ | -| `options` | object | **none** | **(mandatory)** Options used to connect to your redis instance.
All the options from the `go-redis` SDK are available _([check `redis.Options`](https://github.com/redis/go-redis/blob/683f4fa6a6b0615344353a10478548969b09f89c/options.go#L31))_ | -| `prefix` | string | **none** | Prefix used before your flag name in the Redis DB. | +_To understand the format in which a flag needs to be configured in **Redis**, check +the [doc](../go_module/store_file/redis#expected-format) available._ + +| Field name | Type | Default | Description | +|------------|--------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `kind` | string | **none** | **(mandatory)** Value should be **`redis`**.
_This field is mandatory and describes which retriever you are using._ | +| `options` | object | **none** | **(mandatory)** Options used to connect to your redis instance.
All the options from the `go-redis` SDK are available _([check `redis.Options`](https://github.com/redis/go-redis/blob/683f4fa6a6b0615344353a10478548969b09f89c/options.go#L31))_ | +| `prefix` | string | **none** | Prefix used before your flag name in the Redis DB. | @@ -187,7 +187,7 @@ _To understand the format in which a flag needs to be configured in **Redis**, c | Field name | Type | Default | Description | |--------------------|---------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`webhook`**.
_This field is mandatory and describes which retriever you are using._ | +| `kind` | string | **none** | **(mandatory)** Value should be **`webhook`**.
_This field is mandatory and describes which retriever you are using._ | | `endpointUrl` | string | **none** | **(mandatory)** EndpointURL of your webhook. | | `flushInterval` | int | `60000` | The interval in millisecond between 2 calls to the webhook _(if the `maxEventInMemory` is reached before the flushInterval we will call the webhook before)_. | | `maxEventInMemory` | int | `100000` | If we hit that limit we will call the webhook. | @@ -195,73 +195,70 @@ _To understand the format in which a flag needs to be configured in **Redis**, c | `meta` | map[string]string | **none** | Add all the information you want to see in your request. | | `headers` | map[string][]string | **none** | Add all the headers you want to add while calling the endpoint | - ### File -| Field name | Type | Default | Description | -|--------------------|--------|-----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`file`**.
_This field is mandatory and describes which retriever you are using._ | -| `outputDir` | string | **none** | **(mandatory)** OutputDir is the location of the directory where to store the exported files. It should finish with a `/`. | -| `flushInterval` | int | `60000` | The interval in millisecond between 2 calls to the webhook _(if the `maxEventInMemory` is reached before the flushInterval we will call the webhook before)_. | -| `maxEventInMemory` | int | `100000` | If we hit that limit we will call the webhook. | -| `format` | string | `JSON` | Format is the output format you want in your exported file. Available format: `JSON`, `CSV`, `Parquet`. | -| `filename` | string | `flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}` | You can use a templated config to define the name of your exported files. Available replacements are `{{ .Hostname}}`, `{{ .Timestamp}}` and `{{ .Format}` | -| `csvTemplate` | string | `{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}};{{ .Source}}\n` | CsvTemplate 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 [`internal/exporter/feature_event.go`](https://github.com/thomaspoignant/go-feature-flag/blob/main/internal/exporter/feature_event.go) to see the fields available. |` -| `parquetCompressionCodec` | string | `SNAPPY` | ParquetCompressionCodec is the parquet compression codec for better space efficiency. [Available options](https://github.com/apache/parquet-format/blob/master/Compression.md) |` - +| Field name | Type | Default | Description | +|---------------------------|--------|------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `kind` | string | **none** | **(mandatory)** Value should be **`file`**.
_This field is mandatory and describes which retriever you are using._ | +| `outputDir` | string | **none** | **(mandatory)** OutputDir is the location of the directory where to store the exported files. It should finish with a `/`. | +| `flushInterval` | int | `60000` | The interval in millisecond between 2 calls to the webhook _(if the `maxEventInMemory` is reached before the flushInterval we will call the webhook before)_. | +| `maxEventInMemory` | int | `100000` | If we hit that limit we will call the webhook. | +| `format` | string | `JSON` | Format is the output format you want in your exported file. Available format: `JSON`, `CSV`, `Parquet`. | +| `filename` | string | `flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}` | You can use a templated config to define the name of your exported files. Available replacements are `{{ .Hostname}}`, `{{ .Timestamp}}` and `{{ .Format}` | +| `csvTemplate` | string | `{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}};{{ .Source}}\n` | CsvTemplate 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 [`internal/exporter/feature_event.go`](https://github.com/thomaspoignant/go-feature-flag/blob/main/internal/exporter/feature_event.go) to see the fields available. |` +| `parquetCompressionCodec` | string | `SNAPPY` | ParquetCompressionCodec is the parquet compression codec for better space efficiency. [Available options](https://github.com/apache/parquet-format/blob/master/Compression.md) |` ### Log -| Field name | Type | Default | Description | -|--------------------|--------|-------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`log`**.
_This field is mandatory and describes which retriever you are using._ | +| Field name | Type | Default | Description | +|--------------------|--------|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `kind` | string | **none** | **(mandatory)** Value should be **`log`**.
_This field is mandatory and describes which retriever you are using._ | | `flushInterval` | int | `60000` | The interval in millisecond between 2 calls to the webhook _(if the `maxEventInMemory` is reached before the flushInterval, we will call the webhook before)_. | -| `maxEventInMemory` | int | `100000` | If we hit that limit we will call the webhook. | +| `maxEventInMemory` | int | `100000` | If we hit that limit we will call the webhook. | | `logFormat` | string | `[{{ .FormattedDate}}] user="{{ .UserKey}}", flag="{{ .Key}}", value="{{ .Value}}"` | LogFormat is the [template](https://golang.org/pkg/text/template/) configuration of the output format of your log.
You can use all the key from the exporter.FeatureEvent + a key called FormattedDate that represent the date with the RFC 3339 Format. | ### S3 -| Field name | Type | Default | Description | -|--------------------|--------|-----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`s3`**.
_This field is mandatory and describes which retriever you are using._ | -| `bucket` | string | **none** | **(mandatory)** Name of your S3 Bucket. | -| `flushInterval` | int | `60000` | The interval in millisecond between 2 calls to the webhook _(if the `maxEventInMemory` is reached before the flushInterval we will call the webhook before)_. | -| `maxEventInMemory` | int | `100000` | If we hit that limit we will call the webhook. | -| `format` | string | `JSON` | Format is the output format you want in your exported file. Available format: `JSON`, `CSV`, `Parquet`. | -| `filename` | string | `flag-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}` | -| `csvTemplate` | string | `{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}};{{ .Source}}\n` | CsvTemplate 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 [`internal/exporter/feature_event.go`](https://github.com/thomaspoignant/go-feature-flag/blob/main/internal/exporter/feature_event.go) to see what are the fields available. |` -| `path` | string | **bucket root level** | The location of the directory in S3. | -| `parquetCompressionCodec` | string | `SNAPPY` | ParquetCompressionCodec is the parquet compression codec for better space efficiency. [Available options](https://github.com/apache/parquet-format/blob/master/Compression.md) |` +| Field name | Type | Default | Description | +|---------------------------|--------|------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `kind` | string | **none** | **(mandatory)** Value should be **`s3`**.
_This field is mandatory and describes which retriever you are using._ | +| `bucket` | string | **none** | **(mandatory)** Name of your S3 Bucket. | +| `flushInterval` | int | `60000` | The interval in millisecond between 2 calls to the webhook _(if the `maxEventInMemory` is reached before the flushInterval we will call the webhook before)_. | +| `maxEventInMemory` | int | `100000` | If we hit that limit we will call the webhook. | +| `format` | string | `JSON` | Format is the output format you want in your exported file. Available format: `JSON`, `CSV`, `Parquet`. | +| `filename` | string | `flag-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}` | +| `csvTemplate` | string | `{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}};{{ .Source}}\n` | CsvTemplate 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 [`internal/exporter/feature_event.go`](https://github.com/thomaspoignant/go-feature-flag/blob/main/internal/exporter/feature_event.go) to see what are the fields available. |` +| `path` | string | **bucket root level** | The location of the directory in S3. | +| `parquetCompressionCodec` | string | `SNAPPY` | ParquetCompressionCodec is the parquet compression codec for better space efficiency. [Available options](https://github.com/apache/parquet-format/blob/master/Compression.md) |` ### Google Storage -| Field name | Type | Default | Description | -|--------------------|--------|-----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`s3`**.
_This field is mandatory and describes which retriever you are using._ | -| `bucket` | string | **none** | **(mandatory)** Name of your Google Cloud Storage Bucket. | -| `flushInterval` | int | `60000` | The interval in millisecond between 2 calls to the webhook _(if the `maxEventInMemory` is reached before the flushInterval we will call the webhook before)_. | -| `maxEventInMemory` | int | `100000` | If we hit that limit we will call the webhook. | -| `format` | string | `JSON` | Format is the output format you want in your exported file. Available format: `JSON`, `CSV`, `Parquet`. | -| `filename` | string | `flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}` | You can use a templated config to define the name of your exported files. Available replacement are `{{ .Hostname}}`, `{{ .Timestamp}}` and `{{ .Format}` | -| `csvTemplate` | string | `{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}};{{ .Source}}\n` | CsvTemplate 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 [`internal/exporter/feature_event.go`](https://github.com/thomaspoignant/go-feature-flag/blob/main/internal/exporter/feature_event.go) to see what are the fields available. |` -| `path` | string | **bucket root level** | The location of the directory in S3. | -| `parquetCompressionCodec` | string | `SNAPPY` | ParquetCompressionCodec is the parquet compression codec for better space efficiency. [Available options](https://github.com/apache/parquet-format/blob/master/Compression.md) |` +| Field name | Type | Default | Description | +|---------------------------|--------|------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `kind` | string | **none** | **(mandatory)** Value should be **`s3`**.
_This field is mandatory and describes which retriever you are using._ | +| `bucket` | string | **none** | **(mandatory)** Name of your Google Cloud Storage Bucket. | +| `flushInterval` | int | `60000` | The interval in millisecond between 2 calls to the webhook _(if the `maxEventInMemory` is reached before the flushInterval we will call the webhook before)_. | +| `maxEventInMemory` | int | `100000` | If we hit that limit we will call the webhook. | +| `format` | string | `JSON` | Format is the output format you want in your exported file. Available format: `JSON`, `CSV`, `Parquet`. | +| `filename` | string | `flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}` | You can use a templated config to define the name of your exported files. Available replacement are `{{ .Hostname}}`, `{{ .Timestamp}}` and `{{ .Format}` | +| `csvTemplate` | string | `{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}};{{ .Source}}\n` | CsvTemplate 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 [`internal/exporter/feature_event.go`](https://github.com/thomaspoignant/go-feature-flag/blob/main/internal/exporter/feature_event.go) to see what are the fields available. |` +| `path` | string | **bucket root level** | The location of the directory in S3. | +| `parquetCompressionCodec` | string | `SNAPPY` | ParquetCompressionCodec is the parquet compression codec for better space efficiency. [Available options](https://github.com/apache/parquet-format/blob/master/Compression.md) |` ### SQS -| Field name | Type | Default | Description | -|---------------------------|--------|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`sqs`**.
_This field is mandatory and describes which retriever you are using._ | -| `queueUrl` | string | **none** | **(mandatory)** URL of your SQS queue.
_You can find it in your AWS console._ | +| Field name | Type | Default | Description | +|------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------| +| `kind` | string | **none** | **(mandatory)** Value should be **`sqs`**.
_This field is mandatory and describes which retriever you are using._ | +| `queueUrl` | string | **none** | **(mandatory)** URL of your SQS queue.
_You can find it in your AWS console._ | ### Kafka -| Field name | Type | Default | Description | -|------------------|----------|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kafka.topic` | string | **none** | **(mandatory)** Kafka topic to bind to. | +| Field name | Type | Default | Description | +|-------------------|----------|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `kafka.topic` | string | **none** | **(mandatory)** Kafka topic to bind to. | | `kafka.addresses` | []string | **none** | **(mandatory)** List of bootstrap addresses for the Kafka cluster. | -| `kafka.config` | object | _see description_ | This field allows fine tuning of the Kafka reader. This object should contain the [Sarama configuration](https://pkg.go.dev/github.com/IBM/sarama#Config) that the reader will use. On empty, a sensible default is created using [sarama.NewConfig()](https://pkg.go.dev/github.com/IBM/sarama#NewConfig) | - +| `kafka.config` | object | _see description_ | This field allows fine tuning of the Kafka reader. This object should contain the [Sarama configuration](https://pkg.go.dev/github.com/IBM/sarama#Config) that the reader will use. On empty, a sensible default is created using [sarama.NewConfig()](https://pkg.go.dev/github.com/IBM/sarama#NewConfig) | ### Google PubSub @@ -276,17 +273,17 @@ _To understand the format in which a flag needs to be configured in **Redis**, c ### Slack -| Field name | Type | Default | Description | -|-------------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------| +| Field name | Type | Default | Description | +|-------------------|--------|----------|------------------------------------------------------------------------------------------------------------------------| | `kind` | string | **none** | **(mandatory)** Value should be **`slack`**.
_This field is mandatory and describe which retriever you are using._ | -| `slackWebhookUrl` | string | **none** | **(mandatory)** The complete URL of your incoming webhook configured in Slack. | +| `slackWebhookUrl` | string | **none** | **(mandatory)** The complete URL of your incoming webhook configured in Slack. | ### Webhook -| Field name | Type | Default | Description | -|---------------|---------------------|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `kind` | string | **none** | **(mandatory)** Value should be **`webhook`**.
_This field is mandatory and describes which retriever you are using._ | -| `endpointUrl` | string | **none** | **(mandatory)** The complete URL of your API (we will send a POST request to this URL, see [format](https://thomaspoignant.github.io/go-feature-flag/latest/notifier/webhook/#format) | -| `secret` | string | **none** | Secret used to sign your request body and fill the `X-Hub-Signature-256` header.
See [signature section](https://thomaspoignant.github.io/go-feature-flag/latest/data_collection/webhook/#signature) for more details. | -| `meta` | map[string]string | **none** | Add all the information you want to see in your request. | -| `headers` | map[string][]string | **none** | Add all the headers you want to add while calling the endpoint | +| Field name | Type | Default | Description | +|---------------|---------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `kind` | string | **none** | **(mandatory)** Value should be **`webhook`**.
_This field is mandatory and describes which retriever you are using._ | +| `endpointUrl` | string | **none** | **(mandatory)** The complete URL of your API (we will send a POST request to this URL, see [format](https://thomaspoignant.github.io/go-feature-flag/latest/notifier/webhook/#format) | +| `secret` | string | **none** | Secret used to sign your request body and fill the `X-Hub-Signature-256` header.
See [signature section](https://thomaspoignant.github.io/go-feature-flag/latest/data_collection/webhook/#signature) for more details. | +| `meta` | map[string]string | **none** | Add all the information you want to see in your request. | +| `headers` | map[string][]string | **none** | Add all the headers you want to add while calling the endpoint | diff --git a/website/docs/relay_proxy/deploy_relay_proxy.md b/website/docs/relay_proxy/deploy_relay_proxy.md index de701e75b80..f47ec63ae68 100644 --- a/website/docs/relay_proxy/deploy_relay_proxy.md +++ b/website/docs/relay_proxy/deploy_relay_proxy.md @@ -6,7 +6,8 @@ description: Deploy the relay proxy. # Deploy the relay proxy -## Deploy in Kubernetes using Helm +## Deploy in Kubernetes using Helm + The relay proxy can be deployed in Kubernetes using a helm chart. Helm is an invaluable tool for configuring and deploying applications to a Kubernetes environment. @@ -27,8 +28,11 @@ helm repo add go-feature-flag https://charts.gofeatureflag.org/ ### Step 2: Install the Chart -Install the Helm Chart with the Helm install command and provide the custom repository name, the chart name and any necessary values files. -You can look at the [helm doc](https://github.com/thomaspoignant/go-feature-flag/blob/main/cmd/relayproxy/helm-charts/relay-proxy/README.md) to know exactly what you can change in the values.yaml file. +Install the Helm Chart with the Helm install command and provide the custom repository name, the chart name and any +necessary values files. +You can look at +the [helm doc](https://github.com/thomaspoignant/go-feature-flag/blob/main/cmd/relayproxy/helm-charts/relay-proxy/README.md) +to know exactly what you can change in the values.yaml file. ```shell helm install go-feature-flag/relay-proxy -f values.yaml @@ -43,6 +47,7 @@ helm list ``` ## Deploy as AWS Lambda + The GO Feature Flag relay proxy can easily be launched as an AWS Lambda function. To do this, simply set the `startAsAwsLambda` option in your configuration file to `true`, like so: @@ -51,16 +56,34 @@ To do this, simply set the `startAsAwsLambda` option in your configuration file startAsAwsLambda: true ``` -Once you've updated your configuration file, you can deploy your function in AWS and configure it to be accessible -via HTTP. This can be achieved by creating an API Gateway or an Application Load Balancer (ALB) and linking it to +Once you've updated your configuration file, you can deploy your function in AWS and configure it to be accessible +via HTTP. This can be achieved by creating an API Gateway or an Application Load Balancer (ALB) and linking it to your Lambda function. By configuring your GO Feature Flag relay proxy to run as an AWS Lambda function, you can take advantage of many -benefits of serverless computing, including automatic scaling, reduced infrastructure costs, and simplified +benefits of serverless computing, including automatic scaling, reduced infrastructure costs, and simplified deployment and management. :::info As part of our release process, we are building an archive ready to be deployed as AWS lambda. -You can find it in the [GitHub release page](https://github.com/thomaspoignant/go-feature-flag/releases),and you can use the assets named `go-feature-flag-aws-lambda_.zip`. +You can find it in the [GitHub release page](https://github.com/thomaspoignant/go-feature-flag/releases),and you can use +the assets named `go-feature-flag-aws-lambda_.zip`. ::: +### Choose the handler for your AWS Lambda + +Depending on what you put in front of your Lambda function, you will need to choose the right handler. +GO Feature Flag supports 3 different handlers: + +- `APIGatewayV1`: This handler is used when you put an API Gateway with the v1 format in front of your Lambda function. +- `APIGatewayV2`: This handler is used when you put an API Gateway with the v2 format in front of your Lambda function. +- `ALB`: This handler is used when you put an Application Load Balancer in front of your Lambda function. + +To choose the right handler, you need to set the `awsLambdaAdapter` option in your configuration file with one of this +value. If you don't set this option, the default value is `APIGatewayV2`. + +```yaml +# ... +startAsAwsLambda: true +awsLambdaAdapter: ALB +``` \ No newline at end of file