Skip to content

Commit 24f3d78

Browse files
committed
Merge pull request #1767 from vasireddy99/featureflag
[dev] Use feature flag in the start command
1 parent 0a42d59 commit 24f3d78

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

terraform/ec2/amis.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ variable "ami_family" {
2222
otconfig_destination = "/tmp/ot-default.yml"
2323
download_command_pattern = "wget %s"
2424
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"
25-
start_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -c \"$(echo -n 'CONFIGURATION_URI_PLACEHOLDER' | base64 -d)\" -a start"
25+
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"
2626
status_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a status"
2727
ssm_validate = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a status | grep running"
2828
connection_type = "ssh"
@@ -36,7 +36,7 @@ variable "ami_family" {
3636
otconfig_destination = "/tmp/ot-default.yml"
3737
download_command_pattern = "curl %s --output aws-otel-collector.rpm"
3838
install_command = "sudo rpm -Uvh aws-otel-collector.rpm"
39-
start_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -c \"$(echo -n 'CONFIGURATION_URI_PLACEHOLDER' | base64 -d)\" -a start"
39+
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"
4040
status_command = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a status"
4141
ssm_validate = "sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a status | grep running"
4242
connection_type = "ssh"
@@ -50,7 +50,7 @@ variable "ami_family" {
5050
otconfig_destination = "C:\\ot-default.yml"
5151
download_command_pattern = "powershell -command \"Invoke-WebRequest -Uri %s -OutFile C:\\aws-otel-collector.msi\""
5252
install_command = "msiexec /i C:\\aws-otel-collector.msi"
53-
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}\""
53+
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}\""
5454
status_command = "powershell \"& 'C:\\Program Files\\Amazon\\AwsOtelCollector\\aws-otel-collector-ctl.ps1' -Action status\""
5555
ssm_validate = "powershell \"& 'C:\\Program Files\\Amazon\\AwsOtelCollector\\aws-otel-collector-ctl.ps1' -Action status\" | findstr running"
5656
connection_type = "winrm"

terraform/ec2/main.tf

+13-1
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,21 @@ resource "null_resource" "collector_file_configuration" {
303303

304304
locals {
305305
configuration_uri = var.configuration_source == "file" ? local.otconfig_destination : module.remote_configuration[0].configuration_uri
306+
// adding default if none provided
307+
feature_gates = var.otconfig_args == [] ? ["--feature-gates=-adot.exporter.datadogexporter.deprecation"][0] : split("--feature-gates=", var.otconfig_args[0])[1]
306308
// encode the uri used during tests to base64 to avoid problems while this string is sent across the wire on windows.
307309
// we are normalizing this behavior across all operating systems.
308-
start_command = replace(local.ami_family["start_command"], "CONFIGURATION_URI_PLACEHOLDER", base64encode(local.configuration_uri))
310+
command_with_config = replace(
311+
local.ami_family["start_command"],
312+
"CONFIGURATION_URI_PLACEHOLDER",
313+
base64encode(local.configuration_uri)
314+
)
315+
316+
start_command = replace(
317+
local.command_with_config,
318+
"FEATUREGATE_PLACEHOLDER",
319+
local.feature_gates
320+
)
309321
}
310322

311323
resource "null_resource" "start_collector" {

terraform/ec2/variables.tf

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ variable "kafka_version" {
136136
default = ""
137137
}
138138

139+
variable "otconfig_args" {
140+
default = []
141+
}
142+
139143
// Source of the collector configuration: file, s3, http and https
140144
variable "configuration_source" {
141145
default = "file"

0 commit comments

Comments
 (0)