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

run test #32

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
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 $(whoami).txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
22 changes: 17 additions & 5 deletions .github/workflows/Changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- "modules/**"


jobs:
get-label:
runs-on: ubuntu-latest
Expand All @@ -23,14 +24,24 @@ jobs:
needs: get-label
name: Check changelog update
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37

- name: Move integrations files
uses: tj-actions/changed-files@v41
with:
safe_output: true

- name: List all added files
env:
ADDED_FILES: ${{ steps.changed-files.outputs.added_files }}
run: |
for file in "$ADDED_FILES"; do
echo "$file was added"
done

- name: check changelog
run: |
changed_files_string="${{ steps.changed-files.outputs.all_changed_files }}"
read -ra changed_files_array <<< "$changed_files_string"
Expand All @@ -39,4 +50,5 @@ jobs:
if [[ "$changed_file" == *"/main.tf" ]] && [[ "$changed_file" != "examples"* ]]; then
./changelog_check.sh $(dirname $changed_file)
fi
done
done

76 changes: 68 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,20 @@ jobs:
fi
fi

- name: Configure AWS credentials
env:
AWS_ACCESS_KEY_ID: ${{ secrets.TESTING_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.TESTING_SECRET_ACCESS_KEY }}
run: |
echo "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" >> $GITHUB_ENV

# - name: Configure AWS credentials
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.TESTING_ACCESS_KEY }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.TESTING_SECRET_ACCESS_KEY }}
# run: |
# echo "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" >> $GITHUB_ENV
# echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" >> $GITHUB_ENV

- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.TESTING_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TESTING_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Terraform init
run: |
if [[ ${{ matrix.package }} != "locals_variables" ]];then
Expand All @@ -93,4 +99,58 @@ jobs:
terraform plan
fi

- name: Terraform apply
continue-on-error: true
run: |
if [[ ${{ matrix.package }} != "locals_variables" ]]; then
cd "tests/${{ matrix.package }}"
terraform apply -auto-approve
fi
- name: Terraform apply
run: |
if [[ ${{ matrix.package }} != "locals_variables" ]]; then
cd "tests/${{ matrix.package }}"
terraform apply -auto-approve
fi

- name: Add Sleep Before Step
run: sleep 20s

- name: send log to log group
continue-on-error: true
run: |
aws logs put-log-events \
--log-group-name "gr-test" --log-stream-name "test2" \
--log-events "[{\"timestamp\": $(date +%s)000, \"message\": \"This is a log message sent to CloudWatch.\"}]"

- name: Add Sleep Before Step
run: sleep 20s

- name: Validate Lambda Function
continue-on-error: true
run: |
logGroupName=$(aws logs describe-log-groups --log-group-name-prefix '/aws/lambda/Coralogix-CloudWatch-' --query 'logGroups[-1].logGroupName' --output text)
echo $logGroupName
aws logs filter-log-events \
--log-group-name $logGroupName \
--filter-pattern "ERROR"

- name: Add Sleep Before Step
run: sleep 100s

- name: Terraform destroy
continue-on-error: true
run: |
if [[ ${{ matrix.package }} != "locals_variables" ]];then
cd "tests/${{ matrix.package }}"
terraform destroy -auto-approve
fi
- name: Terraform destroy in case of an error
run: |
if [[ ${{ matrix.package }} != "locals_variables" ]];then
cd "tests/${{ matrix.package }}"
terraform destroy -auto-approve
fi



2 changes: 2 additions & 0 deletions modules/cloudwatch-logs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## cloudwatch-logs



### 0.0.3 / 16.8.2023
* [Update] Add an option to use an existing secret instead of creating a new one with SSM, and remove ssm_enabled variable.

Expand Down
1 change: 1 addition & 0 deletions modules/cloudwatch-logs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ data "aws_cloudwatch_log_group" "this" {
name = element(var.log_groups, count.index)
}


resource "random_string" "this" {
length = 12
special = false
Expand Down
15 changes: 11 additions & 4 deletions modules/firehose/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ locals {
terraform-module = "kinesis-firehose-to-coralogix"
terraform-module-version = "v0.1.0"
managed-by = "coralogix-terraform"
custom_endpoint = var.coralogix_firehose_custom_endpoint != null ? var.coralogix_firehose_custom_endpoint : ""
custom_endpoint = var.coralogix_firehose_custom_endpoint != null ? var.coralogix_firehose_custom_endpoint : "_default_"
})

# default namings
Expand Down Expand Up @@ -137,6 +137,7 @@ resource "aws_iam_role" "firehose_to_coralogix" {
}
}


################################################################################
# Firehose Logs Stream
################################################################################
Expand Down Expand Up @@ -239,10 +240,10 @@ resource "aws_iam_role_policy_attachment" "additional_policy_attachment_2" {
# Firehose Metrics Stream
################################################################################

resource "aws_iam_role_policy" "firehose_to_coralogix_metric_policy" {
resource "aws_iam_policy" "firehose_to_coralogix_metric_policy" {
count = var.metric_enable == true ? 1 : 0
name = "${var.firehose_stream}-metrics-addon"
role = aws_iam_role.firehose_to_coralogix.id
name = "${var.firehose_stream}-metrics-policy"
tags = local.tags
policy = <<EOF
{
"Version": "2012-10-17",
Expand Down Expand Up @@ -313,6 +314,12 @@ resource "aws_iam_role_policy" "firehose_to_coralogix_metric_policy" {
EOF
}

resource "aws_iam_role_policy_attachment" "firehose_to_coralogix_metric_policy" {
count = var.metric_enable == true ? 1 : 0
policy_arn = aws_iam_policy.firehose_to_coralogix_metric_policy[count.index].arn
role = aws_iam_role.firehose_to_coralogix.name
}

data "aws_iam_policy_document" "lambda_assume_role" {
count = var.metric_enable == true ? 1 : 0
statement {
Expand Down
2 changes: 1 addition & 1 deletion tests/cloudwatch-logs/cloudwatch-logs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ module "cloudwatch" {
private_key = "{{ secrets.TESTING_PRIVATE_KEY }}"
application_name = "cloudwatch-logs"
subsystem_name = "logs"
log_groups = ["github-action-testing-log-stream"]
log_groups = ["gr-test"]
}
Loading