Skip to content

Commit

Permalink
add awscli variables
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Oct 14, 2021
1 parent f8c47b8 commit ff380e1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions common/variables.awscli.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
variable "region" {
description = "AWS region (default: pull from current running provider)"
type = string
default = ""
}

variable "profile" {
description = "AWS config profile. This is needed because we call the AWSCLI."
type = string
}
2 changes: 2 additions & 0 deletions patch-aws-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ No modules.
| <a name="input_nodegroup_instance_disk_size"></a> [nodegroup\_instance\_disk\_size](#input\_nodegroup\_instance\_disk\_size) | The size of EKS nodegroup EBS disk in gigabytes (default: 40) | `number` | `40` | no |
| <a name="input_nodegroup_maximum_size"></a> [nodegroup\_maximum\_size](#input\_nodegroup\_maximum\_size) | EKs Nodegroup maximum size (default: 16) | `number` | `16` | no |
| <a name="input_nodegroup_minumum_size"></a> [nodegroup\_minumum\_size](#input\_nodegroup\_minumum\_size) | EKS Nodegroup minimum size (default: 1) | `number` | `1` | no |
| <a name="input_profile"></a> [profile](#input\_profile) | AWS config profile. This is needed because we call the AWSCLI. | `string` | n/a | yes |
| <a name="input_region"></a> [region](#input\_region) | AWS region (default: pull from current running provider) | `string` | `""` | no |

## Outputs

Expand Down
5 changes: 4 additions & 1 deletion patch-aws-auth/kubeconfig.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ resource "null_resource" "kubeconfig" {
provisioner "local-exec" {
command = "which kubectl > /dev/null 2>&1; if [ $? != 0 ]; then 'echo missing kubectl'; exit 1; else exit 0; fi"
}
provisioner "local-exec" {
command = "which aws > /dev/null 2>&1; if [ $? != 0 ]; then 'echo missing aws-cli (v2)'; exit 1; else exit 0; fi"
}
provisioner "local-exec" {
command = "test -d '${path.root}/setup' || mkdir '${path.root}/setup'"
}
provisioner "local-exec" {
environment = {
AWS_PROFILE = var.profile
AWS_REGION = var.region
AWS_REGION = local.region
}
command = "aws eks update-kubeconfig --name ${var.cluster_name} --kubeconfig ${path.root}/setup/aws-auth.kube.config"
}
Expand Down
2 changes: 1 addition & 1 deletion patch-aws-auth/locals.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
region = data.aws_region.current.name
region = var.region == "" ? data.aws_region.current.name : var.region
aws_eks_cluster_auth = data.aws_eks_cluster_auth.cluster
aws_eks_cluster = data.aws_eks_cluster.cluster
}
Expand Down
1 change: 1 addition & 0 deletions patch-aws-auth/variables.awscli.tf

0 comments on commit ff380e1

Please sign in to comment.