Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable AWS endpoint #12369

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

- New options to configure roles and VPC. {pull}11779[11779]
- Export automation templates used to create functions. {pull}11923[11923]
- Configurable Amazon endpoint. {pull}12369[12369]

*Winlogbeat*

Expand Down
2 changes: 2 additions & 0 deletions x-pack/functionbeat/_meta/beat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# Configure functions to run on AWS Lambda, currently we assume that the credentials
# are present in the environment to correctly create the function when using the CLI.
#
# Configure which S3 endpoint should we use.
functionbeat.provider.aws.endpoint: "s3.amazonaws.com"
# Configure which S3 bucket we should upload the lambda artifact.
functionbeat.provider.aws.deploy_bucket: "functionbeat-deploy"

Expand Down
2 changes: 2 additions & 0 deletions x-pack/functionbeat/_meta/beat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Configure functions to run on AWS Lambda, currently we assume that the credentials
# are present in the environment to correctly create the function when using the CLI.
#
# Configure which S3 endpoint should we use.
functionbeat.provider.aws.endpoint: "s3.amazonaws.com"
# Configure which S3 bucket we should upload the lambda artifact.
functionbeat.provider.aws.deploy_bucket: "functionbeat-deploy"

Expand Down
7 changes: 7 additions & 0 deletions x-pack/functionbeat/docs/config-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ the events to {es}.

["source","sh",subs="attributes"]
----
{beatname_lc}.provider.aws.endpoint: "s3.amazonaws.com"
{beatname_lc}.provider.aws.deploy_bucket: "functionbeat-deploy"
{beatname_lc}.provider.aws.functions:
- name: cloudwatch
Expand Down Expand Up @@ -56,6 +57,12 @@ to deploy.
TIP: If you change the configuration after deploying the function, use
the <<update-command,`update` command>> to update your deployment.

[float]
[id="{beatname_lc}-endpoint"]
==== `provider.aws.endpoint`

AWS endpoint to use in the URL template to load functions.

[float]
[id="{beatname_lc}-deploy-bucket"]
==== `provider.aws.deploy_bucket`
Expand Down
1 change: 1 addition & 0 deletions x-pack/functionbeat/docs/getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ events from CloudWatch Logs and forwards the events to {es}.

["source","sh",subs="attributes"]
-------------------------------------------------------------------------------------
{beatname_lc}.provider.aws.endpoint: "s3.amazonaws.com"
{beatname_lc}.provider.aws.deploy_bucket: "functionbeat-deploy"
{beatname_lc}.provider.aws.functions:
- name: cloudwatch
Expand Down
2 changes: 2 additions & 0 deletions x-pack/functionbeat/functionbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# Configure functions to run on AWS Lambda, currently we assume that the credentials
# are present in the environment to correctly create the function when using the CLI.
#
# Configure which S3 endpoint should we use.
functionbeat.provider.aws.endpoint: "s3.amazonaws.com"
# Configure which S3 bucket we should upload the lambda artifact.
functionbeat.provider.aws.deploy_bucket: "functionbeat-deploy"

Expand Down
2 changes: 2 additions & 0 deletions x-pack/functionbeat/functionbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Configure functions to run on AWS Lambda, currently we assume that the credentials
# are present in the environment to correctly create the function when using the CLI.
#
# Configure which S3 endpoint should we use.
functionbeat.provider.aws.endpoint: "s3.amazonaws.com"
# Configure which S3 bucket we should upload the lambda artifact.
functionbeat.provider.aws.deploy_bucket: "functionbeat-deploy"

Expand Down
1 change: 1 addition & 0 deletions x-pack/functionbeat/provider/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

// Config expose the configuration option the AWS provider.
type Config struct {
Endpoint string `config:"endpoint" validate:"nonzero,required"`
DeployBucket bucket `config:"deploy_bucket" validate:"nonzero,required"`
}

Expand Down
4 changes: 3 additions & 1 deletion x-pack/functionbeat/provider/aws/template_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type templateData struct {
type defaultTemplateBuilder struct {
provider provider.Provider
log *logp.Logger
endpoint string
bucket string
}

Expand All @@ -53,6 +54,7 @@ func NewTemplateBuilder(log *logp.Logger, cfg *common.Config, p provider.Provide
return &defaultTemplateBuilder{
provider: p,
log: log,
endpoint: config.Endpoint,
bucket: string(config.DeployBucket),
}, nil
}
Expand Down Expand Up @@ -101,7 +103,7 @@ func (d *defaultTemplateBuilder) execute(name string) (templateData, error) {

templateChecksum := checksum(templateJSON)
templateKey := keyPrefix + name + "/" + templateChecksum + "/cloudformation-template-create.json"
templateURL := "https://" + d.bucket + "s3.amazonaws.com/" + templateKey
templateURL := "https://" + d.bucket + "." + d.endpoint + "/" + templateKey

return templateData{
json: templateJSON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ functionbeat.provider.local:
{% endif %}

{% if cloudwatch %}
functionbeat.provider.aws.endpoint: {{ cloudwatch.endpoint | default("s3.amazonaws.com") }}
functionbeat.provider.aws.deploy_bucket: {{ cloudwatch.bucket | default("functionbeat-deploy") }}
functionbeat.provider.aws.functions:
- name: {{ cloudwatch.name }}
Expand Down
7 changes: 3 additions & 4 deletions x-pack/functionbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_base(self):
exit_code = functionbeat_proc.kill_and_wait()
assert exit_code == 0

def test_export_function_template(self):
def test_export_function(self):
"""
Test if the template can be exported
"""
Expand Down Expand Up @@ -56,8 +56,7 @@ def test_export_function_template(self):
)

self.wait_until(lambda: self.log_contains("PASS"))
exit_code = functionbeat_proc.kill_and_wait()
assert exit_code == 0
functionbeat_proc.check_wait()

function_template = self._get_generated_function_template()
function_properties = function_template["Resources"][fnb_name]["Properties"]
Expand All @@ -68,7 +67,7 @@ def test_export_function_template(self):
assert function_properties["VpcConfig"]["SecurityGroupIds"] == security_group_ids
assert function_properties["VpcConfig"]["SubnetIds"] == subnet_ids

def test_export_function_template_with_invalid_configuration(self):
def test_export_function_invalid_conf(self):
"""
Test if invalid configuration is exportable
"""
Expand Down