Skip to content

Commit 0fae1f7

Browse files
authored
Add documentation how to test packages with Serverless (#2520)
1 parent 98bdb8f commit 0fae1f7

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ You can customize your stack using profile settings, see [Elastic Package profil
517517
There are different providers supported, that can be selected with the --provider flag.
518518
- compose: Starts a local stack using Docker Compose. This is the default.
519519
- environment: Prepares an existing stack to be used to test packages. Missing components are started locally using Docker Compose. Environment variables are used to configure the access to the existing Elasticsearch and Kibana instances. You can learn more about this in [this document](./docs/howto/use_existing_stack.md).
520-
- serverless: Uses Elastic Cloud to start a serverless project. Requires an Elastic Cloud API key.
520+
- serverless: Uses Elastic Cloud to start a serverless project. Requires an Elastic Cloud API key. You can learn more about this in [this document](./docs/howto/use_serverless_stack.md).
521521

522522
### `elastic-package stack update`
523523

cmd/stack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ You can customize your stack using profile settings, see [Elastic Package profil
5252
There are different providers supported, that can be selected with the --provider flag.
5353
- compose: Starts a local stack using Docker Compose. This is the default.
5454
- environment: Prepares an existing stack to be used to test packages. Missing components are started locally using Docker Compose. Environment variables are used to configure the access to the existing Elasticsearch and Kibana instances. You can learn more about this in [this document](./docs/howto/use_existing_stack.md).
55-
- serverless: Uses Elastic Cloud to start a serverless project. Requires an Elastic Cloud API key.`
55+
- serverless: Uses Elastic Cloud to start a serverless project. Requires an Elastic Cloud API key. You can learn more about this in [this document](./docs/howto/use_serverless_stack.md).`
5656

5757
const stackShellinitLongDescription = `Use this command to export to the current shell the configuration of the stack managed by elastic-package.
5858

docs/howto/use_serverless_stack.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# HOWTO: Use `elastic-package` to test packages using a Serverless project
2+
3+
## Introduction
4+
5+
`elastic-package` supports creating a new Serverless project to assist developers in testing their own packages in these offerings.
6+
7+
**Please note:** Testing packages using this method may result in additional charges.
8+
9+
10+
### The `serverless` stack provider
11+
12+
The `serverless` provider facilitates the creation and management of a Serverless project, running the Elastic Agent and other services as local containers using Docker compose.
13+
14+
To use the `serverless` provider, follow these steps:
15+
1. Obtain an API key from [Elastic Cloud API keys](https://cloud.elastic.co/account/keys).
16+
2. Set the environment variable `EC_API_KEY` with the obtained API key:
17+
```shell
18+
export EC_API_KEY=<api_key>
19+
```
20+
3. (Recommended) Create a new elastic-package profile for serverless:
21+
```shell
22+
elastic-package profiles create serverless
23+
elastic-package profiles use serverless
24+
```
25+
4. Update the profile configuration with the following keys (e.g. `~/.elastic-package/profiles/serverless/config.yml`):
26+
```yaml
27+
stack.elastic_cloud.host: https://cloud.elastic.co
28+
# supported observability and security types
29+
stack.serverless.type: observability
30+
stack.serverless.region: aws-us-east-1
31+
```
32+
33+
After completing these steps, create a new Elastic Serverless project by running:
34+
```sh
35+
elastic-package stack up -v -d --provider serverless
36+
```
37+
38+
Once this command finishes successfully, your environment will be ready to use
39+
any `elastic-package` subcommand (`install`, `dump`, `test`, ...) targeting the Serverless project created with the above command.
40+
41+
To clean up everything, run:
42+
```sh
43+
elastic-package stack down -v
44+
```
45+
46+
**Recommendation:** Ensure that Serverless projects are properly deleted upon completion of testing to avoid any unexpected charges.
47+
48+
Although Serverless projects are accessible through the management UI at [Elastic Cloud Projects](https://cloud.elastic.co/projects),
49+
those projects created by `elastic-package` must be deleted using the `stack down` command as previously mentioned.
50+
This procedure ensures that all resources and local configurations are cleaned up correctly, thereby allowing `elastic-package` to function
51+
correctly in subsequent commands.
52+
53+
If you need to switch back to a local stack, remember to change to the previous profile. If the previous profile was `default`, run:
54+
```shell
55+
elastic-package profiles use default
56+
```
57+
58+
### Considerations about testing with the `serverless` provider
59+
60+
There are some known issues when running pipeline tests with the `serverless` provider.
61+
62+
In Serverless projects, the GeoIP database cannot be modified as it is done with local stack.
63+
To avoid errors related to those GeoIP fields in these tests, the results from
64+
pipeline tests should not be compared. This can be achieved by setting the following environment variable:
65+
```shell
66+
export ELASTIC_PACKAGE_SERVERLESS_PIPELINE_TEST_DISABLE_COMPARE_RESULTS=true
67+
```
68+
69+
### How to use an existing `Serverless` project
70+
71+
In case you want to test your packages using an already existing Serverless project, it could be used
72+
the `environment` provider instead.
73+
You can learn more about this in [this document](https://github.com/elastic/elastic-package/blob/main/docs/howto/use_existing_stack.md).
74+
75+
**IMPORTANT**: This provider modifies the Fleet configuration of the target stack.
76+
Avoid using it in environments that you use for other purposes, specially in production environments

0 commit comments

Comments
 (0)