File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
210206resource "helm_release" "aws_observability" {
@@ -213,21 +209,22 @@ resource "helm_release" "aws_observability" {
213209 namespace = " amazon-cloudwatch"
214210 create_namespace = true
215211
216- set {
217- name = " clusterName"
218- value = aws_eks_cluster.this.name
219- }
220-
221- set {
222- name = " region"
223- value = " us-west-2"
224- }
212+ set = [
213+ {
214+ name = " clusterName"
215+ value = aws_eks_cluster.this.name
216+ },
217+ {
218+ name = " region"
219+ value = var.region
220+ }
221+ ]
225222 depends_on = [
226223 aws_eks_cluster . this ,
227224 aws_eks_node_group . this ,
228- null_resource. clone_helm_chart ,
229225 aws_eks_addon . pod_identity_addon ,
230226 aws_eks_pod_identity_association . association ,
227+ data . external . clone_helm_chart ,
231228 ]
232229}
233230
Original file line number Diff line number Diff line change @@ -17,10 +17,10 @@ provider "kubernetes" {
1717}
1818
1919provider "helm" {
20- kubernetes {
20+ kubernetes = {
2121 host = aws_eks_cluster.this.endpoint
2222 cluster_ca_certificate = base64decode (aws_eks_cluster. this . certificate_authority . 0 . data )
23- exec {
23+ exec = {
2424 api_version = " client.authentication.k8s.io/v1beta1"
2525 args = [" eks" , " get-token" , " --cluster-name" , aws_eks_cluster.this.name]
2626 command = " aws"
Original file line number Diff line number Diff line change @@ -163,38 +163,35 @@ 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
179175resource "helm_release" "aws_observability" {
180176 name = " amazon-cloudwatch-observability"
181177 chart = " ./helm-charts/charts/amazon-cloudwatch-observability"
182178 namespace = " amazon-cloudwatch"
183179 create_namespace = true
184-
185- set {
186- name = " clusterName"
187- value = aws_eks_cluster.this.name
188- }
189-
190- set {
191- name = " region"
192- value = " us-west-2 "
193- }
180+ set = [
181+ {
182+ name = " clusterName"
183+ value = aws_eks_cluster.this.name
184+ },
185+ {
186+ name = " region "
187+ value = var. region
188+ }
189+ ]
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
200197resource "null_resource" "kubectl" {
Original file line number Diff line number Diff line change @@ -17,10 +17,10 @@ provider "kubernetes" {
1717}
1818
1919provider "helm" {
20- kubernetes {
20+ kubernetes = {
2121 host = aws_eks_cluster.this.endpoint
2222 cluster_ca_certificate = base64decode (aws_eks_cluster. this . certificate_authority . 0 . data )
23- exec {
23+ exec = {
2424 api_version = " client.authentication.k8s.io/v1beta1"
2525 args = [" eks" , " get-token" , " --cluster-name" , aws_eks_cluster.this.name]
2626 command = " aws"
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ resource "aws_eks_node_group" "this" {
4747 min_size = 1
4848 }
4949
50- ami_type = " AL2_x86_64"
50+ ami_type = var . k8s_version >= " 1.33 " ? " AL2023_x86_64_STANDARD " : " AL2_x86_64"
5151 capacity_type = " ON_DEMAND"
5252 disk_size = 20
5353 instance_types = [" t3.medium" ]
You can’t perform that action at this time.
0 commit comments