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

Updating Dev Branch #1771

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 3 additions & 3 deletions terraform/ec2/amis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ variable "ami_family" {
otconfig_destination = "/tmp/ot-default.yml"
download_command_pattern = "wget %s"
install_command = "while sudo fuser /var/cache/apt/archives/lock /var/lib/apt/lists/lock /var/lib/dpkg/lock /var/lib/dpkg/lock-frontend; do echo 'Waiting for dpkg lock...' && sleep 1; done; echo 'No dpkg lock and install collector.' && sudo dpkg -i aws-otel-collector.deb"
start_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -c \"$(echo -n 'CONFIGURATION_URI_PLACEHOLDER' | base64 -d)\" -a start"
start_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -c \"$(echo -n 'CONFIGURATION_URI_PLACEHOLDER' | base64 -d)\" -f FEATUREGATE_PLACEHOLDER -a start"
status_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a status"
ssm_validate = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a status | grep running"
connection_type = "ssh"
Expand All @@ -36,7 +36,7 @@ variable "ami_family" {
otconfig_destination = "/tmp/ot-default.yml"
download_command_pattern = "curl %s --output aws-otel-collector.rpm"
install_command = "sudo rpm -Uvh aws-otel-collector.rpm"
start_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -c \"$(echo -n 'CONFIGURATION_URI_PLACEHOLDER' | base64 -d)\" -a start"
start_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -c \"$(echo -n 'CONFIGURATION_URI_PLACEHOLDER' | base64 -d)\" -f FEATUREGATE_PLACEHOLDER -a start"
status_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a status"
ssm_validate = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a status | grep running"
connection_type = "ssh"
Expand All @@ -50,7 +50,7 @@ variable "ami_family" {
otconfig_destination = "C:\\ot-default.yml"
download_command_pattern = "powershell -command \"Invoke-WebRequest -Uri %s -OutFile C:\\aws-otel-collector.msi\""
install_command = "msiexec /i C:\\aws-otel-collector.msi"
start_command = "powershell -command \"&{ $url = \\\"$([System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String('CONFIGURATION_URI_PLACEHOLDER')))\\\"; . 'C:\\Program Files\\Amazon\\AwsOtelCollector\\aws-otel-collector-ctl.ps1' -ConfigLocation \\\"$url\\\" -Action start}\""
start_command = "powershell -command \"&{ $url = \\\"$([System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String('CONFIGURATION_URI_PLACEHOLDER')))\\\"; . 'C:\\Program Files\\Amazon\\AwsOtelCollector\\aws-otel-collector-ctl.ps1' -ConfigLocation \\\"$url\\\" -FeatureGates FEATUREGATE_PLACEHOLDER -Action start}\""
status_command = "powershell \"& 'C:\\Program Files\\Amazon\\AwsOtelCollector\\aws-otel-collector-ctl.ps1' -Action status\""
ssm_validate = "powershell \"& 'C:\\Program Files\\Amazon\\AwsOtelCollector\\aws-otel-collector-ctl.ps1' -Action status\" | findstr running"
connection_type = "winrm"
Expand Down
15 changes: 13 additions & 2 deletions terraform/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,21 @@ resource "null_resource" "collector_file_configuration" {

locals {
configuration_uri = var.configuration_source == "file" ? local.otconfig_destination : module.remote_configuration[0].configuration_uri
// adding default if none provided
feature_gates = var.otconfig_args == [] ? ["-adot.exporter.datadogexporter.deprecation"][0] : split("--feature-gates=", var.otconfig_args[0])[1]
// encode the uri used during tests to base64 to avoid problems while this string is sent across the wire on windows.
// we are normalizing this behavior across all operating systems.
start_command = replace(local.ami_family["start_command"], "CONFIGURATION_URI_PLACEHOLDER", base64encode(local.configuration_uri))
command_with_config = replace(
local.ami_family["start_command"],
"CONFIGURATION_URI_PLACEHOLDER",
base64encode(local.configuration_uri)
)

start_command = replace(
local.command_with_config,
"FEATUREGATE_PLACEHOLDER",
local.feature_gates
)
}

resource "null_resource" "start_collector" {
Expand Down Expand Up @@ -527,4 +539,3 @@ resource "null_resource" "ssm_canary_metrics" {
output "public_ip" {
value = aws_instance.aoc.public_ip
}

4 changes: 4 additions & 0 deletions terraform/ec2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ variable "kafka_version" {
default = ""
}

variable "otconfig_args" {
default = []
}

// Source of the collector configuration: file, s3, http and https
variable "configuration_source" {
default = "file"
Expand Down
Loading