Skip to content

Commit 48d2c87

Browse files
authored
switch null_resource to external for helm installation (aws#553)
1 parent 2cdae91 commit 48d2c87

2 files changed

Lines changed: 19 additions & 26 deletions

File tree

terraform/eks/daemon/credentials/pod_identity/main.tf

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,13 @@ resource "aws_security_group_rule" "nodes_cluster_inbound" {
194194
type = "ingress"
195195
}
196196

197-
resource "null_resource" "clone_helm_chart" {
198-
triggers = {
199-
timestamp = "${timestamp()}" # Forces re-run on every apply
200-
}
201-
provisioner "local-exec" {
202-
command = <<-EOT
203-
if [ ! -d "./helm-charts" ]; then
204-
git clone -b ${var.helm_chart_branch} https://github.com/aws-observability/helm-charts.git ./helm-charts
205-
fi
206-
EOT
207-
}
197+
data "external" "clone_helm_chart" {
198+
program = ["bash", "-c", <<-EOT
199+
rm -rf ./helm-charts
200+
git clone -b ${var.helm_chart_branch} https://github.com/aws-observability/helm-charts.git ./helm-charts
201+
echo '{"status":"ready"}'
202+
EOT
203+
]
208204
}
209205

210206
resource "helm_release" "aws_observability" {
@@ -220,15 +216,15 @@ resource "helm_release" "aws_observability" {
220216
},
221217
{
222218
name = "region"
223-
value = "us-west-2"
219+
value = var.region
224220
}
225221
]
226222
depends_on = [
227223
aws_eks_cluster.this,
228224
aws_eks_node_group.this,
229-
null_resource.clone_helm_chart,
230225
aws_eks_addon.pod_identity_addon,
231226
aws_eks_pod_identity_association.association,
227+
data.external.clone_helm_chart,
232228
]
233229
}
234230

terraform/eks/daemon/entity/main.tf

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,13 @@ resource "aws_security_group_rule" "nodes_cluster_inbound" {
163163
type = "ingress"
164164
}
165165

166-
resource "null_resource" "clone_helm_chart" {
167-
triggers = {
168-
timestamp = "${timestamp()}" # Forces re-run on every apply
169-
}
170-
provisioner "local-exec" {
171-
command = <<-EOT
172-
if [ ! -d "./helm-charts" ]; then
173-
git clone -b ${var.helm_chart_branch} https://github.com/aws-observability/helm-charts.git ./helm-charts
174-
fi
175-
EOT
176-
}
166+
data "external" "clone_helm_chart" {
167+
program = ["bash", "-c", <<-EOT
168+
rm -rf ./helm-charts
169+
git clone -b ${var.helm_chart_branch} https://github.com/aws-observability/helm-charts.git ./helm-charts
170+
echo '{"status":"ready"}'
171+
EOT
172+
]
177173
}
178174

179175
resource "helm_release" "aws_observability" {
@@ -188,13 +184,14 @@ resource "helm_release" "aws_observability" {
188184
},
189185
{
190186
name = "region"
191-
value = "us-west-2"
187+
value = var.region
192188
}
193189
]
194190
depends_on = [
195191
aws_eks_cluster.this,
196192
aws_eks_node_group.this,
197-
null_resource.clone_helm_chart]
193+
data.external.clone_helm_chart,
194+
]
198195
}
199196

200197
resource "null_resource" "kubectl" {

0 commit comments

Comments
 (0)