Skip to content

Commit 295d090

Browse files
committed
Refactor 1: Do not install AWS
1 parent 1446f28 commit 295d090

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

modules/tfe_init_replicated/functions.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
locals {
55
get_base64_secrets = templatefile("${path.module}/templates/get_base64_secrets.func", {
66
cloud = var.cloud
7+
distribution = var.distribution
78
})
89

910
install_packages = templatefile("${path.module}/templates/install_packages.func", {

modules/tfe_init_replicated/templates/get_base64_secrets.func

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ function get_base64_secrets {
1111

1212
%{ if cloud == "aws" ~}
1313
function get_base64_secrets {
14-
# Description: Pull the Base 64 encoded secrets from AWS Secrets Manager
1514
local secret_id=$1
16-
# OS: Agnostic
17-
/usr/local/bin/aws secretsmanager get-secret-value --secret-id $secret_id | jq --raw-output '.SecretBinary,.SecretString | select(. != null)'
15+
%{ if distribution == "amazon-linux-2023" ~}
16+
# Amazon Linux 2023 already has AWS installed on the machine
17+
aws secretsmanager get-secret-value --secret-id $secret_id | jq --raw-output '.SecretBinary,.SecretString | select(. != null)'
18+
%{ else ~}
19+
# OS: Agnostic
20+
# Description: Pull the Base 64 encoded secrets from AWS Secrets Manager
21+
/usr/local/bin/aws secretsmanager get-secret-value --secret-id $secret_id | jq --raw-output '.SecretBinary,.SecretString | select(. != null)'
22+
%{ endif ~}
1823
}
1924
%{ endif ~}
2025

modules/tfe_init_replicated/templates/install_packages.func

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ function install_packages {
3636
%{ endif ~}
3737
%{ endif ~}
3838

39-
echo "[$(date +"%FT%T")] [Terraform Enterprise] Install AWS CLI" | tee -a $log_pathname
40-
curl --noproxy '*' "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
41-
unzip awscliv2.zip
42-
./aws/install
43-
rm -f ./awscliv2.zip
44-
rm -rf ./aws
39+
# Amazon Linux 2023 already has AWS installed on the machine so no need to install it there.
40+
%{ if distribution != "amazon-linux-2023" ~}
41+
echo "[$(date +"%FT%T")] [Terraform Enterprise] Install AWS CLI" | tee -a $log_pathname
42+
curl --noproxy '*' "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
43+
unzip awscliv2.zip
44+
./aws/install
45+
rm -f ./awscliv2.zip
46+
rm -rf ./aws
47+
%{ endif ~}
4548
}
4649
%{ endif ~}
4750

0 commit comments

Comments
 (0)