diff --git a/kubectl.tf b/kubectl.tf index 3f46a5a..bdce069 100644 --- a/kubectl.tf +++ b/kubectl.tf @@ -37,3 +37,14 @@ resource "aws_s3_bucket_object" "kubeconfig" { key = "${var.project}/${var.environment}/kubeconfig" source = "./kubeconfig_${var.project}-${var.environment}" } + +data "aws_s3_bucket_object" "kubeconfig_local" { + depends_on = ["aws_s3_bucket_object.kubeconfig"] + bucket = "${var.s3_bucket_name}" + key = "${var.project}/${var.environment}/kubeconfig" +} + +resource "local_file" "kubeconfig_local" { + content = "${data.aws_s3_bucket_object.kubeconfig_local.body}" + filename = "${path.cwd}/kubeconfig_local" +}