Skip to content

Conversation

@bhapas
Copy link
Contributor

@bhapas bhapas commented May 22, 2023

What does this PR do

This PR enables the terraform service deployer to generate terraform outputs and use them in the system test config to add terraform related data on agent policy config.

Why is this important

This enables the integrations developers to test aws-s3 input to use the terraform generated values like SQS queue_url in the system test config to run an agent to poll notifications from the underlying S3 bucket against the SQS Queue.

How to test this PR

A system test package aws_logs been created under test/packages/parallel.

  • Build elastic-package using make install
  • Run elastic-package stack up -d -v
  • Navigate to test/packages/parallel/aws_logs
  • export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY into the env variables
  • Run elastic-package install -v
  • Run elastic-package test -v

Screenshots

The queue_url is generated by terraform and added into agent policy config using handlebars template in system test config.

Screenshot 2023-05-24 at 13 47 14

Test Outputs

{
  "queue_url": {
    "sensitive": false,
    "type": "string",
    "value": "https://sqs.us-east-1.amazonaws.com/<ACCOUNT_ID>/elastic-package-aws-logs-queue-<TEST_RUN_ID>"
  },
  "triangle_output": {
    "sensitive": false,
    "type": [
      "object",
      {
        "description": "string",
        "s_one": "number",
        "s_three": "number",
        "s_two": "number"
      }
    ],
    "value": {
      "description": "this is a triangle",
      "s_one": 1,
      "s_three": 2.5,
      "s_two": 2.5
    }
  }
}

To access the variables in agent config

queue_url: {{TF_OUTPUT_queue_url}}

# Accessing complex Object outputs
test_variable_one: {{TF_OUTPUT_triangle_output.s_one}}
test_variable_two: {{TF_OUTPUT_triangle_output.s_two}}
test_variable_three: {{TF_OUTPUT_triangle_output.s_three}}

Related Issues

@bhapas bhapas self-assigned this May 24, 2023
@bhapas bhapas requested a review from jsoriano May 24, 2023 13:07
@bhapas bhapas requested a review from a team May 24, 2023 13:08
@bhapas bhapas changed the title Test terraform outputs Add Terraform Outputs to ServiceContext to use them in agent policy test config May 24, 2023
@bhapas bhapas added the enhancement New feature or request label May 24, 2023
@bhapas bhapas force-pushed the terraform-outputs-aws branch from bd2fad6 to 321503f Compare May 24, 2023 14:03
@bhapas bhapas requested a review from mrodm May 24, 2023 14:03
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. It wasn't too complicated to add. Most of the work was in testing.

@bhapas
Copy link
Contributor Author

bhapas commented May 31, 2023

/test

@bhapas bhapas requested a review from andrewkroh May 31, 2023 12:13
@bhapas bhapas requested a review from mrodm May 31, 2023 16:33
@bhapas bhapas force-pushed the terraform-outputs-aws branch from 09793f3 to 038d54a Compare May 31, 2023 16:39
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @bhapas

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.9-candidate enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants