Skip to content

Commit

Permalink
Fix localstack integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
bhapas committed Jul 10, 2023
1 parent 5a81733 commit 887bdf0
Show file tree
Hide file tree
Showing 10 changed files with 422 additions and 712 deletions.
4 changes: 2 additions & 2 deletions x-pack/filebeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
depends_on:
elasticsearch: { condition: service_healthy }
cometd: { condition: service_healthy }
localstack: { condition: service_healthy }

elasticsearch:
extends:
Expand All @@ -26,13 +27,12 @@ services:
- 8080:8080

localstack:
container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
image: localstack/localstack
hostname: localhost
ports:
- "4566:4566" # LocalStack Gateway
environment:
- SERVICES=sqs,sns,secretsmanager
- SERVICES=s3,sqs,sns,secretsmanager
- DEBUG=1
- DOCKER_HOST=unix:///var/run/docker.sock
- HOST_TMP_FOLDER=${TMPDIR}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/awss3/_meta/terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
terraform/
outputs.yml
outputs*.yml
*.tfstate*
90 changes: 90 additions & 0 deletions x-pack/filebeat/input/awss3/_meta/terraform/localstack.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
provider "aws" {
alias = "localstack"
access_key = "bharat"
secret_key = "bharat"
region = "us-east-1"
s3_use_path_style = true
skip_credentials_validation = true
skip_metadata_api_check = true
skip_requesting_account_id = true
// s3_force_path_style = true

endpoints {
apigateway = "http://localhost:4566"
apigatewayv2 = "http://localhost:4566"
cloudformation = "http://localhost:4566"
cloudwatch = "http://localhost:4566"
dynamodb = "http://localhost:4566"
ec2 = "http://localhost:4566"
es = "http://localhost:4566"
elasticache = "http://localhost:4566"
firehose = "http://localhost:4566"
iam = "http://localhost:4566"
kinesis = "http://localhost:4566"
lambda = "http://localhost:4566"
rds = "http://localhost:4566"
redshift = "http://localhost:4566"
route53 = "http://localhost:4566"
s3 = "http://localhost:4566"
secretsmanager = "http://localhost:4566"
ses = "http://localhost:4566"
sns = "http://localhost:4566"
sqs = "http://localhost:4566"
ssm = "http://localhost:4566"
stepfunctions = "http://localhost:4566"
sts = "http://localhost:4566"
}
}

resource "random_string" "random_localstack" {
length = 6
special = false
upper = false
}

resource "aws_s3_bucket" "filebeat-integtest-localstack" {
provider = aws.localstack
bucket = "filebeat-s3-integtest-localstack-${random_string.random_localstack.result}"
force_destroy = true
}

resource "aws_sqs_queue" "filebeat-integtest-localstack" {
provider = aws.localstack
name = "filebeat-sqs-integtest-localstack-${random_string.random_localstack.result}"
policy = <<POLICY
{
"Version": "2012-10-17",
"Id": "sqspolicy",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "sqs:SendMessage",
"Resource": "arn:aws:sqs:*:*:filebeat-sqs-integtest-localstack-${random_string.random_localstack.result}",
"Condition": {
"ArnEquals": { "aws:SourceArn": "${aws_s3_bucket.filebeat-integtest-localstack.arn}" }
}
}
]
}
POLICY

depends_on = [
aws_s3_bucket.filebeat-integtest-localstack,
]
}

resource "aws_s3_bucket_notification" "bucket_notification-localstack" {
provider = aws.localstack
bucket = aws_s3_bucket.filebeat-integtest-localstack.id

queue {
queue_arn = aws_sqs_queue.filebeat-integtest-localstack.arn
events = ["s3:ObjectCreated:*"]
}

depends_on = [
aws_s3_bucket.filebeat-integtest-localstack,
aws_sqs_queue.filebeat-integtest-localstack,
]
}
Loading

0 comments on commit 887bdf0

Please sign in to comment.