# ------------------------------------------------------------------------ # Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License is located at # # http://www.apache.org/licenses/LICENSE-2.0 # # or in the "license" file accompanying this file. This file is distributed # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either # express or implied. See the License for the specific language governing # permissions and limitations under the License. # ------------------------------------------------------------------------- variable "ami_family" { default = { debian = { login_user = "ubuntu" install_package = "aws-otel-collector.deb" instance_type = "c5a.large" 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" 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" user_data = "" wait_cloud_init = "for i in {1..300}; do [ ! -f /var/lib/cloud/instance/boot-finished ] && echo 'Waiting for cloud-init...'$i && sleep 1 || break; done" } linux = { login_user = "ec2-user" install_package = "aws-otel-collector.rpm" instance_type = "c5a.large" 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" 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" user_data = "" wait_cloud_init = "for i in {1..300}; do [ ! -f /var/lib/cloud/instance/boot-finished ] && echo 'Waiting for cloud-init...'$i && sleep 1 || break; done" } windows = { login_user = "Administrator" install_package = "aws-otel-collector.msi" instance_type = "c5a.large" 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}\"" 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" user_data = < winrm quickconfig -q winrm set winrm/config/winrs '@{MaxShellsPerUser="100"}' winrm set winrm/config/winrs '@{MaxConcurrentUsers="30"}' winrm set winrm/config/winrs '@{MaxProcessesPerShell="100"}' winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' winrm set winrm/config '@{MaxTimeoutms="1800000"}' winrm set winrm/config/service '@{AllowUnencrypted="true"}' winrm set winrm/config/service/auth '@{Basic="true"}' netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow net stop winrm sc.exe config winrm start=auto net start winrm Set-NetFirewallProfile -Profile Public -Enabled False EOF wait_cloud_init = " " } } } ######################################## ## define the amis to test collector ## ## ## os_family, which will be used to construct the downloading url of collector on s3 ## ami_search_pattern, which will be used to search the amis from aws ## ami_owner, could be "amazon", "aws-marketplace", or a dedicated account number, for example, redhat amis are distributed by this account 309956199498(Redhat Inc) ## family, could be "linux", "debian", "windows" ## arch, which will be used to construct the downloading url of collector on s3 ## login_user, which will be taken first, if null then the take from family. ######################################## variable "amis" { default = { # Ubuntu Distribution ubuntu18 = { os_family = "ubuntu" ami_search_pattern = "ubuntu/images/hvm-ssd/ubuntu-bionic-*" ami_owner = "amazon" ami_product_code = [] family = "debian" arch = "amd64" login_user = "ubuntu" user_data = <