Skip to content
This repository has been archived by the owner on Apr 27, 2020. It is now read-only.

Commit

Permalink
Add variable for defining the profile to be used with aws-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongorka committed Jul 18, 2019
1 parent 00b5719 commit 3eacf2a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ To improve the security of your clusters this module defaults to expecting KIAM
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| autotag\_subnets | Automatically add Kubernetes tags to subnets. Requires aws-cli to be available. | string | `"false"` | no |
| autotag\_profile | Defines an optional AWS profile to use with aws-cli when auto-tagging subnets | string | `"false"` | no |
| cluster\_endpoint\_private\_access | Enable Amazon EKS private API server endpoint. | string | `"false"` | no |
| cluster\_endpoint\_public\_access | Enable Amazon EKS public API server endpoint. | string | `"true"` | no |
| cluster\_name | Name of the EKS Cluster | string | n/a | yes |
Expand Down
8 changes: 6 additions & 2 deletions tags.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
optional_profile = var.autotag_profile ? "--profile ${var.autotag_profile}" : ""
}

resource "null_resource" "tag-public-subnet" {
count = var.autotag_subnets ? 1 : 0

Expand All @@ -6,7 +10,7 @@ resource "null_resource" "tag-public-subnet" {
}

provisioner "local-exec" {
command = "aws ec2 create-tags --resources ${join(" ", var.public_subnets)} --tags Key=kubernetes.io/cluster/${var.cluster_name},Value=shared Key=kubernetes.io/role/elb,Value=1"
command = "aws ec2 create-tags --resources ${join(" ", var.public_subnets)} --tags Key=kubernetes.io/cluster/${var.cluster_name},Value=shared Key=kubernetes.io/role/elb,Value=1 ${local.optional_profile}"
}
}

Expand All @@ -18,7 +22,7 @@ resource "null_resource" "tag-private-subnet" {
}

provisioner "local-exec" {
command = "aws ec2 create-tags --resources ${join(" ", var.private_subnets)} --tags Key=kubernetes.io/cluster/${var.cluster_name},Value=shared Key=kubernetes.io/role/internal-elb,Value=1"
command = "aws ec2 create-tags --resources ${join(" ", var.private_subnets)} --tags Key=kubernetes.io/cluster/${var.cluster_name},Value=shared Key=kubernetes.io/role/internal-elb,Value=1 ${local.optional_profile}"
}
}

5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ variable "autotag_subnets" {
default = false
}

variable "autotag_profile" {
description = "Defines an optional AWS profile to use with aws-cli when auto-tagging subnets"
default = false
}

variable "enable_cert_manager" {
description = "Enable required components for Cert-Manager"
default = true
Expand Down

0 comments on commit 3eacf2a

Please sign in to comment.